From e6adedab82f25b09cb172fd5591653d93903751d Mon Sep 17 00:00:00 2001 From: henrykotze Date: Tue, 8 Oct 2024 13:45:52 +0200 Subject: [PATCH] i2cdetect working as expected with no device - i2cdetect is running without any device on bus --- boards/espressif/esp32/nuttx-config/nsh/defconfig | 1 + boards/espressif/esp32/src/i2c.cpp | 2 +- .../src/px4/espressif/esp32/include/px4_arch/micro_hal.h | 9 +++------ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/boards/espressif/esp32/nuttx-config/nsh/defconfig b/boards/espressif/esp32/nuttx-config/nsh/defconfig index e5ad6f9fde90..04a4fc617594 100644 --- a/boards/espressif/esp32/nuttx-config/nsh/defconfig +++ b/boards/espressif/esp32/nuttx-config/nsh/defconfig @@ -38,6 +38,7 @@ CONFIG_DEV_PIPE_SIZE=70 CONFIG_DISABLE_MQUEUE=y CONFIG_DISABLE_POSIX_TIMERS=y CONFIG_ESP32_I2C0=y +CONFIG_ESP32_I2CTIMEOMS=10 CONFIG_ESP32_LEDC=y CONFIG_ESP32_LEDC_CHANNEL0_PIN=4 CONFIG_ESP32_LEDC_CHANNEL1_PIN=13 diff --git a/boards/espressif/esp32/src/i2c.cpp b/boards/espressif/esp32/src/i2c.cpp index 1be1f2a61462..34b159bbc310 100644 --- a/boards/espressif/esp32/src/i2c.cpp +++ b/boards/espressif/esp32/src/i2c.cpp @@ -34,5 +34,5 @@ #include constexpr px4_i2c_bus_t px4_i2c_buses[I2C_BUS_MAX_BUS_ITEMS] = { - initI2CBusInternal(0), + initI2CBusInternal(1), }; diff --git a/platforms/nuttx/src/px4/espressif/esp32/include/px4_arch/micro_hal.h b/platforms/nuttx/src/px4/espressif/esp32/include/px4_arch/micro_hal.h index 3f12ce4e9c87..b8936736f16c 100644 --- a/platforms/nuttx/src/px4/espressif/esp32/include/px4_arch/micro_hal.h +++ b/platforms/nuttx/src/px4/espressif/esp32/include/px4_arch/micro_hal.h @@ -96,10 +96,7 @@ __BEGIN_DECLS int px4_esp32_configgpio(uint32_t pinset); int px4_esp32_unconfiggpio(uint32_t pinset); int esp32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,bool event, xcpt_t func, void *arg); - -#define px4_i2cbus_initialize(bus_num_1based) esp32_i2cbus_initialize(bus_num_1based) -#define px4_i2cbus_uninitialize(pdev) esp32_i2cbus_uninitialize(pdev) - +#define PX4_BUS_OFFSET 1 #define px4_arch_configgpio(pinset) px4_esp32_configgpio(pinset) #define px4_arch_unconfiggpio(pinset) px4_esp32_unconfiggpio(pinset) #define px4_arch_gpioread(pinset) esp32_gpioread(pinset & GPIO_NUM_MASK) @@ -108,9 +105,9 @@ int esp32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,bool e #define px4_arch_mtd_dev() esp32_spiflash_get_mtd() -#define px4_spibus_initialize(bus_num_1based) esp32_spibus_initialize(bus_num_1based) +#define px4_spibus_initialize(bus_num_1based) esp32_spibus_initialize(PX4_BUS_NUMBER_FROM_PX4(bus_num_1based)) -#define px4_i2cbus_initialize(bus_num_1based) esp32_i2cbus_initialize(bus_num_1based) +#define px4_i2cbus_initialize(bus_num_1based) esp32_i2cbus_initialize(PX4_BUS_NUMBER_FROM_PX4(bus_num_1based)) #define px4_i2cbus_uninitialize(pdev) esp32_i2cbus_uninitialize(pdev) #define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_UNUSED