Code: Select all
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/rmt.h"
#include "driver/periph_ctrl.h"
#include "soc/rmt_reg.h"
void app_main()
{
rmt_config_t rmt_rx =
{
.channel = 0,
.gpio_num = 17,
.clk_div = 80, //1MHz
.mem_block_num = 1,
.rmt_mode = RMT_MODE_RX,
.rx_config.filter_en = true,
.rx_config.filter_ticks_thresh = 100,
.rx_config.idle_threshold = 9500
};
rmt_config(&rmt_rx);
rmt_driver_install(rmt_rx.channel, 1000, 0);
RingbufHandle_t rb = NULL;
rmt_get_ringbuf_handle(rmt_rx.channel, &rb);
rmt_rx_start(rmt_rx.channel, 1);
while(rb)
{
size_t rx_size = 0;
rmt_item32_t* item = (rmt_item32_t*) xRingbufferReceive(rb, &rx_size, 1000);
if(item)
{
for (int i = 0; i < rx_size>>2; i++)
{
printf("%d:%dus %d:%dus\n", (item+i)->level0, (item+i)->duration0, (item+i)->level1, (item+i)->duration1);
}
vRingbufferReturnItem(rb, (void*) item);
}
else
{
break;
}
}
}
Code: Select all
0:3906us 1:0us
0:3906us 1:0us
0:3907us 1:0us
0:3906us 1:0us
0:3906us 1:0us
0:3906us 1:0us
0:3906us 1:0us
0:3906us 1:0us
0:3906us 1:0us
0:3906us 1:0us
0:3907us 1:0us
Code: Select all
E (2016) rmt: RMT[0] ERR
E (2016) rmt: status: 0x13000040
Code: Select all
E (1014) rmt: RMT[0] ERR
E (1014) rmt: status: 0x13000040