Updatate PMU initializaiton. Increased low battery waring levels and disabled some interrupts
This commit is contained in:
parent
808df200ab
commit
1ea6d7b9f4
13
ports/espressif/boards/m5stack_stick_c/axp192.h
Normal file → Executable file
13
ports/espressif/boards/m5stack_stick_c/axp192.h
Normal file → Executable file
@ -144,21 +144,28 @@
|
||||
#define AXP192_BATT_TEMP_HIGH_THRESH 0x39
|
||||
#define AXP192_BATT_TEMP_HIGH_THRESH_DEFAULT 0b11111100
|
||||
|
||||
#define AXP192_APS_LOW_BATT_LEVEL_1 0x3A
|
||||
#define AXP192_APS_LOW_BATT_LEVEL_2 0x3B
|
||||
#define AXP192_APS_LOW_BATT_VOLTAGE_3_695V 0b10010100
|
||||
#define AXP192_APS_LOW_BATT_VOLTAGE_3_600V 0b10000011
|
||||
|
||||
#define AXP192_IRQ_1_ENABLE 0x40
|
||||
#define AXP192_IRQ_2_ENABLE 0x41
|
||||
#define AXP192_IRQ_3_ENABLE 0x42
|
||||
#define AXP192_IRQ_3_PEK_SHORT_PRESS 0b00000010
|
||||
#define AXP192_IRQ_3_PEK_LONG_PRESS 0b00000001
|
||||
#define AXP192_IRQ_4_ENABLE 0x43
|
||||
#define AXP192_IRQ_4_LOW_VOLTAGE_WARNING 0b00000001
|
||||
#define AXP192_IRQ_5_ENABLE 0x4a
|
||||
|
||||
#define AXP192_IRQ_X_DISABLE_ALL 0b00000000
|
||||
|
||||
#define AXP192_IRQ_1_STATUS 0x44
|
||||
#define AXP192_IRQ_2_STATUS 0x45
|
||||
#define AXP192_IRQ_3_STATUS 0x46
|
||||
#define AXP192_IRQ_4_STATUS 0x47
|
||||
#define AXP192_IRQ_5_STATUS 0x4d
|
||||
|
||||
#define AXP192_IRQ_3_PEK_SHORT_PRESS 0b00000010
|
||||
#define AXP192_IRQ_3_PEK_LONG_PRESS 0b00000001
|
||||
|
||||
#define AXP192_ADC_ACIN_VOLTAGE_H 0x56
|
||||
#define AXP192_ADC_ACIN_VOLTAGE_L 0x57
|
||||
#define AXP192_ADC_ACIN_CURRENT_H 0x58
|
||||
|
80
ports/espressif/boards/m5stack_stick_c/board.c
Normal file → Executable file
80
ports/espressif/boards/m5stack_stick_c/board.c
Normal file → Executable file
@ -127,6 +127,24 @@ static bool pmic_init(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reg: 3Ah
|
||||
// APS Low battery warning level 1: 3.695V
|
||||
write_buf[0] = AXP192_APS_LOW_BATT_LEVEL_1;
|
||||
write_buf[1] = AXP192_APS_LOW_BATT_VOLTAGE_3_695V;
|
||||
rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf));
|
||||
if (rc != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reg: 3Bh
|
||||
// APS Low battery warning level 2: 3.600V
|
||||
write_buf[0] = AXP192_APS_LOW_BATT_LEVEL_2;
|
||||
write_buf[1] = AXP192_APS_LOW_BATT_VOLTAGE_3_600V;
|
||||
rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf));
|
||||
if (rc != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reg: 82h
|
||||
// ADC all on
|
||||
write_buf[0] = AXP192_ADC_ENABLE_1;
|
||||
@ -204,7 +222,7 @@ static bool pmic_init(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reg: 28h
|
||||
// Reg: 26h
|
||||
// DCDC1 (ESP32 VDD): 3.350V
|
||||
write_buf[0] = AXP192_DCDC1_OUT_VOLTAGE;
|
||||
write_buf[1] = AXP192_DCDC1_OUT_VOLTAGE_3_350V;
|
||||
@ -213,6 +231,54 @@ static bool pmic_init(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reg: 40h
|
||||
// IRQ enable control register 1
|
||||
write_buf[0] = AXP192_IRQ_1_ENABLE;
|
||||
write_buf[1] = AXP192_IRQ_X_DISABLE_ALL;
|
||||
rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf));
|
||||
if (rc != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reg: 41h
|
||||
// IRQ enable control register 2
|
||||
write_buf[0] = AXP192_IRQ_2_ENABLE;
|
||||
write_buf[1] = AXP192_IRQ_X_DISABLE_ALL;
|
||||
rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf));
|
||||
if (rc != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reg: 42h
|
||||
// IRQ enable control register 3
|
||||
// Enable power on key short and long press interrupt
|
||||
write_buf[0] = AXP192_IRQ_2_ENABLE;
|
||||
write_buf[1] = AXP192_IRQ_3_PEK_SHORT_PRESS |
|
||||
AXP192_IRQ_3_PEK_LONG_PRESS;
|
||||
rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf));
|
||||
if (rc != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reg: 43h
|
||||
// IRQ enable control register 4
|
||||
// Enable power on key short and long press interrupt
|
||||
write_buf[0] = AXP192_IRQ_2_ENABLE;
|
||||
write_buf[1] = AXP192_IRQ_4_LOW_VOLTAGE_WARNING;
|
||||
rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf));
|
||||
if (rc != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reg: 44h
|
||||
// IRQ enable control register 5
|
||||
write_buf[0] = AXP192_IRQ_2_ENABLE;
|
||||
write_buf[1] = AXP192_IRQ_X_DISABLE_ALL;
|
||||
rc = common_hal_busio_i2c_write(internal_i2c, AXP192_I2C_ADDRESS, write_buf, sizeof(write_buf));
|
||||
if (rc != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -279,7 +345,17 @@ void board_init(void) {
|
||||
}
|
||||
|
||||
if (!display_init()) {
|
||||
mp_printf(&mp_plat_print, "could not initialize ili9342c LCD");
|
||||
mp_printf(&mp_plat_print, "could not initialize the display");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
|
||||
// Set IR led gpio high to prevent power drain from the led
|
||||
if (pin_number == 9) {
|
||||
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
|
||||
gpio_set_level(pin_number, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user