|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The panel's CAN (Controller Area Network) driver. More...
Go to the source code of this file.
Enumerations | |
| enum | can_twai_health_t { CAN_TWAI_UNKNOWN = 0 , CAN_TWAI_RUNNING , CAN_TWAI_RECOVERING , CAN_TWAI_STOPPED , CAN_TWAI_BUS_OFF } |
Functions | |
| esp_err_t | can_twai_start (uint32_t bitrate) |
| Start TWAI at a bit rate made exactly from the 40MHz crystal. | |
| void | can_twai_stop (void) |
| Stop TWAI and uninstall its driver. Does nothing when it is not running. | |
| bool | can_twai_send (const link_can_frame_t *f, uint32_t timeout_ms) |
| bool | can_twai_recv (link_can_frame_t *f, uint32_t timeout_ms) |
| can_twai_health_t | can_twai_recover (void) |
| Look at the controller and put it back on the bus if it has fallen off. | |
| can_twai_health_t | can_twai_health (void) |
| bool | can_twai_errors (uint32_t *tx_err, uint32_t *rx_err, uint32_t *bus_err, bool *bus_off) |
The panel's CAN (Controller Area Network) driver.
On the ESP32-P4's TWAI (Two-Wire Automotive Interface) controller 0, GPIO22 TX and GPIO21 RX (board_pins.h), clocked from the 40MHz crystal. The bit timing comes from shared/can, which is host-tested; this file holds the peripheral's configuration and the send and receive calls.
SPDX-License-Identifier: MIT
| enum can_twai_health_t |
What the controller is doing, as can_twai_recover() found it.
| bool can_twai_errors | ( | uint32_t * | tx_err, |
| uint32_t * | rx_err, | ||
| uint32_t * | bus_err, | ||
| bool * | bus_off ) |
Bus error counters, for the report. Any pointer may be NULL.
False when the controller is not running or its status would not read; the outputs are then left as the caller set them, because zeros would read as a healthy bus.
| can_twai_health_t can_twai_health | ( | void | ) |
The same reading without acting on it.
For anything that reports the controller's state rather than repairing it, so a diagnosis does not start a recovery as a side effect of being looked at.
| can_twai_health_t can_twai_recover | ( | void | ) |
Look at the controller and put it back on the bus if it has fallen off.
A transmitter nobody answers reaches the bus-off threshold in about four milliseconds at 1Mbit/s, and this peripheral does not recover on its own: without this call every later transmit fails and the link is gone until the panel is power-cycled. Call it while the link is down; it takes one step per call and never blocks.
| bool can_twai_recv | ( | link_can_frame_t * | f, |
| uint32_t | timeout_ms ) |
Take one frame, if one arrives within timeout_ms.
| bool can_twai_send | ( | const link_can_frame_t * | f, |
| uint32_t | timeout_ms ) |
Queue one frame. timeout_ms of 0 does not block.
| esp_err_t can_twai_start | ( | uint32_t | bitrate | ) |
Start TWAI at a bit rate made exactly from the 40MHz crystal.
| bitrate | Bits per second; PANEL_CAN_BITRATE on the link. |