From 6156dc3466f94a912cb4041907b5fb69381975b2 Mon Sep 17 00:00:00 2001 From: maddiebaka Date: Tue, 25 Nov 2025 17:31:28 -0500 Subject: [PATCH] Add GPIO input configuration --- main/CMakeLists.txt | 2 +- main/spincoat-plater-firmware.c | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index c716685..59c70d2 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRCS "spincoat-plater-firmware.c" "dshot_esc_encoder.c" - PRIV_REQUIRES esp_driver_rmt + PRIV_REQUIRES esp_driver_rmt esp_driver_gpio INCLUDE_DIRS ".") diff --git a/main/spincoat-plater-firmware.c b/main/spincoat-plater-firmware.c index 8c71e90..45e665c 100644 --- a/main/spincoat-plater-firmware.c +++ b/main/spincoat-plater-firmware.c @@ -8,6 +8,7 @@ #include "freertos/task.h" #include "esp_log.h" #include "driver/rmt_tx.h" +#include "driver/gpio.h" #include "dshot_esc_encoder.h" #if CONFIG_IDF_TARGET_ESP32H2 @@ -15,7 +16,8 @@ #else #define DSHOT_ESC_RESOLUTION_HZ 40000000 // 40MHz resolution, DSHot protocol needs a relative high resolution #endif -#define DSHOT_ESC_GPIO_NUM 22 +#define DSHOT_ESC_GPIO_NUM 22 +#define DSHOT_ESC_TELEMETRY_GPIO_NUM 27 static const char *TAG = "spincoat-plater-firmware"; @@ -61,7 +63,7 @@ void initialize_esc_throttle(void) { xTaskCreate(&v_initialize_esc_throttle_func, "v_init_throttle_func", 2048, NULL, 5, &v_init_throttle_handle); vTaskDelay(pdMS_TO_TICKS(5000)); vTaskDelete(v_init_throttle_handle); - vTaskDelay(pdMS_TO_TICKS(1000)); + //vTaskDelay(pdMS_TO_TICKS(1000)); } /** @@ -102,16 +104,32 @@ void send_dshot_packet(void) { if(throttle.telemetry_req == true) { throttle.telemetry_req = false; - printf("Set telemetry to false.\n"); } } void app_main(void) { init_rmt_esc_tx(); - throttle.throttle = 100; + throttle.throttle = 200; xTaskCreate(&v_telemetry_packet_func, "v_telemetry_packet_func", 2048, NULL, 5, NULL); + gpio_dump_io_configuration(stdout, (1ULL << 27)); + + printf("==============================\n\n"); + + // Testing gpio setup + gpio_config_t io_conf = {}; + + io_conf.intr_type = GPIO_INTR_DISABLE; + io_conf.mode = GPIO_MODE_INPUT_OUTPUT; + io_conf.pin_bit_mask = (1ULL<