MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / initAxp

Function initAxp

Devices/m5stack-stickc-plus/Source/devices/Power.cpp:18–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18bool initAxp() {
19 const auto axp = createAxp192();
20 return axp->init([](auto* driver) {
21 // Reference: https://github.com/pr3y/Bruce/blob/main/lib/utility/AXP192.cpp
22 axp192_ioctl(driver, AXP192_LDO23_VOLTAGE, 3300); // LCD backlight
23 axp192_ioctl(driver, AXP192_ADC_ENABLE_1, 0xff); // Set all ADC enabled
24 axp192_ioctl(driver, AXP192_CHARGE_CONTROL_1, 0xc0); // Battery charging at 4.2 V and 100 mA
25 axp192_ioctl(driver, AXP192_ADC_ENABLE_1, 0xff); // Enable battery, AC in, Vbus, APS ADC
26 uint8_t buffer;
27 axp192_read(driver, AXP192_DCDC13_LDO23_CONTROL, &buffer);
28 axp192_ioctl(driver, AXP192_DCDC13_LDO23_CONTROL, buffer | 0x4D); // Enable Ext, LDO2, LDO3, DCDC1
29 axp192_ioctl(driver, AXP192_PEK, 0x0C); // 128 ms power on, 4 s power off
30 axp192_ioctl(driver, AXP192_GPIO0_LDOIO0_VOLTAGE, 0xF0); // 3.3 V RTC voltage
31 axp192_ioctl(driver, AXP192_GPIO0_CONTROL, 0x02); // Set GPIO0 to LDO
32 axp192_ioctl(driver, AXP192_VBUS_IPSOUT_CHANNEL, 0x80); // Disable Vbus hold limit
33 axp192_ioctl(driver, AXP192_BATTERY_CHARGE_HIGH_TEMP, 0xFC); // Set temperature protection
34 axp192_ioctl(driver, AXP192_BATTERY_CHARGE_CONTROL, 0xA2); // Enable RTC BAT charge
35 axp192_ioctl(driver, AXP192_SHUTDOWN_BATTERY_CHGLED_CONTROL, 0x46); // Enable bat detection
36 return true;
37 });
38
39}

Callers 1

initBootFunction · 0.50

Calls 4

axp192_ioctlFunction · 0.85
axp192_readFunction · 0.85
createAxp192Function · 0.70
initMethod · 0.45

Tested by

no test coverage detected