Improvements

This commit is contained in:
Ken Van Hoeylandt 2026-07-21 01:15:38 +02:00
parent 88aef27578
commit 66d6348703
4 changed files with 15 additions and 13 deletions

View File

@ -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
)

View File

@ -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 = <AXP2101_DLDO1>;

View File

@ -1,4 +1,3 @@
#include <drivers/axp2101.h>
#include <drivers/py32ioexpander.h>
#include <tactility/check.h>
@ -8,6 +7,9 @@
#include <cstring>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
extern "C" {
// Boot LED pattern (red/green/blue sweep across the 12-LED WS2812C ring).

View File

@ -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;
}
}
}