Add GPIO input configuration

This commit is contained in:
maddiebaka
2025-11-25 17:31:28 -05:00
parent 1ebf753862
commit 6156dc3466
2 changed files with 23 additions and 5 deletions

View File

@@ -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<<DSHOT_ESC_TELEMETRY_GPIO_NUM);
io_conf.pull_down_en = GPIO_PULLDOWN_ENABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&io_conf);
gpio_dump_io_configuration(stdout, (1ULL << 27));
while(1) {
send_dshot_packet();
}