基质喷涂
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

  1. /*
  2. * can_controller.h
  3. *
  4. * Created on: Feb 20, 2025
  5. * Author: iflyt
  6. */
  7. #ifndef APPHAL_CAN_CONTROLLER_H_
  8. #define APPHAL_CAN_CONTROLLER_H_
  9. #include <stm32f4xx_hal.h>
  10. #include "can_message.h"
  11. #include "can_protocol_factory.h"
  12. #include "can_protocol_parser.h"
  13. #include "can.h"
  14. // 使用 CMSIS - RTOS v2 头文件
  15. #include "cmsis_os2.h"
  16. class CANSystemResourceManager {
  17. public:
  18. CANSystemResourceManager();
  19. ~CANSystemResourceManager();
  20. };
  21. // CAN 收发控制类
  22. class CanController {
  23. public:
  24. CanController();
  25. ~CanController();
  26. bool start(CAN_HandleTypeDef* hcan);
  27. void stop();
  28. bool sendMessage(const CanMessage& msg);
  29. private:
  30. static void canTxTask(void *argument);
  31. static void canParserTask(void *argument);
  32. CAN_HandleTypeDef* hcan;
  33. CanProtocolParser parser;
  34. osMessageQueueId_t tx_queue;
  35. osThreadId_t tx_task_handle;
  36. osThreadId_t parser_task_handle;
  37. osMutexId_t mutex_tx_queue_;
  38. };
  39. #endif /* APPHAL_CAN_CONTROLLER_H_ */