EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #465 background imageLoading...
Page #465 background image
Chapter 2. API Reference
Functions
esp_err_t twai_driver_install(const twai_general_config_t *g_config, const
twai_timing_config_t *t_config, const twai_filter_config_t
*f_config)
Install TWAI driver.
This function installs the TWAI driver using three configuration structures. The required memory is allocated
and the TWAI driver is placed in the stopped state after running this function.
Note Macro initializers are available for the configuration structures (see documentation)
Note To reinstall the TWAI driver, call twai_driver_uninstall() first
Return
ESP_OK: Successfully installed TWAI driver
ESP_ERR_INVALID_ARG: Arguments are invalid
ESP_ERR_NO_MEM: Insufficient memory
ESP_ERR_INVALID_STATE: Driver is already installed
Parameters
[in] g_config: General configuration structure
[in] t_config: Timing configuration structure
[in] f_config: Filter configuration structure
esp_err_t twai_driver_uninstall(void)
Uninstall the TWAI driver.
This function uninstalls the TWAI driver, freeing the memory utilized by the driver. This function can only be
called when the driver is in the stopped state or the bus-off state.
Warning The application must ensure that no tasks are blocked on TX/RX queues or alerts when this function
is called.
Return
ESP_OK: Successfully uninstalled TWAI driver
ESP_ERR_INVALID_STATE: Driver is not in stopped/bus-off state, or is not installed
esp_err_t twai_start(void)
Start the TWAI driver.
This function starts the TWAI driver, putting the TWAI driver into the running state. This allows the TWAI
driver to participate in TWAI bus activities such as transmitting/receiving messages. The TX and RX queue
are reset in this function, clearing any messages that are unread or pending transmission. This function can
only be called when the TWAI driver is in the stopped state.
Return
ESP_OK: TWAI driver is now running
ESP_ERR_INVALID_STATE: Driver is not in stopped state, or is not installed
esp_err_t twai_stop(void)
Stop the TWAI driver.
This function stops the TWAI driver, preventing any further message from being transmitted or received until
twai_start() is called. Any messages in the TX queue are cleared. Any messages in the RX queue should be
read by the application after this function is called. This function can only be called when the TWAI driver is
in the running state.
Warning A message currently being transmitted/received on the TWAI bus will be ceased immediately. This
may lead to other TWAI nodes interpreting the unfinished message as an error.
Return
ESP_OK: TWAI driver is now Stopped
ESP_ERR_INVALID_STATE: Driver is not in running state, or is not installed
esp_err_t twai_transmit(const twai_message_t *message, TickType_t ticks_to_wait)
Transmit a TWAI message.
This function queues a TWAI message for transmission. Transmission will start immediately if no other mes-
sages are queued for transmission. If the TX queue is full, this function will block until more space becomes
available or until it times out. If the TX queue is disabled (TX queue length = 0 in configuration), this function
Espressif Systems 454
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish