#ifndef _DRV_CAN_H_ #define _DRV_CAN_H_ #ifdef __cplusplus extern "C" { #endif #include "kit_macro.h" #define CAN_DATA_LEN (8u) typedef enum { kcan_dev_e_1, kcan_dev_e_2, kcan_dev_e_End, }can_dev_e; typedef enum { kcan_interrupt_e_Rx = 0, kcan_interrupt_e_Tx, kcan_interrupt_e_End, }can_interrupt_e; typedef enum { kcan_frame_type_e_Std = 0, kcan_frame_type_e_Ext, kcan_frame_type_e_End, } can_frame_type_e; //1远程帧 0数据帧 typedef enum { kCanRtr_Data = 0, kCanRtr_Remote, kCanRtr_End, }CanRtr; typedef enum { kcan_filter_e_Mask, kcan_filter_e_List, kcan_filter_e_End, }can_filter_e; typedef union { uint32_t value; struct { uint8_t b0; uint8_t b1; uint8_t b2; uint8_t b3; }b; }CanId; typedef union { uint8_t byte[CAN_DATA_LEN]; uint32_t value[2]; }CanData; typedef struct { CanId id; uint8_t len; can_frame_type_e ide; //标示符类型 CanRtr rtr; //远程数据类型 CanData data; }CanMsg; kit_ret_e drv_can_init(can_dev_e dev, uint32_t baud_rate, uint16_t rx_idx, uint16_t tx_idx); kit_ret_e drv_can_send(can_dev_e dev, CanMsg *msg); kit_ret_e drv_can_receive(can_dev_e dev, CanMsg *msg); uint8_t drv_can_get_mailbox(can_dev_e dev); kit_ret_e drv_can_set_interrupt(can_dev_e dev, can_interrupt_e it_type, uint16_t priority, KitIrqCall call); kit_ret_e drv_can_set_filter(uint8_t channel, can_filter_e mode, can_frame_type_e ide, uint32_t rcv_id, uint32_t mask_id); kit_ret_e drv_can_ctrl_interrupt(can_dev_e dev, can_interrupt_e it_type, bool is_enable); #ifdef __cplusplus } #endif #endif