CAN
Function Description
Use ESP32 internal CAN controller resources to achieve CAN bus data sending and receiving, Note: Before use, you need to access the device for the
CAN UNIT
.
Init bus n extframe True/False mode x baudrate TX RX
- Initialisation of the CAN bus, configuration of the frame expansion mode, operating modes (normal, loopback, etc.) and baud rate setting.
Get state of the controller
- Get CAN controller status
If any message wating on the FIFO
- Checking for unread data in FIFOs
Send Message with id x
- Sends a piece of data and specifies the ID of the data frame, the ID length is 1 byte, the incoming data type is required to be
list
or tuple
, and the data length of the data frame is required to be 8 bytes
.
Receive message
Set filter bank x mode x message
Clear filter
Clear TX queue
Clear RX queue
- Clearing the receive queue
Restart
Deinit
Usage
Test case: Using two M5Core devices, connect CAN UNIT to PORT C (if you want to use a different port, please change the pin configuration in the initialisation program), run the following program and press button A to send a data frame.