From 128f52f807d78624967921d90be521e32876cf4d Mon Sep 17 00:00:00 2001 From: Wiktor Maslowski Date: Tue, 29 Nov 2022 22:54:25 +0100 Subject: [PATCH] AP_HAL_ESP32: fix the board names --- libraries/AP_HAL_ESP32/SoftSigReaderRMT.cpp | 14 ++++++-------- libraries/AP_HAL_ESP32/Util.cpp | 4 ++-- libraries/AP_HAL_ESP32/boards/esp32buzz.h | 3 +++ libraries/AP_HAL_ESP32/boards/esp32diy.h | 3 +++ libraries/AP_HAL_ESP32/boards/esp32icarus.h | 3 +++ 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libraries/AP_HAL_ESP32/SoftSigReaderRMT.cpp b/libraries/AP_HAL_ESP32/SoftSigReaderRMT.cpp index 8035f015fe..6bb4a6c150 100644 --- a/libraries/AP_HAL_ESP32/SoftSigReaderRMT.cpp +++ b/libraries/AP_HAL_ESP32/SoftSigReaderRMT.cpp @@ -49,15 +49,13 @@ void SoftSigReaderRMT::init() rmt_config_t config; config.rmt_mode = RMT_MODE_RX; config.channel = RMT_CHANNEL_0; -#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_ESP32_ICARUS - config.gpio_num = (gpio_num_t)36; -#endif -#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_ESP32_DIY - config.gpio_num = (gpio_num_t)4; -#endif -#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_ESP32_BUZZ - config.gpio_num = (gpio_num_t)4; + +#ifndef HAL_ESP32_RMT_RX_PIN_NUMBER + #error HAL_ESP32_RMT_RX_PIN_NUMBER undefined in libraries/AP_HAL_ESP32/boards/esp32... .h #endif + + config.gpio_num = (gpio_num_t)HAL_ESP32_RMT_RX_PIN_NUMBER; + config.clk_div = RMT_CLK_DIV; config.mem_block_num = 1; config.rx_config.filter_en = true; diff --git a/libraries/AP_HAL_ESP32/Util.cpp b/libraries/AP_HAL_ESP32/Util.cpp index 26bcdffa11..c6d4540705 100644 --- a/libraries/AP_HAL_ESP32/Util.cpp +++ b/libraries/AP_HAL_ESP32/Util.cpp @@ -217,7 +217,7 @@ Util::FlashBootloader Util::flash_bootloader() bool Util::get_system_id(char buf[50]) { //uint8_t serialid[12]; - char board_name[14] = "esp32-buzz "; + char board_name[] = HAL_ESP32_BOARD_NAME" "; uint8_t base_mac_addr[6] = {0}; esp_err_t ret = esp_efuse_mac_get_custom(base_mac_addr); @@ -230,7 +230,7 @@ bool Util::get_system_id(char buf[50]) base_mac_addr[0], base_mac_addr[1], base_mac_addr[2], base_mac_addr[3], base_mac_addr[4], base_mac_addr[5]); // null terminate both - board_name[13] = 0; + //board_name[13] = 0; board_mac[19] = 0; // tack strings togehter diff --git a/libraries/AP_HAL_ESP32/boards/esp32buzz.h b/libraries/AP_HAL_ESP32/boards/esp32buzz.h index 6f7303e6dc..29ff8cfe97 100644 --- a/libraries/AP_HAL_ESP32/boards/esp32buzz.h +++ b/libraries/AP_HAL_ESP32/boards/esp32buzz.h @@ -14,6 +14,8 @@ */ #pragma once +#define HAL_ESP32_BOARD_NAME "esp32-buzz" + // make sensor selection clearer #define PROBE_IMU_I2C(driver, bus, addr, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,GET_I2C_DEVICE(bus, addr),##args)) #define PROBE_IMU_SPI(driver, devname, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,hal.spi->get_device(devname),##args)) @@ -180,3 +182,4 @@ // setting to 2 means log-over-mavlink to a companion computer etc. #define HAL_LOGGING_BACKENDS_DEFAULT 1 +#define HAL_ESP32_RMT_RX_PIN_NUMBER 4 diff --git a/libraries/AP_HAL_ESP32/boards/esp32diy.h b/libraries/AP_HAL_ESP32/boards/esp32diy.h index 34b6272db2..94351155dc 100644 --- a/libraries/AP_HAL_ESP32/boards/esp32diy.h +++ b/libraries/AP_HAL_ESP32/boards/esp32diy.h @@ -14,6 +14,8 @@ */ #pragma once +#define HAL_ESP32_BOARD_NAME "esp32-diy" + // make sensor selection clearer #define PROBE_IMU_I2C(driver, bus, addr, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,GET_I2C_DEVICE(bus, addr),##args)) #define PROBE_IMU_SPI(driver, devname, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,hal.spi->get_device(devname),##args)) @@ -111,3 +113,4 @@ +#define HAL_ESP32_RMT_RX_PIN_NUMBER 4 diff --git a/libraries/AP_HAL_ESP32/boards/esp32icarus.h b/libraries/AP_HAL_ESP32/boards/esp32icarus.h index 7a5c5b4f1f..deab0718e2 100644 --- a/libraries/AP_HAL_ESP32/boards/esp32icarus.h +++ b/libraries/AP_HAL_ESP32/boards/esp32icarus.h @@ -14,6 +14,8 @@ */ #pragma once +#define HAL_ESP32_BOARD_NAME "esp32-icarus" + #define HAL_INS_DEFAULT AP_FEATURE_BOARD_DETECT #define HAL_INS_MPU60x0_NAME "MPU6000" #define TRUE 1 @@ -56,3 +58,4 @@ #define HAL_DISABLE_ADC_DRIVER 1 #define HAL_USE_ADC 0 +#define HAL_ESP32_RMT_RX_PIN_NUMBER 36