user_can.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _USER_CAN_H__
  2. #define _USER_CAN_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "define.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #define USER_CAN_INTERVAL 10
  10. #define CAN_SDO_RX 0x600
  11. #define CAN_SDO_TX 0x580
  12. #define USER_CAN_GPIO_RCC_ENABLE RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA, ENABLE)
  13. #define USER_CAN_RCC_ENABLE RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);
  14. #define CAN_TX_GPIO GPIOA
  15. #define CAN_TX_PIN GPIO_Pin_12
  16. #define CAN_RX_GPIO GPIOA
  17. #define CAN_RX_PIN GPIO_Pin_11
  18. #define CAN_TYPE CAN1
  19. typedef enum
  20. {
  21. DIPSW_QUEUE_TIME = 0,
  22. CAN_QUEUE_SEND = 1,
  23. CAN_QUEUE_RECIEVE = 2,
  24. CAN_QUEUE_TIME = 3,
  25. }USER_CAN_QUEUE_TYPE;
  26. typedef struct{
  27. uint8_t sendData[8];
  28. uint8_t sendSize;
  29. CanRxMsg RxMessage;
  30. }user_can_work_s;
  31. typedef void (*vUser_can_recv_data_func)(uint8_t *data, uint8_t size);
  32. void vUser_can_init(void);
  33. void vUser_can_send_data(uint8_t *data, uint8_t size);
  34. void vUser_can_set_recv_data_func(vUser_can_recv_data_func func);
  35. void vUser_can_recv_data(CanRxMsg *RxMessage);
  36. void vUser_can_set_addr(uint8_t addr);
  37. extern tmosTaskID user_can_task_id;
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif // ACTION_MOTOR_H__
  42. /** @} */