Compare commits
2 Commits
504aeaae01
...
2cd91d966c
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cd91d966c | |||
| 9d37201166 |
@ -1370,12 +1370,15 @@ int AXP20X_Class::debugStatus(void)
|
|||||||
{
|
{
|
||||||
if (!_init)
|
if (!_init)
|
||||||
return AXP_NOT_INIT;
|
return AXP_NOT_INIT;
|
||||||
uint8_t val, val1, val2;
|
uint8_t val, val1, val2,val3,val4;
|
||||||
_readByte(AXP202_STATUS, 1, &val);
|
_readByte(AXP202_STATUS, 1, &val);
|
||||||
_readByte(AXP202_MODE_CHGSTATUS, 1, &val1);
|
_readByte(AXP202_MODE_CHGSTATUS, 1, &val1);
|
||||||
_readByte(AXP202_IPS_SET, 1, &val2);
|
_readByte(AXP202_IPS_SET, 1, &val2);
|
||||||
|
_readByte(AXP202_ADC_EN1,1,&val3);
|
||||||
|
_readByte(AXP202_ADC_EN2,1,&val4);
|
||||||
AXP_DEBUG("AXP202_STATUS: AXP202_MODE_CHGSTATUS AXP202_IPS_SET\n");
|
AXP_DEBUG("AXP202_STATUS: AXP202_MODE_CHGSTATUS AXP202_IPS_SET\n");
|
||||||
AXP_DEBUG("0x%x\t\t\t 0x%x\t\t\t 0x%x\n", val, val1, val2);
|
AXP_DEBUG("0x%x\t\t\t 0x%x\t\t\t 0x%x\n", val, val1, val2);
|
||||||
|
AXP_DEBUG("0x%x\t\t\t 0x%x\t\t\t 0x%x\n", val3, val4, val2);
|
||||||
return AXP_PASS;
|
return AXP_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,7 @@ extern "C" {
|
|||||||
#else
|
#else
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <cstdio>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #define AXP_DEBUG_PORT Serial
|
// #define AXP_DEBUG_PORT Serial
|
||||||
|
|||||||
@ -68,6 +68,7 @@ void button_init_all()
|
|||||||
.gpio_num = button_pins[i],
|
.gpio_num = button_pins[i],
|
||||||
.active_level = BUTTON_ACTIVE_LEVEL,
|
.active_level = BUTTON_ACTIVE_LEVEL,
|
||||||
.enable_power_save = true,
|
.enable_power_save = true,
|
||||||
|
.disable_pull = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
esp_err_t ret = iot_button_new_gpio_device(&btn_cfg, &gpio_cfg, &buttons[i]);
|
esp_err_t ret = iot_button_new_gpio_device(&btn_cfg, &gpio_cfg, &buttons[i]);
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include "i2c_port.h"
|
#include "i2c_port.h"
|
||||||
#include "axp20x.hpp"
|
#include "axp20x.hpp"
|
||||||
|
|
||||||
|
|
||||||
static const char *TAG = "AXP20x";
|
static const char *TAG = "AXP20x";
|
||||||
|
|
||||||
extern "C" QueueHandle_t gpio_evt_queue = NULL;
|
extern "C" QueueHandle_t gpio_evt_queue = NULL;
|
||||||
@ -30,7 +31,7 @@ extern "C" void axp_irq_init()
|
|||||||
//change gpio intrrupt type for one pin
|
//change gpio intrrupt type for one pin
|
||||||
gpio_set_intr_type(AXP_ISR_GPIO, GPIO_INTR_NEGEDGE);
|
gpio_set_intr_type(AXP_ISR_GPIO, GPIO_INTR_NEGEDGE);
|
||||||
//install gpio isr service
|
//install gpio isr service
|
||||||
gpio_install_isr_service(0);
|
// gpio_install_isr_service(0);
|
||||||
//hook isr handler for specific gpio pin
|
//hook isr handler for specific gpio pin
|
||||||
gpio_isr_handler_add(AXP_ISR_GPIO, axp_isr_handler, (void *) AXP_ISR_GPIO);
|
gpio_isr_handler_add(AXP_ISR_GPIO, axp_isr_handler, (void *) AXP_ISR_GPIO);
|
||||||
//create a queue to handle gpio event from isr
|
//create a queue to handle gpio event from isr
|
||||||
@ -153,8 +154,8 @@ extern "C" void axp_config()
|
|||||||
axp.setBackupChargeVoltage(AXP202_BACKUP_VOLTAGE_3V0);
|
axp.setBackupChargeVoltage(AXP202_BACKUP_VOLTAGE_3V0);
|
||||||
axp.setBackupChargeCurrent(AXP202_BACKUP_CURRENT_100UA);
|
axp.setBackupChargeCurrent(AXP202_BACKUP_CURRENT_100UA);
|
||||||
|
|
||||||
axp.setGPIOMode(AXP_GPIO_0, AXP_IO_OUTPUT_HIGH_MODE); // 打开主板指示灯PIO0
|
axp.setGPIOMode(AXP_GPIO_0, AXP_IO_LDO_MODE); // 屏幕供电
|
||||||
axp.gpioWrite(AXP_GPIO_0, 1);
|
axp.setLDO5Voltage(AXP202_LDO5_3300MV);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void axp_info()
|
extern "C" void axp_info()
|
||||||
@ -248,7 +249,10 @@ extern "C" void Axp202_task(void *pvParameter)
|
|||||||
|
|
||||||
axp_config();
|
axp_config();
|
||||||
|
|
||||||
|
axp.adc1Enable(AXP202_BATT_VOL_ADC1 | AXP202_BATT_CUR_ADC1 | AXP202_VBUS_VOL_ADC1 | AXP202_VBUS_CUR_ADC1,true);
|
||||||
|
axp.adc1Enable(AXP202_APS_VOL_ADC1 | AXP202_TS_PIN_ADC1,false);
|
||||||
axp.ClearCoulombcounter();
|
axp.ClearCoulombcounter();
|
||||||
|
|
||||||
axp.EnableCoulombcounter();
|
axp.EnableCoulombcounter();
|
||||||
|
|
||||||
|
|
||||||
@ -262,8 +266,14 @@ extern "C" void Axp202_task(void *pvParameter)
|
|||||||
if (io_num == AXP_ISR_GPIO) {
|
if (io_num == AXP_ISR_GPIO) {
|
||||||
axp.readIRQ();
|
axp.readIRQ();
|
||||||
if (axp.isPEKLongtPressIRQ()) {
|
if (axp.isPEKLongtPressIRQ()) {
|
||||||
|
ESP_LOGI("sleep","esp_light_sleep_start");
|
||||||
|
axp.setGPIOMode(AXP_GPIO_0, AXP_IO_INPUT_MODE); // 屏幕供电
|
||||||
|
vTaskDelay(500/ portTICK_PERIOD_MS);
|
||||||
|
esp_light_sleep_start();
|
||||||
ESP_LOGI(TAG, "AXP202 PEK key Click:%.2f,%.2f,%.2f,%d",axp.getBattVoltage(),axp.getCoulombData(),axp.getBattDischargeCurrent(),axp.getBattPercentage());
|
ESP_LOGI(TAG, "AXP202 PEK key Click:%.2f,%.2f,%.2f,%d",axp.getBattVoltage(),axp.getCoulombData(),axp.getBattDischargeCurrent(),axp.getBattPercentage());
|
||||||
// axp.shutdown();
|
// axp.shutdown();
|
||||||
|
axp.setGPIOMode(AXP_GPIO_0, AXP_IO_LDO_MODE); // 屏幕供电
|
||||||
|
|
||||||
}
|
}
|
||||||
axp.clearIRQ();
|
axp.clearIRQ();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
#include "wifi_task.h"
|
#include "wifi_task.h"
|
||||||
#include "spiffs.h"
|
#include "spiffs.h"
|
||||||
|
|
||||||
|
#include "esp_sleep.h"
|
||||||
|
|
||||||
#include "bsp_flash.h"
|
#include "bsp_flash.h"
|
||||||
|
|
||||||
#include "esp_efuse.h"
|
#include "esp_efuse.h"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user