From 66d6348703f591057be43097b2bdfd05e01d7f13 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Tue, 21 Jul 2026 01:15:38 +0200 Subject: [PATCH] Improvements --- Devices/m5stack-stackchan/CMakeLists.txt | 2 +- .../m5stack-stackchan/m5stack,stackchan.dts | 4 +--- Devices/m5stack-stackchan/source/module.cpp | 4 +++- Drivers/axp2101-module/source/axp2101.cpp | 18 ++++++++++-------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Devices/m5stack-stackchan/CMakeLists.txt b/Devices/m5stack-stackchan/CMakeLists.txt index 0fcf2f68b..40769314a 100644 --- a/Devices/m5stack-stackchan/CMakeLists.txt +++ b/Devices/m5stack-stackchan/CMakeLists.txt @@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES source/*.c*) idf_component_register( SRCS ${SOURCE_FILES} INCLUDE_DIRS "source" - REQUIRES TactilityKernel axp2101-module py32ioexpander-module + REQUIRES TactilityKernel py32ioexpander-module ) diff --git a/Devices/m5stack-stackchan/m5stack,stackchan.dts b/Devices/m5stack-stackchan/m5stack,stackchan.dts index 7e2aabb81..486362e80 100644 --- a/Devices/m5stack-stackchan/m5stack,stackchan.dts +++ b/Devices/m5stack-stackchan/m5stack,stackchan.dts @@ -94,7 +94,7 @@ // Same rail assignment as CoreS3: ALDO1=AW88298, ALDO2=ES7210, ALDO3=camera // (not yet implemented, but harmless to power), ALDO4=TF/SD card. BLDO1/BLDO2 are - // enabled with no specific voltage requirement - see the module's device_listener. + // enabled with no specific voltage requirement. axp2101 { compatible = "x-powers,axp2101"; reg = <0x34>; @@ -109,8 +109,6 @@ bldo1-enabled; bldo2-enabled; - // LCD backlight (DLDO1). Raw register codes [20,28] from the deprecated driver - // map to [2500,3300]mV. display_backlight: backlight { compatible = "axp2101-backlight"; ldo = ; diff --git a/Devices/m5stack-stackchan/source/module.cpp b/Devices/m5stack-stackchan/source/module.cpp index 6e941ada6..93212b4d0 100644 --- a/Devices/m5stack-stackchan/source/module.cpp +++ b/Devices/m5stack-stackchan/source/module.cpp @@ -1,4 +1,3 @@ -#include #include #include @@ -8,6 +7,9 @@ #include +#include +#include + extern "C" { // Boot LED pattern (red/green/blue sweep across the 12-LED WS2812C ring). diff --git a/Drivers/axp2101-module/source/axp2101.cpp b/Drivers/axp2101-module/source/axp2101.cpp index 225aecb4c..578414fef 100644 --- a/Drivers/axp2101-module/source/axp2101.cpp +++ b/Drivers/axp2101-module/source/axp2101.cpp @@ -264,7 +264,7 @@ error_t axp2101_set_ldo_voltage(Device* device, Axp2101Ldo ldo, uint16_t millivo uint8_t code; error_t err = encode_single_range(millivolts, LDO_RANGE[ldo], &code); if (err != ERROR_NONE) { - LOG_E(TAG, "Failed to encode"); + LOG_E(TAG, "Failed to encode %u mV", millivolts); return err; } @@ -528,9 +528,9 @@ static error_t start(Device* device) { return error; } - // All 9 LDO channels: each is only touched when BOTH its voltage is set (non-zero) AND its - // matching xEnabled flag is set - boards that need it enable/voltage-set the channel via - // config instead of per-board imperative code. Order matches enum Axp2101Ldo. + // All 9 LDO channels: voltage and enable states are applied independently if configured. + // Boards that need it enable/voltage-set the channel via config instead of per-board imperative code. + // Order matches enum Axp2101Ldo. static constexpr Axp2101Ldo LDO_CHANNELS[9] = { AXP2101_ALDO1, AXP2101_ALDO2, AXP2101_ALDO3, AXP2101_ALDO4, AXP2101_BLDO1, AXP2101_BLDO2, AXP2101_CPUSLDO, AXP2101_DLDO1, AXP2101_DLDO2, @@ -551,16 +551,18 @@ static error_t start(Device* device) { }; for (size_t i = 0; i < 9; i++) { if (ldo_millivolts[i] != 0) { - if (axp2101_set_ldo_voltage(device, LDO_CHANNELS[i], ldo_millivolts[i]) != ERROR_NONE) { + error_t err = axp2101_set_ldo_voltage(device, LDO_CHANNELS[i], ldo_millivolts[i]); + if (err != ERROR_NONE) { LOG_E(TAG, "Failed to set %s voltage", LDO_NAMES[i]); - return ERROR_RESOURCE; + return err; } } if (ldo_enabled[i]) { - if (axp2101_set_ldo_enabled(device, LDO_CHANNELS[i], true) != ERROR_NONE) { + error_t err = axp2101_set_ldo_enabled(device, LDO_CHANNELS[i], true); + if (err != ERROR_NONE) { LOG_E(TAG, "Failed to enable %s", LDO_NAMES[i]); - return ERROR_RESOURCE; + return err; } } }