1 /* 2 * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #include <stdint.h> 10 #include <stdbool.h> 11 #include "sdkconfig.h" 12 #include "esp_err.h" 13 #include "freertos/FreeRTOS.h" 14 #include "freertos/ringbuf.h" 15 #include "driver/rmt_types_legacy.h" 16 17 #if !CONFIG_RMT_SUPPRESS_DEPRECATE_WARN 18 #warning "The legacy RMT driver is deprecated, please use driver/rmt_tx.h and/or driver/rmt_rx.h" 19 #endif 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /** 26 * @brief Set RMT clock divider, channel clock is divided from source clock. 27 * 28 * @param channel RMT channel 29 * @param div_cnt RMT counter clock divider 30 * 31 * @return 32 * - ESP_ERR_INVALID_ARG Parameter error 33 * - ESP_OK Success 34 */ 35 esp_err_t rmt_set_clk_div(rmt_channel_t channel, uint8_t div_cnt); 36 37 /** 38 * @brief Get RMT clock divider, channel clock is divided from source clock. 39 * 40 * @param channel RMT channel 41 * @param div_cnt pointer to accept RMT counter divider 42 * 43 * @return 44 * - ESP_ERR_INVALID_ARG Parameter error 45 * - ESP_OK Success 46 */ 47 esp_err_t rmt_get_clk_div(rmt_channel_t channel, uint8_t *div_cnt); 48 49 /** 50 * @brief Set RMT RX idle threshold value 51 * 52 * In receive mode, when no edge is detected on the input signal 53 * for longer than idle_thres channel clock cycles, 54 * the receive process is finished. 55 * 56 * @param channel RMT channel 57 * @param thresh RMT RX idle threshold 58 * 59 * @return 60 * - ESP_ERR_INVALID_ARG Parameter error 61 * - ESP_OK Success 62 */ 63 esp_err_t rmt_set_rx_idle_thresh(rmt_channel_t channel, uint16_t thresh); 64 65 /** 66 * @brief Get RMT idle threshold value. 67 * 68 * In receive mode, when no edge is detected on the input signal 69 * for longer than idle_thres channel clock cycles, 70 * the receive process is finished. 71 * 72 * @param channel RMT channel 73 * @param thresh pointer to accept RMT RX idle threshold value 74 * 75 * @return 76 * - ESP_ERR_INVALID_ARG Parameter error 77 * - ESP_OK Success 78 */ 79 esp_err_t rmt_get_rx_idle_thresh(rmt_channel_t channel, uint16_t *thresh); 80 81 /** 82 * @brief Set RMT memory block number for RMT channel 83 * 84 * This function is used to configure the amount of memory blocks allocated to channel n 85 * The 8 channels share a 512x32-bit RAM block which can be read and written 86 * by the processor cores over the APB bus, as well as read by the transmitters 87 * and written by the receivers. 88 * 89 * The RAM address range for channel n is start_addr_CHn to end_addr_CHn, which are defined by: 90 * Memory block start address is RMT_CHANNEL_MEM(n) (in soc/rmt_reg.h), 91 * that is, start_addr_chn = RMT base address + 0x800 + 64 ∗ 4 ∗ n, and 92 * end_addr_chn = RMT base address + 0x800 + 64 ∗ 4 ∗ n + 64 ∗ 4 ∗ RMT_MEM_SIZE_CHn mod 512 ∗ 4 93 * 94 * @note 95 * If memory block number of one channel is set to a value greater than 1, this channel will occupy the memory 96 * block of the next channel. 97 * Channel 0 can use at most 8 blocks of memory, accordingly channel 7 can only use one memory block. 98 * 99 * @param channel RMT channel 100 * @param rmt_mem_num RMT RX memory block number, one block has 64 * 32 bits. 101 * 102 * @return 103 * - ESP_ERR_INVALID_ARG Parameter error 104 * - ESP_OK Success 105 */ 106 esp_err_t rmt_set_mem_block_num(rmt_channel_t channel, uint8_t rmt_mem_num); 107 108 /** 109 * @brief Get RMT memory block number 110 * 111 * @param channel RMT channel 112 * @param rmt_mem_num Pointer to accept RMT RX memory block number 113 * 114 * @return 115 * - ESP_ERR_INVALID_ARG Parameter error 116 * - ESP_OK Success 117 */ 118 esp_err_t rmt_get_mem_block_num(rmt_channel_t channel, uint8_t *rmt_mem_num); 119 120 /** 121 * @brief Configure RMT carrier for TX signal. 122 * 123 * Set different values for carrier_high and carrier_low to set different frequency of carrier. 124 * The unit of carrier_high/low is the source clock tick, not the divided channel counter clock. 125 * 126 * @param channel RMT channel 127 * @param carrier_en Whether to enable output carrier. 128 * @param high_level High level duration of carrier 129 * @param low_level Low level duration of carrier. 130 * @param carrier_level Configure the way carrier wave is modulated for channel. 131 * - 1'b1:transmit on low output level 132 * - 1'b0:transmit on high output level 133 * 134 * @return 135 * - ESP_ERR_INVALID_ARG Parameter error 136 * - ESP_OK Success 137 */ 138 esp_err_t rmt_set_tx_carrier(rmt_channel_t channel, bool carrier_en, uint16_t high_level, uint16_t low_level, rmt_carrier_level_t carrier_level); 139 140 /** 141 * @brief Set RMT memory in low power mode. 142 * 143 * Reduce power consumed by memory. 1:memory is in low power state. 144 * 145 * @param channel RMT channel 146 * @param pd_en RMT memory low power enable. 147 * 148 * @return 149 * - ESP_ERR_INVALID_ARG Parameter error 150 * - ESP_OK Success 151 */ 152 esp_err_t rmt_set_mem_pd(rmt_channel_t channel, bool pd_en); 153 154 /** 155 * @brief Get RMT memory low power mode. 156 * 157 * @param channel RMT channel 158 * @param pd_en Pointer to accept RMT memory low power mode. 159 * 160 * @return 161 * - ESP_ERR_INVALID_ARG Parameter error 162 * - ESP_OK Success 163 */ 164 esp_err_t rmt_get_mem_pd(rmt_channel_t channel, bool *pd_en); 165 166 /** 167 * @brief Set RMT start sending data from memory. 168 * 169 * @param channel RMT channel 170 * @param tx_idx_rst Set true to reset memory index for TX. 171 * Otherwise, transmitter will continue sending from the last index in memory. 172 * 173 * @return 174 * - ESP_ERR_INVALID_ARG Parameter error 175 * - ESP_OK Success 176 */ 177 esp_err_t rmt_tx_start(rmt_channel_t channel, bool tx_idx_rst); 178 179 /** 180 * @brief Set RMT stop sending. 181 * 182 * @param channel RMT channel 183 * 184 * @return 185 * - ESP_ERR_INVALID_ARG Parameter error 186 * - ESP_OK Success 187 */ 188 esp_err_t rmt_tx_stop(rmt_channel_t channel); 189 190 /** 191 * @brief Set RMT start receiving data. 192 * 193 * @param channel RMT channel 194 * @param rx_idx_rst Set true to reset memory index for receiver. 195 * Otherwise, receiver will continue receiving data to the last index in memory. 196 * 197 * @return 198 * - ESP_ERR_INVALID_ARG Parameter error 199 * - ESP_OK Success 200 */ 201 esp_err_t rmt_rx_start(rmt_channel_t channel, bool rx_idx_rst); 202 203 /** 204 * @brief Set RMT stop receiving data. 205 * 206 * @param channel RMT channel 207 * 208 * @return 209 * - ESP_ERR_INVALID_ARG Parameter error 210 * - ESP_OK Success 211 */ 212 esp_err_t rmt_rx_stop(rmt_channel_t channel); 213 214 /** 215 * @brief Reset RMT TX memory 216 * 217 * @param channel RMT channel 218 * 219 * @return 220 * - ESP_ERR_INVALID_ARG Parameter error 221 * - ESP_OK Success 222 */ 223 esp_err_t rmt_tx_memory_reset(rmt_channel_t channel); 224 225 /** 226 * @brief Reset RMT RX memory 227 * 228 * @param channel RMT channel 229 * 230 * @return 231 * - ESP_ERR_INVALID_ARG Parameter error 232 * - ESP_OK Success 233 */ 234 esp_err_t rmt_rx_memory_reset(rmt_channel_t channel); 235 236 /** 237 * @brief Set RMT memory owner. 238 * @note Setting memory is only valid for RX channel. 239 * 240 * @param channel RMT channel 241 * @param owner To set when the transmitter or receiver can process the memory of channel. 242 * 243 * @return 244 * - ESP_ERR_INVALID_ARG Parameter error 245 * - ESP_OK Success 246 */ 247 esp_err_t rmt_set_memory_owner(rmt_channel_t channel, rmt_mem_owner_t owner); 248 249 /** 250 * @brief Get RMT memory owner. 251 * 252 * @param channel RMT channel 253 * @param owner Pointer to get memory owner. 254 * 255 * @return 256 * - ESP_ERR_INVALID_ARG Parameter error 257 * - ESP_OK Success 258 */ 259 esp_err_t rmt_get_memory_owner(rmt_channel_t channel, rmt_mem_owner_t *owner); 260 261 /** 262 * @brief Set RMT tx loop mode. 263 * 264 * @param channel RMT channel 265 * @param loop_en Enable RMT transmitter loop sending mode. 266 * If set true, transmitter will continue sending from the first data 267 * to the last data in channel over and over again in a loop. 268 * 269 * @return 270 * - ESP_ERR_INVALID_ARG Parameter error 271 * - ESP_OK Success 272 */ 273 esp_err_t rmt_set_tx_loop_mode(rmt_channel_t channel, bool loop_en); 274 275 /** 276 * @brief Get RMT tx loop mode. 277 * 278 * @param channel RMT channel 279 * @param loop_en Pointer to accept RMT transmitter loop sending mode. 280 * 281 * @return 282 * - ESP_ERR_INVALID_ARG Parameter error 283 * - ESP_OK Success 284 */ 285 esp_err_t rmt_get_tx_loop_mode(rmt_channel_t channel, bool *loop_en); 286 287 /** 288 * @brief Set RMT RX filter. 289 * 290 * In receive mode, channel will ignore input pulse when the pulse width is smaller than threshold. 291 * Counted in source clock, not divided counter clock. 292 * 293 * @param channel RMT channel 294 * @param rx_filter_en To enable RMT receiver filter. 295 * @param thresh Threshold of pulse width for receiver. 296 * 297 * @return 298 * - ESP_ERR_INVALID_ARG Parameter error 299 * - ESP_OK Success 300 */ 301 esp_err_t rmt_set_rx_filter(rmt_channel_t channel, bool rx_filter_en, uint8_t thresh); 302 303 /** 304 * @brief Set RMT source clock 305 * 306 * RMT module has two clock sources: 307 * 1. APB clock which is 80Mhz 308 * 2. REF tick clock, which would be 1Mhz (not supported in this version). 309 * 310 * @param channel RMT channel 311 * @param base_clk To choose source clock for RMT module. 312 * 313 * @return 314 * - ESP_ERR_INVALID_ARG Parameter error 315 * - ESP_OK Success 316 */ 317 esp_err_t rmt_set_source_clk(rmt_channel_t channel, rmt_source_clk_t base_clk); 318 319 /** 320 * @brief Get RMT source clock 321 * 322 * RMT module has two clock sources: 323 * 1. APB clock which is 80Mhz 324 * 2. REF tick clock, which would be 1Mhz (not supported in this version). 325 * 326 * @param channel RMT channel 327 * @param src_clk Pointer to accept source clock for RMT module. 328 * 329 * @return 330 * - ESP_ERR_INVALID_ARG Parameter error 331 * - ESP_OK Success 332 */ 333 esp_err_t rmt_get_source_clk(rmt_channel_t channel, rmt_source_clk_t *src_clk); 334 335 /** 336 * @brief Set RMT idle output level for transmitter 337 * 338 * @param channel RMT channel 339 * @param idle_out_en To enable idle level output. 340 * @param level To set the output signal's level for channel in idle state. 341 * 342 * @return 343 * - ESP_ERR_INVALID_ARG Parameter error 344 * - ESP_OK Success 345 */ 346 esp_err_t rmt_set_idle_level(rmt_channel_t channel, bool idle_out_en, rmt_idle_level_t level); 347 348 /** 349 * @brief Get RMT idle output level for transmitter 350 * 351 * @param channel RMT channel 352 * @param idle_out_en Pointer to accept value of enable idle. 353 * @param level Pointer to accept value of output signal's level in idle state for specified channel. 354 * 355 * @return 356 * - ESP_ERR_INVALID_ARG Parameter error 357 * - ESP_OK Success 358 */ 359 esp_err_t rmt_get_idle_level(rmt_channel_t channel, bool *idle_out_en, rmt_idle_level_t *level); 360 361 /** 362 * @brief Get RMT status 363 * 364 * @param channel RMT channel 365 * @param status Pointer to accept channel status. 366 * Please refer to RMT_CHnSTATUS_REG(n=0~7) in `rmt_reg.h` for more details of each field. 367 * 368 * @return 369 * - ESP_ERR_INVALID_ARG Parameter error 370 * - ESP_OK Success 371 */ 372 esp_err_t rmt_get_status(rmt_channel_t channel, uint32_t *status); 373 374 /** 375 * @brief Set RMT RX interrupt enable 376 * 377 * @param channel RMT channel 378 * @param en enable or disable RX interrupt. 379 * 380 * @return 381 * - ESP_ERR_INVALID_ARG Parameter error 382 * - ESP_OK Success 383 */ 384 esp_err_t rmt_set_rx_intr_en(rmt_channel_t channel, bool en); 385 386 /** 387 * @brief Set RMT RX error interrupt enable 388 * 389 * @param channel RMT channel 390 * @param en enable or disable RX err interrupt. 391 * 392 * @return 393 * - ESP_ERR_INVALID_ARG Parameter error 394 * - ESP_OK Success 395 */ 396 esp_err_t rmt_set_err_intr_en(rmt_channel_t channel, bool en); 397 398 /** 399 * @brief Set RMT TX interrupt enable 400 * 401 * @param channel RMT channel 402 * @param en enable or disable TX interrupt. 403 * 404 * @return 405 * - ESP_ERR_INVALID_ARG Parameter error 406 * - ESP_OK Success 407 */ 408 esp_err_t rmt_set_tx_intr_en(rmt_channel_t channel, bool en); 409 410 /** 411 * @brief Set RMT TX threshold event interrupt enable 412 * 413 * An interrupt will be triggered when the number of transmitted items reaches the threshold value 414 * 415 * @param channel RMT channel 416 * @param en enable or disable TX event interrupt. 417 * @param evt_thresh RMT event interrupt threshold value 418 * 419 * @return 420 * - ESP_ERR_INVALID_ARG Parameter error 421 * - ESP_OK Success 422 */ 423 esp_err_t rmt_set_tx_thr_intr_en(rmt_channel_t channel, bool en, uint16_t evt_thresh); 424 425 /** 426 * @brief Configure the GPIO used by RMT channel 427 * 428 * @param channel RMT channel 429 * @param mode RMT mode, either RMT_MODE_TX or RMT_MODE_RX 430 * @param gpio_num GPIO number, which is connected with certain RMT signal 431 * @param invert_signal Invert RMT signal physically by GPIO matrix 432 * 433 * @return 434 * - ESP_ERR_INVALID_ARG Configure RMT GPIO failed because of wrong parameter 435 * - ESP_OK Configure RMT GPIO successfully 436 */ 437 esp_err_t rmt_set_gpio(rmt_channel_t channel, rmt_mode_t mode, gpio_num_t gpio_num, bool invert_signal); 438 439 /** 440 * @brief Configure RMT parameters 441 * 442 * @param rmt_param RMT parameter struct 443 * 444 * @return 445 * - ESP_ERR_INVALID_ARG Parameter error 446 * - ESP_OK Success 447 */ 448 esp_err_t rmt_config(const rmt_config_t *rmt_param); 449 450 /** 451 * @brief Register RMT interrupt handler, the handler is an ISR. 452 * 453 * The handler will be attached to the same CPU core that this function is running on. 454 * 455 * @note If you already called rmt_driver_install to use system RMT driver, 456 * please do not register ISR handler again. 457 * 458 * @param fn Interrupt handler function. 459 * @param arg Parameter for the handler function 460 * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred) 461 * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info. 462 * @param handle If non-zero, a handle to later clean up the ISR gets stored here. 463 * 464 * @return 465 * - ESP_OK Success 466 * - ESP_ERR_INVALID_ARG Function pointer error. 467 * - ESP_FAIL System driver installed, can not register ISR handler for RMT 468 */ 469 esp_err_t rmt_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags, rmt_isr_handle_t *handle); 470 471 /** 472 * @brief Deregister previously registered RMT interrupt handler 473 * 474 * @param handle Handle obtained from rmt_isr_register 475 * 476 * @return 477 * - ESP_OK Success 478 * - ESP_ERR_INVALID_ARG Handle invalid 479 */ 480 esp_err_t rmt_isr_deregister(rmt_isr_handle_t handle); 481 482 /** 483 * @brief Fill memory data of channel with given RMT items. 484 * 485 * @param channel RMT channel 486 * @param item Pointer of items. 487 * @param item_num RMT sending items number. 488 * @param mem_offset Index offset of memory. 489 * 490 * @return 491 * - ESP_ERR_INVALID_ARG Parameter error 492 * - ESP_OK Success 493 */ 494 esp_err_t rmt_fill_tx_items(rmt_channel_t channel, const rmt_item32_t *item, uint16_t item_num, uint16_t mem_offset); 495 496 /** 497 * @brief Initialize RMT driver 498 * 499 * @param channel RMT channel 500 * @param rx_buf_size Size of RMT RX ringbuffer. Can be 0 if the RX ringbuffer is not used. 501 * @param intr_alloc_flags Flags for the RMT driver interrupt handler. Pass 0 for default flags. See esp_intr_alloc.h for details. 502 * If ESP_INTR_FLAG_IRAM is used, please do not use the memory allocated from psram when calling rmt_write_items. 503 * 504 * @return 505 * - ESP_ERR_INVALID_STATE Driver is already installed, call rmt_driver_uninstall first. 506 * - ESP_ERR_NO_MEM Memory allocation failure 507 * - ESP_ERR_INVALID_ARG Parameter error 508 * - ESP_OK Success 509 */ 510 esp_err_t rmt_driver_install(rmt_channel_t channel, size_t rx_buf_size, int intr_alloc_flags); 511 512 /** 513 * @brief Uninstall RMT driver. 514 * 515 * @param channel RMT channel 516 * 517 * @return 518 * - ESP_ERR_INVALID_ARG Parameter error 519 * - ESP_OK Success 520 */ 521 esp_err_t rmt_driver_uninstall(rmt_channel_t channel); 522 523 /** 524 * @brief Get the current status of eight channels. 525 * 526 * @note Do not call this function if it is possible that `rmt_driver_uninstall` will be called at the same time. 527 * 528 * @param[out] channel_status store the current status of each channel 529 * 530 * @return 531 * - ESP_ERR_INVALID_ARG Parameter is NULL 532 * - ESP_OK Success 533 */ 534 esp_err_t rmt_get_channel_status(rmt_channel_status_result_t *channel_status); 535 536 /** 537 * @brief Get speed of channel's internal counter clock. 538 * 539 * @param channel RMT channel 540 * @param[out] clock_hz counter clock speed, in hz 541 * 542 * @return 543 * - ESP_ERR_INVALID_ARG Parameter is NULL 544 * - ESP_OK Success 545 */ 546 esp_err_t rmt_get_counter_clock(rmt_channel_t channel, uint32_t *clock_hz); 547 548 /** 549 * @brief RMT send waveform from rmt_item array. 550 * 551 * This API allows user to send waveform with any length. 552 * 553 * @param channel RMT channel 554 * @param rmt_item head point of RMT items array. 555 * If ESP_INTR_FLAG_IRAM is used, please do not use the memory allocated from psram when calling rmt_write_items. 556 * @param item_num RMT data item number. 557 * @param wait_tx_done 558 * - If set 1, it will block the task and wait for sending done. 559 * - If set 0, it will not wait and return immediately. 560 * 561 * @note 562 * This function will not copy data, instead, it will point to the original items, 563 * and send the waveform items. 564 * If wait_tx_done is set to true, this function will block and will not return until 565 * all items have been sent out. 566 * If wait_tx_done is set to false, this function will return immediately, and the driver 567 * interrupt will continue sending the items. We must make sure the item data will not be 568 * damaged when the driver is still sending items in driver interrupt. 569 * 570 * @return 571 * - ESP_ERR_INVALID_ARG Parameter error 572 * - ESP_OK Success 573 */ 574 esp_err_t rmt_write_items(rmt_channel_t channel, const rmt_item32_t *rmt_item, int item_num, bool wait_tx_done); 575 576 /** 577 * @brief Wait RMT TX finished. 578 * 579 * @param channel RMT channel 580 * @param wait_time Maximum time in ticks to wait for transmission to be complete. If set 0, return immediately with ESP_ERR_TIMEOUT if TX is busy (polling). 581 * 582 * @return 583 * - ESP_OK RMT Tx done successfully 584 * - ESP_ERR_TIMEOUT Exceeded the 'wait_time' given 585 * - ESP_ERR_INVALID_ARG Parameter error 586 * - ESP_FAIL Driver not installed 587 */ 588 esp_err_t rmt_wait_tx_done(rmt_channel_t channel, TickType_t wait_time); 589 590 /** 591 * @brief Get ringbuffer from RMT. 592 * 593 * Users can get the RMT RX ringbuffer handle, and process the RX data. 594 * 595 * @param channel RMT channel 596 * @param buf_handle Pointer to buffer handle to accept RX ringbuffer handle. 597 * 598 * @return 599 * - ESP_ERR_INVALID_ARG Parameter error 600 * - ESP_OK Success 601 */ 602 esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t *buf_handle); 603 604 /** 605 * @brief Init rmt translator and register user callback. 606 * The callback will convert the raw data that needs to be sent to rmt format. 607 * If a channel is initialized more than once, the user callback will be replaced by the later. 608 * 609 * @param channel RMT channel . 610 * @param fn Point to the data conversion function. 611 * 612 * @return 613 * - ESP_FAIL Init fail. 614 * - ESP_OK Init success. 615 */ 616 esp_err_t rmt_translator_init(rmt_channel_t channel, sample_to_rmt_t fn); 617 618 /** 619 * @brief Set user context for the translator of specific channel 620 * 621 * @param channel RMT channel number 622 * @param context User context 623 * 624 * @return 625 * - ESP_FAIL Set context fail 626 * - ESP_OK Set context success 627 */ 628 esp_err_t rmt_translator_set_context(rmt_channel_t channel, void *context); 629 630 /** 631 * @brief Get the user context set by 'rmt_translator_set_context' 632 * 633 * @note This API must be invoked in the RMT translator callback function, 634 * and the first argument must be the actual parameter 'item_num' you got in that callback function. 635 * 636 * @param item_num Address of the memory which contains the number of translated items (It's from driver's internal memory) 637 * @param context Returned User context 638 * 639 * @return 640 * - ESP_FAIL Get context fail 641 * - ESP_OK Get context success 642 */ 643 esp_err_t rmt_translator_get_context(const size_t *item_num, void **context); 644 645 /** 646 * @brief Translate uint8_t type of data into rmt format and send it out. 647 * Requires rmt_translator_init to init the translator first. 648 * 649 * @param channel RMT channel . 650 * @param src Pointer to the raw data. 651 * @param src_size The size of the raw data. 652 * @param wait_tx_done Set true to wait all data send done. 653 * 654 * @return 655 * - ESP_FAIL Send fail 656 * - ESP_OK Send success 657 */ 658 esp_err_t rmt_write_sample(rmt_channel_t channel, const uint8_t *src, size_t src_size, bool wait_tx_done); 659 660 /** 661 * @brief Registers a callback that will be called when transmission ends. 662 * 663 * Called by rmt_driver_isr_default in interrupt context. 664 * 665 * @note Requires rmt_driver_install to install the default ISR handler. 666 * 667 * @param function Function to be called from the default interrupt handler or NULL. 668 * @param arg Argument which will be provided to the callback when it is called. 669 * 670 * @return the previous callback settings (members will be set to NULL if there was none) 671 */ 672 rmt_tx_end_callback_t rmt_register_tx_end_callback(rmt_tx_end_fn_t function, void *arg); 673 674 #if SOC_RMT_SUPPORT_RX_PINGPONG 675 /** 676 * @brief Set RMT RX threshold event interrupt enable 677 * 678 * An interrupt will be triggered when the number of received items reaches the threshold value 679 * 680 * @param channel RMT channel 681 * @param en enable or disable RX event interrupt. 682 * @param evt_thresh RMT event interrupt threshold value 683 * 684 * @return 685 * - ESP_ERR_INVALID_ARG Parameter error 686 * - ESP_OK Success 687 */ 688 esp_err_t rmt_set_rx_thr_intr_en(rmt_channel_t channel, bool en, uint16_t evt_thresh); 689 #endif 690 691 #if SOC_RMT_SUPPORT_TX_SYNCHRO 692 /** 693 * @brief Add channel into a synchronous group (channels in the same group can start transaction simultaneously) 694 * 695 * @param channel RMT channel 696 * 697 * @return 698 * - ESP_ERR_INVALID_ARG Parameter error 699 * - ESP_OK Success 700 */ 701 esp_err_t rmt_add_channel_to_group(rmt_channel_t channel); 702 703 /** 704 * @brief Remove channel out of a group 705 * 706 * @param channel RMT channel 707 * 708 * @return 709 * - ESP_ERR_INVALID_ARG Parameter error 710 * - ESP_OK Success 711 */ 712 esp_err_t rmt_remove_channel_from_group(rmt_channel_t channel); 713 #endif 714 715 #if SOC_RMT_SUPPORT_TX_LOOP_COUNT 716 /** 717 * @brief Set loop count threshold value for RMT TX channel 718 * 719 * When tx loop count reaches this value, an ISR callback will notify user 720 * 721 * @param channel RMT channel 722 * @param count loop count, 1 ~ 1023 723 * @return 724 * - ESP_ERR_INVALID_ARG Parameter error 725 * - ESP_OK Success 726 */ 727 esp_err_t rmt_set_tx_loop_count(rmt_channel_t channel, uint32_t count); 728 729 /** 730 * @brief Enable or disable the feature that when loop count reaches the threshold, RMT will stop transmitting. 731 * 732 * - When the loop auto-stop feature is enabled will halt RMT transmission after the loop count reaches a certain threshold 733 * - When disabled, the RMT transmission continue indefinitely until halted by the users 734 * 735 * @note The auto-stop feature is implemented in hardware on particular targets (i.e. those with SOC_RMT_SUPPORT_TX_LOOP_AUTO_STOP defined). 736 * Otherwise, the auto-stop feature is implemented in software via the interrupt. 737 * 738 * @param channel RMT channel 739 * @param en enable bit 740 * @return 741 * - ESP_ERR_INVALID_ARG Parameter error 742 * - ESP_OK Success 743 */ 744 esp_err_t rmt_enable_tx_loop_autostop(rmt_channel_t channel, bool en); 745 #endif // SOC_RMT_SUPPORT_TX_LOOP_COUNT 746 747 #ifdef __cplusplus 748 } 749 #endif 750