drv_can.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef DRV_CAN_H
  2. #define DRV_CAN_H
  3. #define FRAME_PRO_0 (0)
  4. #define FRAME_PRO_1 (1)
  5. #define FRAME_PRO_2 (2)
  6. #define FRAME_PRO_3 (3)
  7. #define FRAME_PRO_4 (4)
  8. #define FRAME_PRO_5 (5)
  9. #define FRAME_PRO_6 (6)
  10. #define FRAME_PRO_7 (7)
  11. #define FRAME_PRO_D (FRAME_PRO_0)
  12. #define FRAME_PT_NEED_RSP (1)
  13. #define FRAME_PT_RSP (2)
  14. #define FRAME_PT_NO_RSP (3)
  15. #define PRINTF_TER_ID (0x45UL)
  16. #define SELF_ID (0x42UL)
  17. #define CTR_ID (0x43UL)
  18. #define BROCAST_ID (0x7FUL)
  19. #define CAN_TX_BUF_MAX (256)
  20. #define CAN_RX_BUF_MAX (256)
  21. #define CAN_RX_CTR_BRO_BUF_MAX (256)
  22. #define CAN_RX_TEST_BRO_BUF_MAX (256)
  23. #define get_index_total_value(x) ((x)?(x):(32))
  24. #define Silent_Enable(x) gpio_bit_write(GPIOA,GPIO_PIN_7,(bit_status)(x))
  25. #pragma pack (push,1)
  26. typedef struct
  27. {
  28. uint32_t other:3;
  29. uint32_t dest:7;
  30. uint32_t sour:7;
  31. uint32_t index:5;
  32. uint32_t total:5;
  33. uint32_t rsp:2;
  34. uint32_t pro:3;
  35. }HEAD;
  36. typedef struct
  37. {
  38. HEAD head;
  39. uint8_t* data;
  40. uint16_t len;
  41. }CAN_FRAME;
  42. #pragma pack(pop)
  43. extern CAN_FRAME can_ctr_self;
  44. extern CAN_FRAME can_ctr_bro;
  45. extern CAN_FRAME can_test_bro;
  46. enum
  47. {
  48. BMS_1_SELF,
  49. BMS_1_CUR_VOL_SELF,
  50. BMS_1_RSP,
  51. BMS_1_RESEND,
  52. TIMEOUT_BMS_1_RESEND,
  53. BMS_2_SELF,
  54. BMS_2_CUR_VOL_SELF,
  55. BMS_2_RSP,
  56. BMS_2_RESEND,
  57. TIMEOUT_BMS_2_RESEND,
  58. CTR_SELF,
  59. CTR_RSP,
  60. CTR_RESEND,
  61. TIMEOUT_CTR_RESEND,
  62. ADAS_SELF,
  63. ADAS_RSP,
  64. ADAS_RESEND,
  65. TIMEOUT_ADAS_RESEND,
  66. OTHER_SEND,
  67. CAN_TEST
  68. };
  69. void CAN_Config_HW(void);
  70. void CAN_Config(void);
  71. uint16_t Get_Data_Can(CAN_FRAME*app_can_frame);
  72. int8_t Send_Data_Can(CAN_FRAME*app_can_frame,uint8_t from);
  73. void Check_Can_Poll(void);
  74. void Can_Stop_Send(void);
  75. #endif