Code: Select all
// Use GPIOs 36 or lower on the P4 DevKit to avoid LDO power issues with high numbered GPIOs.-TGP
Code: Select all
// Use GPIOs 36 or lower on the P4 DevKit to avoid LDO power issues with high numbered GPIOs.Code: Select all
ESP LDO Channel State:
Index ID ref_cnt voltage_mv adjustable
0 1 1 3300 no
1 2 1 1900 no
2 -1 0 0 yes
3 -1 0 0 yes Code: Select all
#include "esp_ldo_regulator.h"
esp_ldo_channel_handle_t ldo2 = NULL;
esp_ldo_channel_handle_t ldo3 = NULL;
void setup() {
Serial.begin(115200);
delay(1000);
esp_ldo_dump(stdout);
// Create configuration for LDO index 2
esp_ldo_channel_config_t config2 = {
.chan_id = 3, // discovered by trial and error
.voltage_mv = 3300,
.flags = {
.adjustable = 1,
.owned_by_hw = 0,
.bypass = 0
}
};
// Create configuration for LDO index 3
esp_ldo_channel_config_t config3 = {
.chan_id = 4, // discovered by trial and error
.voltage_mv = 3300,
.flags = {
.adjustable = 1,
.owned_by_hw = 0,
.bypass = 0
}
};
// Try to acquire both channels
if (esp_ldo_acquire_channel(&config2, &ldo2) == ESP_OK) {
Serial.println("LDO index 2 acquired");
} else {
Serial.println("Failed to acquire LDO index 2");
}
if (esp_ldo_acquire_channel(&config3, &ldo3) == ESP_OK) {
Serial.println("LDO index 3 acquired");
} else {
Serial.println("Failed to acquire LDO index 3");
}
// Adjust voltage if you want to set it again (redundant if already set above)
if (ldo2) {
esp_ldo_channel_adjust_voltage(ldo2, 3300);
Serial.println("LDO index 2 voltage adjusted");
}
if (ldo3) {
esp_ldo_channel_adjust_voltage(ldo3, 3300);
Serial.println("LDO index 3 voltage adjusted");
}
// Optionally: dump to see results
esp_ldo_dump(stdout);
}
void loop(){}
Code: Select all
LDO index 2 acquired
LDO index 3 acquired
LDO index 2 voltage adjusted
LDO index 3 voltage adjusted
ESP LDO Channel State:
Index ID ref_cnt voltage_mv adjustable
0 1 1 3300 no
1 2 1 1900 no
2 3 1 3300 yes
3 4 1 3300 yes Code: Select all
ESP LDO Channel State:
Index ID ref_cnt voltage_mv adjustable
0 1 1 3300 no
1 -1 0 0 yes
2 -1 0 0 yes
3 -1 0 0 yes Users browsing this forum: YisouSpider and 4 guests