|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The panel's TWAI controller on the link: start, stop, send and receive. More...
#include "can_twai.h"#include <string.h>#include "driver/twai.h"#include "esp_idf_version.h"#include "esp_log.h"#include "board_pins.h"#include "can_timing.h"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) |
| bool | can_twai_errors (uint32_t *tx_err, uint32_t *rx_err, uint32_t *bus_err, bool *bus_off) |
| can_twai_health_t | can_twai_health (void) |
| can_twai_health_t | can_twai_recover (void) |
| Look at the controller and put it back on the bus if it has fallen off. | |
Variables | |
| static const char * | TAG = "can" |
| static bool | s_running |
The panel's TWAI controller on the link: start, stop, send and receive.
SPDX-License-Identifier: MIT
| 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. |