/*
**@brief CAN服务初始化
*/
void slave_can_services_init(void)
{
struct rt_thread *tid = NULL;
rt_err_t result = 0;
CAN2_Init();
// 静态通信状态邮箱初始化
result = rt_mb_init(&slave_mb_status, "mb_slave_comm", &slave_status_mb_pool, sizeof(slave_status_mb_pool) / 4, RT_IPC_FLAG_FIFO);
if(result != RT_EOK)
{
slave_can_dbg_msg("init mb_slave_comm failed.\n");
}
// 发送信号量初始化
result = rt_sem_init(&SlaveCanTxSem, "SlaveCanTxSem", 0, RT_IPC_FLAG_FIFO);
if(result != RT_EOK)
{
slave_can_dbg_msg("init SlaveCanTxSem failed.\n");
}
// 接收信号量初始化
result = rt_sem_init(&SlaveCanRxSem, "SlaveCanRxSem", 0, RT_IPC_FLAG_FIFO);
if(result != RT_EOK)
{
slave_can_dbg_msg("init SlaveCanRxSem failed.\n");
}
// 创建及启动发送线程
tid = rt_thread_create("slave_can_tx", slave_can_tx_services_entry, RT_NULL, SLAVE_CAN_TX_STACK_SIZE, SLAVE_CAN_TX_PRIORITY, SLAVE_CAN_TX_TICK);
if(tid != RT_NULL)
{
rt_thread_startup(tid);
}
else
{
slave_can_dbg_msg("create slave_can_tx_thread failed.\n");
}
// 创建及启动接收线程
tid = rt_thread_create("slave_can_rx", slave_can_rx_services_entry, RT_NULL, SLAVE_CAN_RX_STACK_SIZE, SLAVE_CAN_RX_PRIORITY, SLAVE_CAN_RX_TICK);
if(tid != RT_NULL)
{
rt_thread_startup(tid);
}
else
{
slave_can_dbg_msg("create slave_can_rx_thread failed.\n");
}
}
#define SLAVE_CAN_RX_STACK_SIZE (1024u)
#define SLAVE_CAN_RX_PRIORITY (2u)
#define SLAVE_CAN_RX_TICK (20u)
#define SLAVE_CAN_TX_STACK_SIZE (1024u)
#define SLAVE_CAN_TX_PRIORITY (3u)
#define SLAVE_CAN_TX_TICK (20u)
slave_can_tx_services_entry线程就是运行不了,静态初始化也试了,也不行,出鬼了,请大侠协助分析,谁愿意帮我分析,我可以把源工程文件都给他,Jason-PengYunjian,谢谢!