From 8a4e4bc1468720ae69f98e6a13d1e47b108c95ca Mon Sep 17 00:00:00 2001 From: mondraker <691806052@qq.com> Date: Thu, 30 Nov 2023 11:42:43 +0800 Subject: [PATCH] no --- .../PMU_AXP20x/.vscode/c_cpp_properties.json | 19 ----- .../ESP-IDF/PMU_AXP20x/.vscode/launch.json | 35 ---------- .../ESP-IDF/PMU_AXP20x/.vscode/settings.json | 10 --- software/ESP-IDF/PMU_AXP20x/main/main.cpp | 69 ++++++++++++++++++- 4 files changed, 66 insertions(+), 67 deletions(-) delete mode 100644 software/ESP-IDF/PMU_AXP20x/.vscode/c_cpp_properties.json delete mode 100644 software/ESP-IDF/PMU_AXP20x/.vscode/launch.json delete mode 100644 software/ESP-IDF/PMU_AXP20x/.vscode/settings.json diff --git a/software/ESP-IDF/PMU_AXP20x/.vscode/c_cpp_properties.json b/software/ESP-IDF/PMU_AXP20x/.vscode/c_cpp_properties.json deleted file mode 100644 index f81a3a9..0000000 --- a/software/ESP-IDF/PMU_AXP20x/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "configurations": [ - { - "name": "Win32", - "includePath": [ - "${workspaceFolder}/**", - "C:\\Users\\69180\\Desktop\\PMU_AXP20x\\components/**", - "C:\\Espressif/**" - ], - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE" - ], - "configurationProvider": "ms-vscode.makefile-tools" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/software/ESP-IDF/PMU_AXP20x/.vscode/launch.json b/software/ESP-IDF/PMU_AXP20x/.vscode/launch.json deleted file mode 100644 index c4b8cab..0000000 --- a/software/ESP-IDF/PMU_AXP20x/.vscode/launch.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - // 使用 IntelliSense 了解相关属性。 - // 悬停以查看现有属性的描述。 - // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "(gdb) 启动", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/PMU_AXP202x.elf", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "miDebuggerPath": "C:/Espressif/tools/riscv32-esp-elf-gdb/11.2_20220823/riscv32-esp-elf-gdb/bin/riscv32-esp-elf-gdb.exe", - "setupCommands": [ - { - "description": "为 gdb 启用整齐打印", - "text": "-enable-pretty-printing", - "ignoreFailures": true - }, - { - "description": "将反汇编风格设置为 Intel", - "text": "-gdb-set disassembly-flavor intel", - "ignoreFailures": true - } - ] - } - - ] - -} \ No newline at end of file diff --git a/software/ESP-IDF/PMU_AXP20x/.vscode/settings.json b/software/ESP-IDF/PMU_AXP20x/.vscode/settings.json deleted file mode 100644 index bf83d18..0000000 --- a/software/ESP-IDF/PMU_AXP20x/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "idf.adapterTargetName": "esp32s3", - "idf.openOcdConfigs": [ - "board/esp32s3-builtin.cfg" - ], - "idf.flashType": "JTAG", - "idf.portWin": "COM17", - "idf.flashBaudRate": "2000000", - "cmake.configureOnOpen": true -} \ No newline at end of file diff --git a/software/ESP-IDF/PMU_AXP20x/main/main.cpp b/software/ESP-IDF/PMU_AXP20x/main/main.cpp index 16738a5..be1ce6a 100644 --- a/software/ESP-IDF/PMU_AXP20x/main/main.cpp +++ b/software/ESP-IDF/PMU_AXP20x/main/main.cpp @@ -75,7 +75,7 @@ static void axp_irq_init() gpio_evt_queue = xQueueCreate(10, sizeof(uint32_t)); } -static void axp_config_init() +static void axp_init() { if (axp.begin(twi_read, twi_write, AXP202_SLAVE_ADDRESS)) { @@ -83,7 +83,10 @@ static void axp_config_init() while (1); } ESP_LOGI(TAG, "Success init axp20x !!!"); +} +static void axp_config() +{ // 两个警告等级(类似于手机20%一提醒,10%一提醒)和一个关机电压(类似于手机3%关机,实际显示0%) axp.setVWarningLevel1(3450); axp.setVWarningLevel2(3400); @@ -188,16 +191,76 @@ static void axp_config_init() axp.gpioWrite(AXP_GPIO_0, 1); } +static void axp_info() +{ + if (axp.isDCDC2Enable()) + { + ESP_LOGI(TAG, "DC2: %u mV", axp.getDCDC2Voltage()); + } + else + { + ESP_LOGI(TAG, "DC2: DISABLE"); + } + + if (axp.isDCDC3Enable()) + { + ESP_LOGI(TAG, "DC3: %u mV", axp.getDCDC3Voltage()); + } + else + { + ESP_LOGI(TAG, "DC3: DISABLE"); + } + + if (axp.isLDO2Enable()) + { + ESP_LOGI(TAG, "LDO2: %u mV", axp.getLDO2Voltage()); + } + else + { + ESP_LOGI(TAG, "LDO2: DISABLE"); + } + + if (axp.isLDO3Enable()) + { + ESP_LOGI(TAG, "LDO3: %u mV", axp.getLDO3Voltage()); + } + else + { + ESP_LOGI(TAG, "LDO3: DISABLE"); + } + + if (axp.isLDO4Enable()) + { + ESP_LOGI(TAG, "LDO4: %u mV", axp.getLDO4Voltage()); + } + else + { + ESP_LOGI(TAG, "LDO4: DISABLE"); + } + + if (axp.isExtenEnable()) + { + ESP_LOGI(TAG, "Exten: ENABLE"); + } + else + { + ESP_LOGI(TAG, "Exten: DISABLE"); + } +} extern "C" void app_main(void) { ESP_ERROR_CHECK(i2c_master_init()); + axp_init(); + + axp_info(); + axp_irq_init(); - axp_config_init(); + axp_config(); - //! Enable all irq channel + // //! Enable all irq channel axp.enableIRQ(AXP202_ALL_IRQ, true); axp.clearIRQ();