user_can.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_GPIOB, ENABLE)
  13. #define USER_CAN_RCC_ENABLE RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);
  14. #define USER_CAN_REMAPCONFIG_ENABLE GPIO_PinRemapConfig(GPIO_Remap1_CAN1, ENABLE);
  15. #define CAN_TX_GPIO GPIOB
  16. #define CAN_TX_PIN GPIO_Pin_9
  17. #define CAN_RX_GPIO GPIOB
  18. #define CAN_RX_PIN GPIO_Pin_8
  19. #define CAN_TYPE CAN1
  20. typedef enum
  21. {
  22. DIPSW_QUEUE_TIME = 0,
  23. CAN_QUEUE_SEND = 1,
  24. CAN_QUEUE_RECIEVE = 2,
  25. CAN_QUEUE_TIME = 3,
  26. }USER_CAN_QUEUE_TYPE;
  27. typedef struct{
  28. uint8_t sendData[8];
  29. uint8_t sendSize;
  30. CanRxMsg RxMessage;
  31. }user_can_work_s;
  32. typedef void (*vUser_can_recv_data_func)(uint8_t *data, uint8_t size);
  33. void vUser_can_init(void);
  34. void vUser_can_send_data(uint8_t *data, uint8_t size);
  35. void vUser_can_set_recv_data_func(vUser_can_recv_data_func func);
  36. void vUser_can_recv_data(CanRxMsg *RxMessage);
  37. void vUser_can_set_addr(uint8_t addr);
  38. extern tmosTaskID user_can_task_id;
  39. #ifdef __cplusplus
  40. }
  41. #endif
  42. #endif // ACTION_MOTOR_H__
  43. /** @} */