CAN FD外设
1、STATIC_INLINE void CANFD_setMode(uint32_t base, CANFD_ModeType modes)
- function description: Set the working mode of CANFD module.
- parameter description:
- input parameters:
-base: base address of CANFD module register;
-modes: selects the operating mode of the CANFD module.
- return parameter: None.
2、STATIC_INLINE void CANFD_setCmd(uint32_t base, CANFD_CmdType cmds)
- function description: Set the data transmission of CANFD module.
- parameter description:
- input parameters:
-base: base address of CANFD module register;
-cmds: Set the data sending. The optional parameter values are as follows:
-0x01: stop the data transmission of the secondary transmission buffer;
-0x02: start sending all data in the secondary send buffer;
-0x04: start the transmission of single frame data in the secondary transmission buffer;
-0x08: stop sending data in the main send buffer;
-0x10: start the data transmission of the main transmission buffer;
-0 x20: control CAN transceiver to enter standby mode;
-0x40: Set the can controller to enter the listen-only mode;
-0x80: Select the secondary transmit buffer for data transmission.
- return parameter: None.
3、STATIC_INLINE void CANFD_setInterrupt(uint32_t base, CANFD_IntType ints)
- function description: Enables receive and transmit interrupts associated with the CANFD module.
- parameter description:
- input parameters:
-base: base address of CANFD module register;
-ints: Select the interrupt to be enabled. The optional parameter values are as follows:
- 0 x02: enable error interrupt;
- 0 x04: Enable secondary transmit buffer transmit interrupt;
- 0 x08: Enable main transmit buffer transmit interrupt;
- 0x10: Enable receive buffer to be full interrupt;
- 0x20: Enable receive buffer full load interrupt;
- 0x40: Enable receive buffer overload interrupt;
- 0x80: Enable receive interrupts for the receive buffer. An interrupt is generated for each valid and accepted message.
- return parameter: None.
4、STATIC_INLINE void CANFD_setAcceptFilter(uint32_t base, uint32_t acr, uint32_t amr)
- function description: Set the receive filter of CANFD.
- parameter description:
- input parameters:
-base: base address of CANFD module register;
-acr: the verification code of the filter, specifying the verification value.
-amr: The mask of the filter, which specifies which bits need to be verified.
- return parameter: None.
5、STATIC_INLINE u32 CANFD_isTransmitterBusy(uint32_t base)
- function description: Obtain the sending status of CANFD controller.
- parameter description:
- input parameters:
-base: base address of CANFD module register;
- return parameters:
-1: The controller is currently sending a frame;
-0: The controller is not sending activity.
6、STATIC_INLINE u32 CANFD_isReceiveBusy(uint32_t base)
- function description: Obtain the receiving status of CANFD controller.
- parameter description:
- input parameter: base: base address of CANFD module register;
- return parameters:
-1: The controller is currently receiving a frame;
-0: The controller is not receiving activity.
7、void CANFD_sendFrame(uint32_t base, uint32_t sta_id, CANFD_TTSEN ttsen, CANFD_BRS brs, CANFD_FDF fdf, CANFD_RTR rtr, CANFD_IDE ide, const void *msg, u8 DLC)
- function description: CANFD send API function.
- parameter description:
- input parameters:
-base: base address of CANFD module register;
- sta _ ID: ID of CAN data frame;
- ttsen: send timestamp enable bit,
-1: enable timestamp update,
-0: Do not obtain the sending timestamp of this frame;
- brs: bit rate switching,
-1: data load and CRC switch to fast bit rate,
-0: Use a slow bit rate for the entire frame;
- fDF: set the working mode of CAN controller,
- 1:CANFD,
-0: Classic CAN;
- rTR: Remote transmission request,
-1: remote frame,
-0: data frame;
- iDE: Set the format of data frame,
-1: extended format,
-0: standard format;
- mSG: the first address of the data to be sent;
- dLC: Data length.
return parameter: none
8、void CANFD_recvFrameBlocking(uint32_t base, void *msg)
- function description: CANFD receive API function.
- parameter description:
- input parameters:
-base: base address of CANFD module register;
- msg: Received data frame.
- return parameter: none