| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #ifndef DRV_CAN_H
- #define DRV_CAN_H
- #include "shark_types.h"
- #define FRAME_PRO_0 (0)
- #define FRAME_PRO_1 (1)
- #define FRAME_PRO_2 (2)
- #define FRAME_PRO_3 (3)
- #define FRAME_PRO_4 (4)
- #define FRAME_PRO_5 (5)
- #define FRAME_PRO_6 (6)
- #define FRAME_PRO_7 (7)
- #define FRAME_PRO_D (FRAME_PRO_0)
- #define FRAME_PT_NEED_RSP (1)
- #define FRAME_PT_RSP (2)
- #define FRAME_PT_NO_RSP (3)
- #define PRINTF_TER_ID (0x45UL)
- #define SELF_ID (0x42UL)
- #define CTR_ID (0x43UL)
- #define BROCAST_ID (0x7FUL)
- #define CAN_TX_BUF_MAX (256)
- #define CAN_RX_BUF_MAX (256)
- #define CAN_RX_CTR_BRO_BUF_MAX (256)
- #define CAN_RX_TEST_BRO_BUF_MAX (256)
- #define get_index_total_value(x) ((x)?(x):(32))
- #define Silent_Enable(x) gpio_bit_write(GPIOA,GPIO_PIN_7,(bit_status)(x))
- typedef union {
- u32 value;
- struct {
- u32 dest :7;
- u32 src :7;
- u32 index :5;
- u32 total :5;
- u32 type :2;
- u32 priority :3;
- u32 length :3;
- };
- } shark_can_efid_t;
- typedef struct {
- shark_can_efid_t efid;
- union {
- u16 key;
- u8 data[8];
- u32 values[2];
- };
- } shark_can_frame_t;
- #pragma pack (push,1)
- typedef struct
- {
- uint32_t other:3;
- uint32_t dest:7;
- uint32_t sour:7;
- uint32_t index:5;
- uint32_t total:5;
- uint32_t rsp:2;
- uint32_t pro:3;
- }HEAD;
- typedef struct
- {
- HEAD head;
- uint8_t* data;
- uint16_t len;
- }CAN_FRAME;
- #pragma pack(pop)
- extern CAN_FRAME can_ctr_self;
- extern CAN_FRAME can_ctr_bro;
- extern CAN_FRAME can_test_bro;
- enum
- {
- BMS_1_SELF,
- BMS_1_CUR_VOL_SELF,
- BMS_1_RSP,
- BMS_1_RESEND,
- TIMEOUT_BMS_1_RESEND,
-
- BMS_2_SELF,
- BMS_2_CUR_VOL_SELF,
- BMS_2_RSP,
- BMS_2_RESEND,
- TIMEOUT_BMS_2_RESEND,
- CTR_SELF,
- CTR_RSP,
- CTR_RESEND,
- TIMEOUT_CTR_RESEND,
- ADAS_SELF,
- ADAS_RSP,
- ADAS_RESEND,
- TIMEOUT_ADAS_RESEND,
-
- OTHER_SEND,
- CAN_TEST
- };
- void CAN_Config_HW(void);
- void CAN_Config(void);
- uint16_t Get_Data_Can(CAN_FRAME*app_can_frame);
- int8_t Send_Data_Can(CAN_FRAME*app_can_frame,uint8_t from);
- void Check_Can_Poll(void);
- void Can_Stop_Send(void);
- shark_bool shark_can_send_frame(shark_can_efid_t efid, const void *buff, u8 length);
- shark_bool shark_can_send(u8 dest, u8 src, u8 type, const u8 *buff, u16 length);
- void shark_can_tx_flush(void);
- #endif
|