EasyManua.ls Logo

Espressif ESP32-S2 - Page 352

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
Loading...
Chapter 2. API Reference
Finalize Configuration Once the rmt_config_t structure is populated with parameters, it should be then
invoked with rmt_config() to make the configuration effective.
The last configuration step is installation of the driver in memory by calling rmt_driver_install(). If
rx_buf_size parameter of this function is > 0, then a ring buffer for incoming data will be allocated. A de-
fault ISR handler will be installed, see a note in Use Interrupts.
Now, depending on how the channel is configured, we are ready to either Transmit Data or Receive Data. This is
described in next two sections.
Transmit Data
Before being able to transmit some RMT pulses, we need to define the pulse pattern. The minimum pattern recognized
by the RMT controller, later called an item, is provided in a structure rmt_item32_t. Each item consists of
two pairs of two values. The first value in a pair describes the signal duration in ticks and is 15 bits long, the second
provides the signal level (high or low) and is contained in a single bit. A block of couple of items and the structure
of an item is presented below.
Fig. 10: Structure of RMT items (L - signal level)
For a simple example how to define a block of items see peripherals/rmt/morse_code.
The items are provided to the RMT controller by calling function rmt_write_items(). This function also
automatically triggers start of transmission. It may be called to wait for transmission completion or exit just after
transmission start. In such case you can wait for the transmission end by calling rmt_wait_tx_done(). This
function does not limit the number of data items to transmit. It is using an interrupt to successively copy the new data
chunks to RMTs internal memory as previously provided data are sent out.
Another way to provide data for transmission is by calling rmt_fill_tx_items(). In this case transmission
is not started automatically. To control the transmission process use rmt_tx_start() and rmt_tx_stop().
The number of items to sent is restricted by the size of memory blocks allocated in the RMT controllers internal
memory, see rmt_set_mem_block_num().
Receive Data
Before starting the receiver we need some storage for incoming items. The RMT controller has 256 x 32-bits of
internal RAM shared between all four channels.
In typical scenarios it is not enough as an ultimate storage for all incoming (and outgoing) items. Therefore this
API supports retrieval of incoming items on the fly to save them in a ring buffer of a size defined by the user. The
Espressif Systems 341
Submit Document Feedback
Release v4.4

Table of Contents