Voir ESP32 rmt_tx : exemple d’impulsion simple (ESP-IDF) pour un exemple sans sync manager
esp32_rmt_tx.cpp
#include <driver/rmt_tx.h>rmt_tx_sync_manager_config.cpp
rmt_channel_handle_t channel;
rmt_tx_channel_config_t tx_chan_config = {
.gpio_num = GPIO_NUM_19, // Numéro GPIO
.clk_src = RMT_CLK_SRC_DEFAULT, // sélectionne l'horloge source
.resolution_hz = 1 * 1000 * 1000, // Résolution 1 MHz
.mem_block_symbols = 64, // taille de bloc mémoire, 64 * 4 = 256 Octets
.trans_queue_depth = 1, // définit le nombre de transactions en attente en arrière-plan
};
ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &channel));
ESP_ERROR_CHECK(rmt_enable(channel));
rmt_symbol_word_t txdata[64];
txdata[0] = {
.duration0 = 100,
.level0 = 1,
.duration1 = 0,
.level1 = 0,
};
// installe le sync manager
rmt_channel_handle_t tx_channels[] = {channel};
rmt_sync_manager_handle_t synchro = NULL;
rmt_sync_manager_config_t synchro_config = {
.tx_channel_array = tx_channels,
.array_size = sizeof(tx_channels) / sizeof(rmt_channel_handle_t),
};
ESP_ERROR_CHECK(rmt_new_sync_manager(&synchro_config, &synchro));
// Crée un encodeur simple
rmt_copy_encoder_config_t encoder_config;
rmt_encoder_handle_t encoder;
ESP_ERROR_CHECK(rmt_new_copy_encoder(&encoder_config, &encoder));
rmt_transmit_config_t tx_config = {
.loop_count = 0, // pas de boucle de transfert
};
while(true)
{
ESP_ERROR_CHECK(rmt_transmit(channel, encoder, pulseRMT, 1*sizeof(rmt_symbol_word_t), &tx_config));
// Attend une seconde
vTaskDelay(10 / portTICK_PERIOD_MS);
}
Consultez les articles similaires par catégorie :
Allgemein ESP8266/ESP32
Si cet article vous a aidé, pensez à m'offrir un café ou à faire un don via PayPal pour soutenir la recherche et la publication de nouveaux articles sur TechOverflow