|
Open Model Railroad Network (OpenMRN)
|
ESP32 Hardware TWAI (CAN) driver interface. More...
#include <Esp32HardwareTwai.hxx>
Public Member Functions | |
| Esp32HardwareTwai (int rx, int tx, bool report=true, size_t rx_buffer_size=config_can_rx_buffer_size(), size_t tx_buffer_size=config_can_tx_buffer_size(), const char *path="/dev/twai", int clock_out=GPIO_NUM_NC, int bus_status=GPIO_NUM_NC, uint32_t isr_preferred_core=DEFAULT_ISR_CORE) | |
| ~Esp32HardwareTwai () | |
| Destructor. | |
| void | hw_init () |
| Initializes the TWAI hardware and VFS adapter. | |
| void | get_driver_stats (esp32_twai_stats_t *stats) |
| Retrieves the current driver statistics. | |
Private Member Functions | |
| Esp32HardwareTwai () | |
| Default constructor. | |
| DISALLOW_COPY_AND_ASSIGN (Esp32HardwareTwai) | |
Private Attributes | |
| const int | rxPin_ |
| GPIO pin connected to the external transceiver RX pin. | |
| const int | txPin_ |
| GPIO pin connected to the external transceiver TX pin. | |
| const int | extClockPin_ |
| GPIO pin that generates an external clock signal. | |
| const int | busStatusPin_ |
| GPIO pin connected to an external bus status indicator. | |
| const uint32_t | preferredIsrCore_ |
| Core which the TWAI ISR should be bound to. | |
| const char * | vfsPath_ |
| VFS Mount point. | |
Static Private Attributes | |
| static constexpr uint32_t | DEFAULT_ISR_CORE = PRO_CPU_NUM |
| Default core for running the TWAI ISR. | |
Additional Inherited Members | |
Static Public Member Functions inherited from Singleton< Esp32HardwareTwai > | |
| static Esp32HardwareTwai * | instance () |
| static bool | exists () |
ESP32 Hardware TWAI (CAN) driver interface.
The ESP32 has a hardware TWAI controller that requires an external CAN transceiver connected via two GPIO pins (RX and TX). SPI connected CAN transceivers are not supported by this interface.
Example of usage (async API):
Example of usage (select API):
NOTE: For the select API it is necessary to start the executor thread in the setup() method.
NOTE: The select API is not be usable without CONFIG_VFS_SUPPORT_SELECT being enabled in sdkconfig, this option is disabled automatically when CONFIG_LWIP_USE_ONLY_LWIP_SELECT is enabled. CONFIG_VFS_SUPPORT_SELECT is enabled by default in arduino-esp32.
Definition at line 128 of file Esp32HardwareTwai.hxx.
| void openmrn_arduino::Esp32HardwareTwai::get_driver_stats | ( | esp32_twai_stats_t * | stats | ) |
Retrieves the current driver statistics.
| stats | esp32_twai_stats_t buffer to be filled with the current statistics. |
| void openmrn_arduino::Esp32HardwareTwai::hw_init | ( | ) |
Initializes the TWAI hardware and VFS adapter.
NOTE: This must be called prior to adding the TWAI driver to the SimpleCanStack.
|
private |
GPIO pin connected to an external bus status indicator.
Definition at line 195 of file Esp32HardwareTwai.hxx.
|
staticconstexprprivate |
Default core for running the TWAI ISR.
Definition at line 205 of file Esp32HardwareTwai.hxx.
|
private |
GPIO pin that generates an external clock signal.
Definition at line 192 of file Esp32HardwareTwai.hxx.
|
private |
Core which the TWAI ISR should be bound to.
Definition at line 198 of file Esp32HardwareTwai.hxx.
|
private |
GPIO pin connected to the external transceiver RX pin.
Definition at line 186 of file Esp32HardwareTwai.hxx.
|
private |
GPIO pin connected to the external transceiver TX pin.
Definition at line 189 of file Esp32HardwareTwai.hxx.
|
private |
VFS Mount point.
Definition at line 209 of file Esp32HardwareTwai.hxx.