mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-08-20 08:55:06 +00:00
Improvements
This commit is contained in:
parent
88aef27578
commit
66d6348703
@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES source/*.c*)
|
|||||||
idf_component_register(
|
idf_component_register(
|
||||||
SRCS ${SOURCE_FILES}
|
SRCS ${SOURCE_FILES}
|
||||||
INCLUDE_DIRS "source"
|
INCLUDE_DIRS "source"
|
||||||
REQUIRES TactilityKernel axp2101-module py32ioexpander-module
|
REQUIRES TactilityKernel py32ioexpander-module
|
||||||
)
|
)
|
||||||
|
|||||||
@ -94,7 +94,7 @@
|
|||||||
|
|
||||||
// Same rail assignment as CoreS3: ALDO1=AW88298, ALDO2=ES7210, ALDO3=camera
|
// 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
|
// (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 {
|
axp2101 {
|
||||||
compatible = "x-powers,axp2101";
|
compatible = "x-powers,axp2101";
|
||||||
reg = <0x34>;
|
reg = <0x34>;
|
||||||
@ -109,8 +109,6 @@
|
|||||||
bldo1-enabled;
|
bldo1-enabled;
|
||||||
bldo2-enabled;
|
bldo2-enabled;
|
||||||
|
|
||||||
// LCD backlight (DLDO1). Raw register codes [20,28] from the deprecated driver
|
|
||||||
// map to [2500,3300]mV.
|
|
||||||
display_backlight: backlight {
|
display_backlight: backlight {
|
||||||
compatible = "axp2101-backlight";
|
compatible = "axp2101-backlight";
|
||||||
ldo = <AXP2101_DLDO1>;
|
ldo = <AXP2101_DLDO1>;
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
#include <drivers/axp2101.h>
|
|
||||||
#include <drivers/py32ioexpander.h>
|
#include <drivers/py32ioexpander.h>
|
||||||
|
|
||||||
#include <tactility/check.h>
|
#include <tactility/check.h>
|
||||||
@ -8,6 +7,9 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
// Boot LED pattern (red/green/blue sweep across the 12-LED WS2812C ring).
|
// Boot LED pattern (red/green/blue sweep across the 12-LED WS2812C ring).
|
||||||
|
|||||||
@ -264,7 +264,7 @@ error_t axp2101_set_ldo_voltage(Device* device, Axp2101Ldo ldo, uint16_t millivo
|
|||||||
uint8_t code;
|
uint8_t code;
|
||||||
error_t err = encode_single_range(millivolts, LDO_RANGE[ldo], &code);
|
error_t err = encode_single_range(millivolts, LDO_RANGE[ldo], &code);
|
||||||
if (err != ERROR_NONE) {
|
if (err != ERROR_NONE) {
|
||||||
LOG_E(TAG, "Failed to encode");
|
LOG_E(TAG, "Failed to encode %u mV", millivolts);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,9 +528,9 @@ static error_t start(Device* device) {
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All 9 LDO channels: each is only touched when BOTH its voltage is set (non-zero) AND its
|
// All 9 LDO channels: voltage and enable states are applied independently if configured.
|
||||||
// matching xEnabled flag is set - boards that need it enable/voltage-set the channel via
|
// Boards that need it enable/voltage-set the channel via config instead of per-board imperative code.
|
||||||
// config instead of per-board imperative code. Order matches enum Axp2101Ldo.
|
// Order matches enum Axp2101Ldo.
|
||||||
static constexpr Axp2101Ldo LDO_CHANNELS[9] = {
|
static constexpr Axp2101Ldo LDO_CHANNELS[9] = {
|
||||||
AXP2101_ALDO1, AXP2101_ALDO2, AXP2101_ALDO3, AXP2101_ALDO4,
|
AXP2101_ALDO1, AXP2101_ALDO2, AXP2101_ALDO3, AXP2101_ALDO4,
|
||||||
AXP2101_BLDO1, AXP2101_BLDO2, AXP2101_CPUSLDO, AXP2101_DLDO1, AXP2101_DLDO2,
|
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++) {
|
for (size_t i = 0; i < 9; i++) {
|
||||||
if (ldo_millivolts[i] != 0) {
|
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]);
|
LOG_E(TAG, "Failed to set %s voltage", LDO_NAMES[i]);
|
||||||
return ERROR_RESOURCE;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ldo_enabled[i]) {
|
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]);
|
LOG_E(TAG, "Failed to enable %s", LDO_NAMES[i]);
|
||||||
return ERROR_RESOURCE;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user