Skip to content

Instantly share code, notes, and snippets.

@raspberrypisig
Created April 22, 2024 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raspberrypisig/9a25da92599422408f42ef1a905afaba to your computer and use it in GitHub Desktop.
Save raspberrypisig/9a25da92599422408f42ef1a905afaba to your computer and use it in GitHub Desktop.
#include "driver/rmt.h"
static rmt_item32_t items[3] = {
{{ 5000, 1, 4000, 0 }},
{{ 5000, 1, 4000, 0 }},
{{ 5000, 1, 4000, 0 }}
};
// { 4000, 1, 4000, 0 },
/*
* Initialize the RMT Tx channel
*/
static void rmt_tx_init(void)
{
rmt_config_t config;
config.rmt_mode = RMT_MODE_TX;
config.channel = RMT_CHANNEL_0;
config.gpio_num = GPIO_NUM_21;
config.mem_block_num = 1;
config.tx_config.loop_en = false;
config.clk_div = 80;
ESP_ERROR_CHECK(rmt_config(&config));
ESP_ERROR_CHECK(rmt_driver_install(config.channel, 0, 0));
}
// void app_main(void *ignore)
void setup()
{
Serial.begin(115200);
rmt_tx_init();
delay(100);
//int i;
//for (int i = 0 ; i < 1999 ; i++) {
// items[i] = (rmt_item32_t){{{ 5000, 1, 4000, 0 }}};
//}
ESP_ERROR_CHECK(rmt_write_items(RMT_CHANNEL_0, items, 3, false));
}
void loop()
{
Serial.println(rmt_wait_tx_done(RMT_CHANNEL_0, 0));
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment