#ifndef __CAN_INTERFACE_H #define __CAN_INTERFACE_H #ifdef __cplusplus extern "C" { #endif #ifdef __CAN_INTERFACE_H_GLOBAL #define __CAN_INTERFACE_H_EXTERN #else #define __CAN_INTERFACE_H_EXTERN extern #endif /************************************************************************************************ * Version * ************************************************************************************************/ /************************************************************************************************ * How to use * ************************************************************************************************/ /************************************************************************************************ * Enable config * ************************************************************************************************/ /************************************************************************************************ * Includes * ************************************************************************************************/ #include /************************************************************************************************ * Defines * ************************************************************************************************/ #define CAN_IER hcan.Instance->IER #define CAN_IT_TME_ENABLE() HAL_CAN_ActivateNotification(&hcan, CAN_IT_TX_MAILBOX_EMPTY) #define CAN_IT_TME_DISABLE() HAL_CAN_DeactivateNotification(&hcan, CAN_IT_TX_MAILBOX_EMPTY) /************************************************************************************************ * Typedefs * ************************************************************************************************/ typedef struct { struct { uint8_t ide; uint8_t rtr; uint8_t dlc; } reg; union { uint32_t r; struct { uint8_t sa : 8; uint8_t ps : 8; uint8_t pf : 8; uint8_t dp : 1; uint8_t r : 1; uint8_t p : 3; } b; } id; union { uint8_t u8_buf[8]; uint16_t u16_buf[4]; uint32_t u32_buf[2]; uint64_t u64_buf; } data; } pdu_tag, *p_pdu_tag; typedef void (*pcan_tx)(void); typedef void (*pcan_rx)(CAN_RxHeaderTypeDef, uint8_t *); /************************************************************************************************ * Interfaces * ************************************************************************************************/ uint8_t can_write(uint32_t id, uint8_t id_type, uint8_t *p_data, uint8_t len); void can_rx_back_init(pcan_rx p_fun); void can_tx_back_init(pcan_tx p_fun); #ifdef __cplusplus }; #endif #endif // __CAN_INTERFACE_H