pdf-icon

CAN

Function Description

Utilizes the internal CAN controller resources of the ESP32 to implement CAN bus data transmission and reception. Note: Before use, the device must be connected to a CAN UNIT .

Init bus n extframe True/False mode x baudrate TX RX

  • Initializes the CAN bus, configures whether it is in extended frame mode, the working mode (normal mode, loopback mode, etc.), and sets the baud rate.

Get state of the controller

  • Gets the state of the CAN controller.

If any message waiting on the FIFO

  • Checks if there are unread messages in the FIFO.

Send Message with id x

  • Sends a message and specifies the ID of the data frame. The ID length is 1 byte. The input data type must be list or tuple, and the data frame's data length is required to be 8 bytes.

Receive message

  • Receives data.

Set filter bank x mode x message

  • Sets a filter bank.

Clear filter

  • Clears the filter bank.

Clear TX queue

  • Clears the transmission queue.

Clear RX queue

  • Clears the reception queue.

Restart

  • Restarts the CAN bus.

Deinit

  • Stops the CAN bus.

Usage Method

Test case: Use two M5Core devices, connect the CAN UNIT to PORT C on each (if you need to use a different port, please change the pin configuration in the initialization program), and run the following program on each device. Press button A to send a data frame.
On This Page