diff -r 995557380e5f -r acc1904cd70d components/esp32-owb/include/owb_rmt.h --- a/components/esp32-owb/include/owb_rmt.h Tue Sep 26 14:56:04 2023 +0200 +++ b/components/esp32-owb/include/owb_rmt.h Tue Sep 26 14:57:18 2023 +0200 @@ -23,34 +23,79 @@ * SOFTWARE. */ +/** + * @file + * @brief Interface definitions for ESP32 RMT driver used to communicate with devices + * on the One Wire Bus. + * + * This is the recommended driver. + */ + #pragma once #ifndef OWB_RMT_H #define OWB_RMT_H #include "freertos/FreeRTOS.h" #include "freertos/queue.h" -#include "freertos/ringbuf.h" -#include "driver/rmt.h" + +#include "driver/rmt_tx.h" +#include "driver/rmt_rx.h" + +#include "owb.h" // for tyoe OneWireBus #ifdef __cplusplus extern "C" { #endif +/** + * @brief RMT driver information + */ typedef struct { - int tx_channel; ///< RMT channel to use for TX - int rx_channel; ///< RMT channel to use for RX - RingbufHandle_t rb; ///< Ring buffer handle - int gpio; ///< OneWireBus GPIO - OneWireBus bus; ///< OneWireBus instance + rmt_channel_handle_t tx_channel_handle; ///< RMT transmit channel, allocated by RMT driver + rmt_channel_handle_t rx_channel_handle; ///< RMT receive channel, allocated by RMT driver + rmt_encoder_handle_t copy_encoder_handle; ///< RMT built-in data encoder that sends pre-defined symbols + rmt_encoder_handle_t bytes_encoder_handle; ///< RMT built-in data encoder that converts bits into symbols + rmt_symbol_word_t *rx_buffer; ///< RMT receive channel symbol buffer + size_t rx_buffer_size_in_bytes; ///< Size of the RMT received buffer, in bytes + QueueHandle_t rx_queue; ///< xQueue to receive RMT symbols from the `on_recv_done` callback + int gpio; ///< OneWireBus GPIO + OneWireBus bus; ///< OneWireBus instance (see owb.h) } owb_rmt_driver_info; /** * @brief Initialise the RMT driver. - * @return OneWireBus*, pass this into the other OneWireBus public API functions + * @param[in] info Pointer to an uninitialized owb_rmt_driver_info structure. + * Note: the structure must remain in scope for the lifetime of this component. + * @param[in] gpio_num The GPIO number to use as the One Wire bus data line. + * @param tx_channel NOW IGNORED: the new RMT driver allocates channels dynamically. + * @param rx_channel NOW IGNORED: the new RMT driver allocates channels dynamically. + * @return OneWireBus *, pass this into the other OneWireBus public API functions */ -OneWireBus* owb_rmt_initialize(owb_rmt_driver_info *info, uint8_t gpio_num, - rmt_channel_t tx_channel, rmt_channel_t rx_channel); +OneWireBus* owb_rmt_initialize(owb_rmt_driver_info * info, gpio_num_t gpio_num, + /*rmt_channel_t*/ int tx_channel, /* rmt_channel_t*/ int rx_channel); + + +/** + * @brief Legacy RMT channel IDs. + * + * These are no longer used for anything. They are defined here purely so + * that code written for the old rmt driver can still compile. + */ +typedef enum { + RMT_CHANNEL_0, /*!< RMT channel number 0 */ + RMT_CHANNEL_1, /*!< RMT channel number 1 */ + RMT_CHANNEL_2, /*!< RMT channel number 2 */ + RMT_CHANNEL_3, /*!< RMT channel number 3 */ +#if SOC_RMT_CHANNELS_PER_GROUP > 4 + RMT_CHANNEL_4, /*!< RMT channel number 4 */ + RMT_CHANNEL_5, /*!< RMT channel number 5 */ + RMT_CHANNEL_6, /*!< RMT channel number 6 */ + RMT_CHANNEL_7, /*!< RMT channel number 7 */ +#endif + RMT_CHANNEL_MAX /*!< Number of RMT channels */ +} rmt_channel_t; + #ifdef __cplusplus }