This commit is contained in:
Alexey Zholtikov 2024-05-21 11:52:50 +03:00
commit 6d9c85cdf9
9 changed files with 2072 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
build
sdkconfig
sdkconfig.old

51
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,51 @@
{
"configurations": [
{
"name": "MAC_ESP32",
"compilerPath": "${config:idf.toolsPath}/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"includePath": [
"${workspaceFolder}/**",
"/Users/alexey.zholtikov/esp/v5.2/esp-idf/components/**"
]
},
{
"name": "MAC_ESP8266",
"compilerPath": "/Users/alexey.zholtikov/.espressif/tools/xtensa-lx106-elf/esp-2020r3-49-gd5524c1-8.4.0/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc-8.4.0",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/build/include/*",
"/Users/alexey.zholtikov/esp/ESP8266_RTOS_SDK/components/**",
"/Users/alexey.zholtikov/esp/ESP8266_RTOS_SDK/components/freertos/port/esp8266/include"
],
"defines": [
"__ESP_FILE__"
],
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
},
{
"name": "LINUX_ESP32",
"compilerPath": "/home/alexey-zholtikov/.espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"includePath": [
"${workspaceFolder}/**",
"/home/alexey-zholtikov/esp/esp-idf/components/**"
]
},
{
"name": "LINUX_ESP8266",
"compilerPath": "/home/alexey-zholtikov/.espressif/tools/xtensa-lx106-elf/esp-2020r3-49-gd5524c1-8.4.0/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc-8.4.0",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/build/include/*",
"/home/alexey-zholtikov/esp/ESP8266_RTOS_SDK/components/**",
"/home/alexey-zholtikov/esp/ESP8266_RTOS_SDK/components/freertos/port/esp8266/include"
],
"defines": [
"__ESP_FILE__"
],
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}

53
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,53 @@
{
"cmake.configureOnOpen": false,
"files.associations": {
"freertos.h": "c",
"task.h": "c",
"esp_system.h": "c",
"portable.h": "c",
"portmacro.h": "c",
"xtensa_rtos.h": "c",
"xtensa_timer.h": "c",
"sdkconfig.h": "c",
"esp_err.h": "c",
"esp_ota_ops.h": "c",
"zh_nvs.h": "c",
"zh_gpio.h": "c",
"zh_espnow.h": "c",
"zh_json.h": "c",
"esp_app_format.h": "c",
"esp_now.h": "c",
"esp_timer.h": "c",
"esp_wifi.h": "c",
"string.h": "c",
"event_groups.h": "c",
"gpio.h": "c",
"nvs.h": "c",
"*.inc": "c",
"nvs_flash.h": "c",
"esp_netif.h": "c",
"queue.h": "c",
"stdint.h": "c",
"stdio.h": "c",
"stdbool.h": "c",
"zh_onewire.h": "c",
"zh_config.h": "c",
"tcpip_adapter.h": "c",
"dhcpserver.h": "c",
"ip_addr.h": "c",
"array": "c",
"string": "c",
"string_view": "c",
"stdlib.h": "c",
"esp_heap_caps.h": "c",
"zh_vector.h": "c",
"rmt.h": "c",
"rmt_rx.h": "c"
},
"idf.adapterTargetName": "esp32",
"idf.port": "/dev/cu.usbserial-0001",
"idf.flashType": "UART",
"idf.openOcdConfigs": [
"board/esp32-wrover-kit-3.3v.cfg"
]
}

3
CMakeLists.txt Normal file
View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(template)

2
Makefile Normal file
View File

@ -0,0 +1,2 @@
PROJECT_NAME := template
include $(IDF_PATH)/make/project.mk

1
main/CMakeLists.txt Normal file
View File

@ -0,0 +1 @@
idf_component_register(SRCS "main.c" INCLUDE_DIRS "")

0
main/component.mk Normal file
View File

67
main/main.c Normal file
View File

@ -0,0 +1,67 @@
#include "stdio.h"
#include "driver/rmt_rx.h"
#include "driver/gpio.h"
// #include "freertos/queue.h"
// #include "freertos/task.h"
#include "freertos/FreeRTOS.h"
// static bool example_rmt_rx_done_callback(rmt_channel_handle_t channel, const rmt_rx_done_event_data_t *edata, void *user_data)
// {
// // BaseType_t high_task_wakeup = pdFALSE;
// // QueueHandle_t receive_queue = (QueueHandle_t)user_data;
// // // send the received RMT symbols to the parser task
// // xQueueSendFromISR(receive_queue, edata, &high_task_wakeup);
// // // return whether any task is woken up
// // return high_task_wakeup == pdTRUE;
// }
void app_main(void)
{
gpio_config_t config;
config.intr_type = GPIO_INTR_DISABLE;
config.mode = GPIO_MODE_INPUT;
config.pin_bit_mask = (1ULL << 5);
config.pull_down_en = GPIO_PULLDOWN_DISABLE;
config.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config(&config);
gpio_set_direction(5, GPIO_MODE_OUTPUT);
gpio_set_level(5, 0);
vTaskDelay(10 / portTICK_PERIOD_MS);
// gpio_set_level(5, 1);
gpio_set_direction(5, GPIO_MODE_INPUT);
rmt_channel_handle_t rx_channel = NULL;
rmt_rx_channel_config_t rx_chan_config = {
.gpio_num = 5, // GPIO number
.clk_src = RMT_CLK_SRC_DEFAULT, // select source clock
.resolution_hz = 1 * 1000 * 1000, // 1MHz tick resolution, i.e. 1 tick = 1us
.mem_block_symbols = 64, // memory block size, 64 * 4 = 256Bytes
.flags.invert_in = false, // don't invert input signal
.flags.with_dma = false, // don't need DMA backend
// .flags.io_loop_back=false,
// .intr_priority=0,
};
ESP_ERROR_CHECK(rmt_new_rx_channel(&rx_chan_config, &rx_channel));
// QueueHandle_t receive_queue = xQueueCreate(1, sizeof(rmt_rx_done_event_data_t));
// rmt_rx_event_callbacks_t cbs = {
// .on_recv_done = example_rmt_rx_done_callback,
// };
// ESP_ERROR_CHECK(rmt_rx_register_event_callbacks(rx_channel, &cbs, NULL));
// the following timing requirement is based on NEC protocol
rmt_receive_config_t receive_config = {
.signal_range_min_ns = 20000, // the shortest duration for NEC signal is 560us, 1250ns < 560us, valid signal won't be treated as noise
.signal_range_max_ns = 90000, // the longest duration for NEC signal is 9000us, 12000000ns > 9000us, the receive won't stop early
};
rmt_symbol_word_t raw_symbols[64]; // 64 symbols should be sufficient for a standard NEC frame
// ready to receive
ESP_ERROR_CHECK(rmt_receive(rx_channel, raw_symbols, sizeof(raw_symbols), &receive_config));
// wait for RX done signal
// rmt_rx_done_event_data_t rx_data;
for (uint8_t i = 0; i < 64; ++i)
{
printf("%d, %d, %d, %d\n", raw_symbols[i].duration0, raw_symbols[i].level0, raw_symbols[i].duration1, raw_symbols[i].level1);
}
}

1892
sdkconfig Normal file

File diff suppressed because it is too large Load Diff