mirror of
https://gitee.com/dlmu-cone/tronone-h7-scaffold
synced 2026-07-24 19:37:45 +08:00
CAN CAN NEED
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "daemon.h"
|
||||||
|
|
||||||
static PowerMeterInstance *power_meter_instance = NULL;
|
static PowerMeterInstance *power_meter_instance = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +86,7 @@ PowerMeterInstance *PowerMeterInit(FDCAN_HandleTypeDef *can_handle)
|
|||||||
}
|
}
|
||||||
memset(power_meter_instance, 0, sizeof(PowerMeterInstance));
|
memset(power_meter_instance, 0, sizeof(PowerMeterInstance));
|
||||||
|
|
||||||
// 配置FDCAN初始化参数 - 完全适配您的FDCAN驱动
|
// 配置功率计初始化参数
|
||||||
FDCAN_Init_Config_s can_config = {
|
FDCAN_Init_Config_s can_config = {
|
||||||
.can_handle = can_handle,
|
.can_handle = can_handle,
|
||||||
.rx_id = 0x213, // 功率计反馈标识符
|
.rx_id = 0x213, // 功率计反馈标识符
|
||||||
@@ -93,7 +95,7 @@ PowerMeterInstance *PowerMeterInit(FDCAN_HandleTypeDef *can_handle)
|
|||||||
.id = power_meter_instance, // 将实例指针作为ID传递
|
.id = power_meter_instance, // 将实例指针作为ID传递
|
||||||
};
|
};
|
||||||
|
|
||||||
// 注册FDCAN实例 - 使用FDCANRegister函数
|
// 注册FDCAN实例
|
||||||
power_meter_instance->can_instance = CANRegister(&can_config);
|
power_meter_instance->can_instance = CANRegister(&can_config);
|
||||||
if (power_meter_instance->can_instance == NULL)
|
if (power_meter_instance->can_instance == NULL)
|
||||||
{
|
{
|
||||||
@@ -103,12 +105,12 @@ PowerMeterInstance *PowerMeterInit(FDCAN_HandleTypeDef *can_handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//注册守护进程
|
//注册守护进程
|
||||||
// Daemon_Init_Config_s daemon_config = {
|
Daemon_Init_Config_s daemon_config = {
|
||||||
// .callback = PowerMeterLostCallback,
|
.callback = PowerMeterLostCallback,
|
||||||
// .owner_id = power_meter_instance,
|
.owner_id = power_meter_instance,
|
||||||
// .reload_count = 5, // 50ms未收到数据则认为丢失 (1000Hz发送,5个周期)
|
.reload_count = 5, // 50ms未收到数据则认为丢失 (1000Hz发送,5个周期)
|
||||||
// };
|
};
|
||||||
// power_meter_instance->daemon = DaemonRegister(&daemon_config);
|
power_meter_instance->daemon = DaemonRegister(&daemon_config);
|
||||||
|
|
||||||
return power_meter_instance;
|
return power_meter_instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,10 @@
|
|||||||
#ifndef TRONONEH7_SCAFFOLD_XIDIPWMETER_H
|
#ifndef TRONONEH7_SCAFFOLD_XIDIPWMETER_H
|
||||||
#define TRONONEH7_SCAFFOLD_XIDIPWMETER_H
|
#define TRONONEH7_SCAFFOLD_XIDIPWMETER_H
|
||||||
|
|
||||||
#include "general_def.h"
|
|
||||||
#include "bsp_dwt.h"
|
#include "bsp_dwt.h"
|
||||||
#include "bsp_fdcan.h"
|
#include "bsp_fdcan.h"
|
||||||
|
#include "daemon.h"
|
||||||
|
#include "general_def.h"
|
||||||
|
|
||||||
/* 功率计测量数据结构 */
|
/* 功率计测量数据结构 */
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -25,7 +26,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
FDCANInstance *can_instance; // FDCAN实例指针
|
FDCANInstance *can_instance; // FDCAN实例指针
|
||||||
PowerMeter_Measure_s measure; // 测量数据
|
PowerMeter_Measure_s measure; // 测量数据
|
||||||
// DaemonInstance *daemon; // 守护进程
|
Daemon_Instance *daemon; // 守护进程
|
||||||
uint32_t feed_cnt; // 喂狗计数器
|
uint32_t feed_cnt; // 喂狗计数器
|
||||||
} PowerMeterInstance;
|
} PowerMeterInstance;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user