You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
993 B
48 lines
993 B
/*
|
|
* can_controller.h
|
|
*
|
|
* Created on: Feb 20, 2025
|
|
* Author: iflyt
|
|
*/
|
|
|
|
#ifndef APPHAL_CAN_CONTROLLER_H_
|
|
#define APPHAL_CAN_CONTROLLER_H_
|
|
|
|
#include <stm32f4xx_hal.h>
|
|
#include "can_message.h"
|
|
#include "can_protocol_factory.h"
|
|
#include "can_protocol_parser.h"
|
|
#include "can.h"
|
|
// 使用 CMSIS - RTOS v2 头文件
|
|
#include "cmsis_os2.h"
|
|
|
|
class CANSystemResourceManager {
|
|
public:
|
|
CANSystemResourceManager();
|
|
~CANSystemResourceManager();
|
|
};
|
|
|
|
// CAN 收发控制类
|
|
class CanController {
|
|
public:
|
|
CanController();
|
|
~CanController();
|
|
bool start(CAN_HandleTypeDef* hcan);
|
|
void stop();
|
|
bool sendMessage(const CanMessage& msg);
|
|
|
|
private:
|
|
static void canTxTask(void *argument);
|
|
static void canParserTask(void *argument);
|
|
CAN_HandleTypeDef* hcan;
|
|
CanProtocolParser parser;
|
|
|
|
osMessageQueueId_t tx_queue;
|
|
|
|
osThreadId_t tx_task_handle;
|
|
osThreadId_t parser_task_handle;
|
|
|
|
osMutexId_t mutex_tx_queue_;
|
|
};
|
|
|
|
#endif /* APPHAL_CAN_CONTROLLER_H_ */
|