| 84 | } |
| 85 | |
| 86 | bool initPowerControl() { |
| 87 | LOGGER.info("Init power control (AXP2101)"); |
| 88 | |
| 89 | // Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L61 |
| 90 | aw9523->bitOnP1(0b10000000); // SY7088 boost enable |
| 91 | |
| 92 | /** AXP2101 usage |
| 93 | Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/README.md?plain=1#L223 |
| 94 | | |M5Stack<BR>CoreS3<BR>CoreS3SE| | |
| 95 | |:---------:|:-----------------:|:---------:| |
| 96 | | ALDO1 |VDD 1v8 | ALDO1 | |
| 97 | | ALDO2 |VDDA 3v3 | ALDO2 | |
| 98 | | ALDO3 |CAM 3v3 | ALDO3 | |
| 99 | | ALDO4 |TF 3v3 | ALDO4 | |
| 100 | | BLDO1 |AVDD | BLDO1 | |
| 101 | | BLDO2 |DVDD | BLDO2 | |
| 102 | | DLDO1/DC1 |LCD BL | DLDO1/DC1 | |
| 103 | | DLDO2/DC2 | --- | DLDO2/DC2 | |
| 104 | | BACKUP |RTC BAT | BACKUP | |
| 105 | */ |
| 106 | |
| 107 | /** |
| 108 | * 0x92 = ALD01 |
| 109 | * 0x93 = ALD02 |
| 110 | * 0x94 = ALD03 |
| 111 | * 0x95 = ALD04 |
| 112 | * 0x96 = BLD01 |
| 113 | * 0x97 = BLD02 |
| 114 | * |
| 115 | * DCDC1 : 0.7-3.5V, 25mV/step 1200mA |
| 116 | * DCDC2 : 0.7-2.275V,25mV/step 1600mA |
| 117 | * DCDC3 : 0.7-3.5V, 25mV/step 700mA |
| 118 | |
| 119 | * LDOio0: 1.8-3.3V, 100mV/step 50mA |
| 120 | * LDO1 : 30mA always on |
| 121 | * LDO2 : 1.8-3.3V, 100mV/step 200mA |
| 122 | * LDO3 : 1.8-3.3V, 100mV/step 200mA |
| 123 | */ |
| 124 | // Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L64 |
| 125 | static constexpr uint8_t reg_data_array[] = { |
| 126 | 0x90U, 0xBFU, // LDOS ON/OFF control 0 (backlight) |
| 127 | 0x92U, 18U -5U, // ALDO1 set to 1.8v // for AW88298 |
| 128 | 0x93U, 33U -5U, // ALDO2 set to 3.3v // for ES7210 |
| 129 | 0x94U, 33U -5U, // ALDO3 set to 3.3v // for camera |
| 130 | 0x95U, 33U -5U, // ALDO3 set to 3.3v // for TF card slot |
| 131 | 0x27, 0x00, // PowerKey Hold=1sec / PowerOff=4sec |
| 132 | 0x69, 0x11, // CHGLED setting |
| 133 | 0x10, 0x30, // PMU common config |
| 134 | 0x30, 0x0F // ADC enabled (for voltage measurement) |
| 135 | }; |
| 136 | |
| 137 | if (axp2101->setRegisters((uint8_t*)reg_data_array, sizeof(reg_data_array))) { |
| 138 | LOGGER.info("AXP2101 initialized with {} registers", sizeof(reg_data_array) / 2); |
| 139 | return true; |
| 140 | } else { |
| 141 | LOGGER.error("AXP2101: Failed to set registers"); |
| 142 | return false; |
| 143 | } |
no test coverage detected