#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 "stm32f4xx_can.h" /************************************************************************************************ * Defines * ************************************************************************************************/ #define CAN_IER CAN1->IER #define CAN_IT_TME_ENABLE() CAN_ITConfig(CAN1, CAN_IT_TME, ENABLE) #define CAN_IT_TME_DISABLE() CAN_ITConfig(CAN1, CAN_IT_TME, DISABLE) /************************************************************************************************ * 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)(CanRxMsg); /************************************************************************************************ * Interfaces * ************************************************************************************************/ uint8_t can_msg_tx(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); void can_tx_iqr(void); void can_rx_iqr(void); #ifdef __cplusplus }; #endif #endif // __CAN_INTERFACE_H