In development. It changes without notice.
Topic
Power Chip Drivers
The power chips: battery, power key, the supply of the parts, and switching the board off.
| Chip | Boards | What the firmware uses it for |
|---|---|---|
| Axp192 | Core2 v1.3, M5StickC Plus 1.1, M5StickC Plus SE | Battery, power key, supplies, power-off |
| Axp2101 | CoreS3 SE | The same, with a fuel gauge |
| Py32Pmic (M5PM1) | M5StickS3 | Battery, power key, supplies, and the line that ends the deep sleep |
| Aw9523 (I/O expander) | CoreS3 SE | Resets and supplies of other parts |
A driver for the IP5306 is here too; none of the nine boards has that chip.
Off. The AXP192 and the AXP2101 switch the board off. First they clear what their interrupts hold, and the AXP2101 masks them, because there a pending one would power the board on again. Only the chip's own power-on sources bring it back, as a cold start. Their power key's timing and interrupts are written at the start, since the chip keeps what any earlier firmware set.
Asleep. The M5PM1 does not switch the board off. Its driver lets a click of the power key pull one line low, which is what ends the ESP32-S3's deep sleep.
- See also
- Power, Battery & Parking, Audio Drivers
Files | |
| file | src/ |
| AW9523B I/O expander driver for the CoreS3 SE's display rail/reset control. | |
| file | src/ |
| AW9523B I2C GPIO expander register map (CoreS3 SE display subset). | |
| file | src/ |
| X-Powers AXP192 PMIC driver (battery telemetry + display rails). | |
| file | src/ |
| X-Powers AXP192 PMIC register map (Kleidos subset). | |
| file | src/ |
| X-Powers AXP2101 PMIC driver (battery telemetry + display rails). | |
| file | src/ |
| X-Powers AXP2101 PMIC register map (Kleidos subset). | |
| file | src/ |
| Power-key configuration, IRQ latch clearing and soft power-off of the X-Powers AXP192 and AXP2101. | |
| file | src/ |
| Raw coulomb-counter reading: the two hardware counters and the ADC rate. | |
| file | src/ |
| Abstract Power Management IC driver contract. | |
| file | src/ |
| Injoinic IP5306 power-bank PMIC driver. | |
| file | src/ |
| Injoinic IP5306 power-bank PMIC register map (Kleidos subset). | |
| file | src/ |
| Shared pure helpers for the concrete PMIC drivers. | |
| file | src/ |
| PMIC driver factory — probes the internal I2C bus for the chip. | |
| file | src/ |
| PY32-based M5PM1 PMIC driver for the M5StickS3. | |
| file | src/ |
| GPIO-function fields and the power-key IRQ line of the M5PM1 (PY32) PMIC on the M5StickS3. | |
| file | src/ |
| PY32-based M5PM1 PMIC register map (M5StickS3). | |
Functions | |
| bool | kleidos:: |
| Pin the AXP192 power-key timing and its IRQ enables. | |
| bool | kleidos:: |
| Clear every AXP192 IRQ status latch. | |
| bool | kleidos:: |
| Switch the board off at the AXP192. | |
| bool | kleidos:: |
| Put the AXP192 outputs a board never uses in their off state. | |
| bool | kleidos:: |
| Pin the AXP2101 power-key timing, its OFFLEVEL action and its IRQ enables. | |
| bool | kleidos:: |
| Clear every AXP2101 IRQ status latch. | |
| bool | kleidos:: |
| Switch the board off at the AXP2101. | |
| IPmic * | kleidos:: |
| Probes the PMIC at address, returning a ready singleton driver for the detected chip, or nullptr if none is present/ | |
| bool | kleidos:: |
Set PYG pin's two-bit function field, preserving the other pins'. | |
| bool | kleidos:: |
Drive PYG pin high or low, and nothing else: its bit of the output register, preserving the other pins'. | |
| bool | kleidos:: |
| Route the power key's click to the PYG1 IRQ line, released. | |
| bool | kleidos:: |
| Route PYG4's level changes (the IMU's INT1) to the PYG1 IRQ line. | |
| bool | kleidos:: |
Clear the PYG level-change latch (IRQ_STATUS1), which releases the IRQ line while armMotionIrq has it routed. | |
| bool | kleidos:: |
| Clear the three IRQ latches (0x40-0x42), releasing the IRQ line. | |
| bool | kleidos:: |
| Return PYG1 to the PMIC's reset state, a plain input. | |
| constexpr uint8_t | kleidos:: |
Register holding PYG pin's two-bit field, given the first of the pair. | |
| constexpr uint8_t | kleidos:: |
Bit position of PYG pin's two-bit field in its register. | |
Variables | |
| constexpr uint8_t | kleidos:: |
| Port 0 input state. | |
| constexpr uint8_t | kleidos:: |
| Port 1 input state. | |
| constexpr uint8_t | kleidos:: |
| Port 0 output state. | |
| constexpr uint8_t | kleidos:: |
| Port 1 output state (LCD_RST = bit 1). | |
| constexpr uint8_t | kleidos:: |
| Port 0 direction (0 => output, 1 => input). | |
| constexpr uint8_t | kleidos:: |
| Port 1 direction. | |
| constexpr uint8_t | kleidos:: |
| Read-only chip ID. | |
| constexpr uint8_t | kleidos:: |
| Global control (bit4 => Port0 push-pull). | |
| constexpr uint8_t | kleidos:: |
| 1 => GPIO mode, 0 => LED dim mode. | |
| constexpr uint8_t | kleidos:: |
| Port 1 LED/GPIO mode select. | |
| constexpr uint8_t | kleidos:: |
| Expected read-only chip ID value. | |
| constexpr uint8_t | kleidos:: |
| AW9523 P1.1 — panel reset line. | |
| constexpr uint8_t | kleidos:: |
| AW9523 P0.2 — speaker amplifier gate. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| AW9523 P1.7 BOOST_EN: the SY7088 5 V boost's enable. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| Port 1 pins begin() writes: the ones it drives high and the boost enable. | |
| constexpr uint8_t | kleidos:: |
| Port 0 direction (1 => input). | |
| constexpr uint8_t | kleidos:: |
| Port 1 direction (1 => input). | |
| constexpr uint8_t | kleidos:: |
| GCR bit 4: Port 0 push-pull output mode. | |
| constexpr uint8_t | kleidos:: |
| Force GPIO mode on every port pin. | |
| constexpr uint8_t | kleidos:: |
| Power-status register (charging bit). | |
| constexpr uint8_t | kleidos:: |
Charging flag bit in kRegStatus. | |
| constexpr int | kleidos:: |
| 1.1 mV → (raw * 11 + 5) / 10 | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr int | kleidos:: |
| 0.5 mA/LSB → raw * 1 / 2 | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr int | kleidos:: |
| 1.7 mV/LSB → raw * 17 / 10 | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr int | kleidos:: |
| 0.625 mA/LSB → raw * 625 / 1000 | |
| constexpr int | kleidos:: |
| Denominator of the 0.625 mA/LSB scale. | |
| constexpr uint8_t | kleidos:: |
| 0x82 bit5: ACIN-voltage ADC | |
| constexpr uint8_t | kleidos:: |
| 0x82 bit4: ACIN-current ADC | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| 0xB0..0xB3 (MSB first) | |
| constexpr uint8_t | kleidos:: |
| 0xB4..0xB7 (MSB first) | |
| constexpr uint8_t | kleidos:: |
| INTSTS1: ACIN / VBUS events. | |
| constexpr uint8_t | kleidos:: |
| INTSTS2: battery / charger events. | |
| constexpr uint8_t | kleidos:: |
| INTSTS3: power key, DCDC low-V, over-temp. | |
| constexpr uint8_t | kleidos:: |
| INTSTS4: N_OE, VBUS session, APS low-V. | |
| constexpr uint8_t | kleidos:: |
| constexpr std::array< uint8_t, 5 > | kleidos:: |
| Every IRQ status latch, in the order a full clear writes them. | |
| constexpr uint8_t | kleidos:: |
| Value written to a status latch to clear every bit of it (write-1-to-clear). | |
| constexpr uint8_t | kleidos:: |
| Latch read by the click poll. | |
| constexpr uint8_t | kleidos:: |
| Short + long press bits. | |
| constexpr uint8_t | kleidos:: |
| Field offset of the key bits. | |
| constexpr uint8_t | kleidos:: |
| INTEN3: power key, DCDC low-V, over-temp. | |
| constexpr uint8_t | kleidos:: |
| Short-press IRQ enable. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| The key enables the driver owns in INTEN3 (both are set). | |
| constexpr uint8_t | kleidos:: |
| POK_SET: power-key timing. | |
| constexpr uint8_t | kleidos:: |
| ONLEVEL code 0: 128 ms press powers on. | |
| constexpr uint8_t | kleidos:: |
| Long-press IRQ after 1 s. | |
| constexpr uint8_t | kleidos:: |
| Holding the key for OFFLEVEL powers off. | |
| constexpr uint8_t | kleidos:: |
| PWROK asserted 64 ms after power-up. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| The pinned POK_SET value: 128 ms on, 1 s long press, power off after a 4 s hold. | |
| constexpr uint8_t | kleidos:: |
| POK_SET has no reserved bit. | |
| constexpr uint8_t | kleidos:: |
| OFF_CTL: soft power-off, CHGLED, N_OE. | |
| constexpr uint8_t | kleidos:: |
| Soft power-off command bit. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| GPIO3/4 function control. | |
| constexpr uint8_t | kleidos:: |
| GPIO3/4 output level. | |
| constexpr uint8_t | kleidos:: |
| bit7 enable, GPIO4 = output | |
| constexpr uint8_t | kleidos:: |
| GPIO0 function; 010 switches the LDOio0 rail on. | |
| constexpr uint8_t | kleidos:: |
| GPIO1 function. | |
| constexpr uint8_t | kleidos:: |
| GPIO2 function. | |
| constexpr uint8_t | kleidos:: |
| The function field of a GPIO control register. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| Function 11x: the pin floats. 0x07, the power-on value, selects the same function. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| INTEN1: SOC warnings, gauge, battery temperature. | |
| constexpr uint8_t | kleidos:: |
| INTEN2: VBUS / battery insert-remove, power key. | |
| constexpr uint8_t | kleidos:: |
| INTEN3: charger and protection events. | |
| constexpr uint8_t | kleidos:: |
| INTSTS1: latches for INTEN1. | |
| constexpr uint8_t | kleidos:: |
| INTSTS2: latches for INTEN2 (power key). | |
| constexpr uint8_t | kleidos:: |
| constexpr std::array< uint8_t, 3 > | kleidos:: |
| Every IRQ enable register, in the order a power-off masks them. | |
| constexpr std::array< uint8_t, 3 > | kleidos:: |
| Every IRQ status latch, in the order a full clear writes them. | |
| constexpr uint8_t | kleidos:: |
| Masks every IRQ of one enable register. | |
| constexpr uint8_t | kleidos:: |
| Clears every bit of one status latch. | |
| constexpr uint8_t | kleidos:: |
| Short press (released before IRQLEVEL). | |
| constexpr uint8_t | kleidos:: |
| Long press (held for IRQLEVEL). | |
| constexpr uint8_t | kleidos:: |
| PWRON falling edge. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| Every power-key bit of INTEN2: the field the driver pins at begin(). | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| Latch read by the click poll. | |
| constexpr uint8_t | kleidos:: |
| Short + long press bits. | |
| constexpr uint8_t | kleidos:: |
| Field offset of the key bits. | |
| constexpr uint8_t | kleidos:: |
| IRQ_ | |
| constexpr uint8_t | kleidos:: |
| IRQLEVEL code 0: long press after 1 s. | |
| constexpr uint8_t | kleidos:: |
| OFFLEVEL code 0: a 4 s hold powers off. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| The pinned timing: 1 s long press, power off after a 4 s hold, 128 ms on. | |
| constexpr uint8_t | kleidos:: |
| The three timing fields (bits 5..0). | |
| constexpr uint8_t | kleidos:: |
| PWROFF_EN. | |
| constexpr uint8_t | kleidos:: |
| An OFFLEVEL hold acts on the PMIC. | |
| constexpr uint8_t | kleidos:: |
| Set: restart; clear: power off. | |
| constexpr uint8_t | kleidos:: |
| Key bits. | |
| constexpr uint8_t | kleidos:: |
| Hold to power off, no restart. | |
| constexpr uint8_t | kleidos:: |
| COMMON_ | |
| constexpr uint8_t | kleidos:: |
| Soft power-off command bit. | |
| constexpr uint8_t | kleidos:: |
| LDO_ | |
| constexpr uint8_t | kleidos:: |
| ALDO1 enable. | |
| constexpr uint8_t | kleidos:: |
| ALDO2 enable. | |
| constexpr uint8_t | kleidos:: |
| ALDO4 enable. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| Device type (0x50 on the M5StickS3). | |
| constexpr uint8_t | kleidos:: |
| Device model (0x20 on the M5StickS3). | |
| constexpr uint8_t | kleidos:: |
| Why the PMIC last powered on; 0 clears it. | |
| constexpr uint8_t | kleidos:: |
| Charger, DC/DC, LDO, 5 V boost, LED level. | |
| constexpr uint8_t | kleidos:: |
| Rails and PYG pins kept through a power-off. | |
| constexpr uint8_t | kleidos:: |
| I2C speed and idle-sleep timeout. | |
| constexpr uint8_t | kleidos:: |
| Write-only command port (key | opcode). | |
| constexpr uint8_t | kleidos:: |
| bit=1 selects output direction | |
| constexpr uint8_t | kleidos:: |
| bit=1 drives the PYG pin high | |
| constexpr uint8_t | kleidos:: |
| Live PYG input levels. | |
| constexpr uint8_t | kleidos:: |
| bit=0 selects push-pull output | |
| constexpr uint8_t | kleidos:: |
| PYG0..PYG3 pulls, two bits per pin. | |
| constexpr uint8_t | kleidos:: |
| PYG0..PYG3 function, two bits per pin. | |
| constexpr uint8_t | kleidos:: |
| PYG pins that wake the PMIC from power-off. | |
| constexpr uint8_t | kleidos:: |
| Wake edge per PYG pin (0 = falling). | |
| constexpr uint8_t | kleidos:: |
| Battery mV, low byte of a little-endian pair. | |
| constexpr uint8_t | kleidos:: |
| Timer count in s, LSB of four bytes. | |
| constexpr uint8_t | kleidos:: |
| Timer arm bit and action. | |
| constexpr uint8_t | kleidos:: |
| Write-only timer reload key port. | |
| constexpr uint8_t | kleidos:: |
| PYG level-change latches. | |
| constexpr uint8_t | kleidos:: |
| Power-source event latches. | |
| constexpr uint8_t | kleidos:: |
| Power-key event latches. | |
| constexpr uint8_t | kleidos:: |
| bit=1 masks the matching IRQ_STATUS1 bit | |
| constexpr uint8_t | kleidos:: |
| bit=1 masks the matching IRQ_STATUS2 bit | |
| constexpr uint8_t | kleidos:: |
| bit=1 masks the matching IRQ_STATUS3 bit | |
| constexpr uint8_t | kleidos:: |
| Power-key pressed state. | |
| constexpr uint8_t | kleidos:: |
| Key timings, single-click reset, download lock. | |
| constexpr uint8_t | kleidos:: |
| Double-click power-off disable. | |
| constexpr uint8_t | kleidos:: |
| POWER_CONFIG: charger on. | |
| constexpr uint8_t | kleidos:: |
| POWER_CONFIG: 3.3 V DC/DC on. | |
| constexpr uint8_t | kleidos:: |
| POWER_CONFIG: 3.3 V LDO on. | |
| constexpr uint8_t | kleidos:: |
| POWER_CONFIG: 5 V boost on. | |
| constexpr uint8_t | kleidos:: |
| POWER_CONFIG: LED_EN level. | |
| constexpr uint8_t | kleidos:: |
| HOLD_CONFIG: LDO kept on. | |
| constexpr uint8_t | kleidos:: |
| BUTTON_ | |
| constexpr uint8_t | kleidos:: |
| BUTTON_ | |
| constexpr uint8_t | kleidos:: |
| BUTTON_ | |
| constexpr uint8_t | kleidos:: |
| BUTTON_ | |
| constexpr uint8_t | kleidos:: |
| GPIO_INPUT: PYG0, 0 = charging. | |
| constexpr uint8_t | kleidos:: |
| PYG1: the IRQ output, to ESP32-S3 GPIO13. | |
| constexpr uint8_t | kleidos:: |
| PYG1's bit in a one-bit-per-pin register. | |
| constexpr uint8_t | kleidos:: |
| PYG2: enables the L3B rails (LCD, codec + microphone). | |
| constexpr uint8_t | kleidos:: |
| PYG2's bit in a one-bit-per-pin register. | |
| constexpr uint8_t | kleidos:: |
| PYG3: SHDN line of the AW8737A speaker amplifier. | |
| constexpr uint8_t | kleidos:: |
| PYG3's bit in a one-bit-per-pin register. | |
| constexpr uint8_t | kleidos:: |
| PYG4: the BMI270's INT1 output. | |
| constexpr uint8_t | kleidos:: |
| PYG4's bit in a one-bit-per-pin register. | |
| constexpr uint8_t | kleidos:: |
| Highest PM1 GPIO index (PYG4). | |
| constexpr uint8_t | kleidos:: |
| Width of one pin's field. | |
| constexpr uint8_t | kleidos:: |
| One pin's field, unshifted. | |
| constexpr uint8_t | kleidos:: |
| Pins whose fields share one register. | |
| constexpr uint8_t | kleidos:: |
| Function field: plain GPIO. | |
| constexpr uint8_t | kleidos:: |
| Function field: the PMIC's IRQ output. | |
| constexpr uint8_t | kleidos:: |
| Pull field: no pull. | |
| constexpr uint8_t | kleidos:: |
| Pull field: pull-up. | |
| constexpr uint8_t | kleidos:: |
| IRQ_STATUS3 / IRQ_MASK3: single click. | |
| constexpr uint8_t | kleidos:: |
| IRQ_STATUS3 / IRQ_MASK3: wake-source flag. | |
| constexpr uint8_t | kleidos:: |
| IRQ_STATUS3 / IRQ_MASK3: double click. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| IRQ_MASK1 with PYG4 alone let through: the BMI270's INT1 edges, nothing else. | |
| constexpr uint8_t | kleidos:: |
| IRQ_MASK3: every power-key event. | |
| constexpr uint8_t | kleidos:: |
| IRQ_MASK2: every power-source event. | |
| constexpr uint8_t | kleidos:: |
| An IRQ latch is cleared by writing 0. | |
| constexpr uint8_t | kleidos:: |
| WAKE_SRC is cleared by writing 0. | |
| constexpr uint8_t | kleidos:: |
| SYS_COMMAND key nibble. | |
| constexpr uint8_t | kleidos:: |
| SYS_COMMAND opcode: power off. | |
| constexpr uint8_t | kleidos:: |
| TIMER_CONFIG action: set the wake flag. | |
| constexpr uint8_t | kleidos:: |
| TIMER_CONFIG action: power on. | |
| constexpr uint8_t | kleidos:: |
| TIMER_CONFIG: start counting. | |
| constexpr uint8_t | kleidos:: |
| TIMER_KEY value that commits the timer. | |
Function Documentation
armKeyIrq() #
Route the power key's click to the PYG1 IRQ line, released.
Masks every PYG level change and power-source event, unmasks the key's click and double click (and the wake-source flag when wakeFlag is set), clears WAKE_SRC, configures PYG1 as a push-pull output driven high with its pull-up and gives it the IRQ function, then clears the three latches. Stops at the first step that fails.
- Parameters
-
Name Direction Meaning dev in The M5PM1 on the internal I2C bus. wakeFlag in Also raise the line on the wake-source flag, which the PMIC timer's "set wake flag" action sets (a self-test of the wake path).
- Return values
-
Value Meaning true Every step landed: the next key click pulls GPIO13 low. false A step failed; the line's state is unknown, so the caller reads it before arming it as a wake source.
- See also
- releaseKeyIrq, clearIrqLatches
armMotionIrq() #
Route PYG4's level changes (the IMU's INT1) to the PYG1 IRQ line.
Masks every PYG level change but PYG4's, every power-source event and every key event, gives PYG1 the pad setup and the IRQ function of armKeyIrq, then clears the three latches. Stops at the first step that fails.
- Parameters
-
Name Direction Meaning dev in The M5PM1 on the internal I2C bus.
- Return values
-
Value Meaning true Every step landed: the next edge on PYG4 pulls GPIO13 low. false A step failed; the caller releases the line.
- See also
- clearMotionIrq, releaseKeyIrq
clearIrqLatches() #
Clear the three IRQ latches (0x40-0x42), releasing the IRQ line.
Every latch is attempted even after a failed write.
- Parameters
-
Name Direction Meaning dev in The M5PM1 on the internal I2C bus.
- Return values
-
Value Meaning true All three latches were written. false At least one write failed.
clearIrqStatus() [1/2] #
Clear every AXP192 IRQ status latch.
Writes 0xFF to the five write-1-to-clear latches (0x44-0x47, 0x4D). The enable registers are left as they are. Every latch is attempted even after a failed write.
- Parameters
-
Name Direction Meaning dev in The AXP192 on the internal I2C bus.
- Return values
-
Value Meaning true All five latches were written. false At least one write failed.
- See also
- powerOff
clearIrqStatus() [2/2] #
Clear every AXP2101 IRQ status latch.
Writes 0xFF to the three write-1-to-clear latches (0x48-0x4A). The enable registers are left as they are. Every latch is attempted even after a failed write.
- Parameters
-
Name Direction Meaning dev in The AXP2101 on the internal I2C bus.
- Return values
-
Value Meaning true All three latches were written. false At least one write failed.
- See also
- powerOff
clearMotionIrq() #
Clear the PYG level-change latch (IRQ_STATUS1), which releases the IRQ line while armMotionIrq has it routed.
- Parameters
-
Name Direction Meaning dev in The M5PM1 on the internal I2C bus.
- Return values
-
Value Meaning true The latch was written. false The write failed.
configurePowerKey() [1/2] #
Pin the AXP192 power-key timing and its IRQ enables.
Sets POK_SET (0x36) to kPowerKeyTiming and the short- and long-press enables of INTEN3 (0x42), leaving its other enables untouched. A register that already holds the value is not rewritten. Both registers are attempted even when the first one fails.
- Parameters
-
Name Direction Meaning dev in The AXP192 on the internal I2C bus.
- Return values
-
Value Meaning true Both registers hold the pinned values. false An I2C transaction failed; that register keeps its old value.
- See also
- clearIrqStatus, powerOff
configurePowerKey() [2/2] #
Pin the AXP2101 power-key timing, its OFFLEVEL action and its IRQ enables.
Sets the timing fields of IRQ_ (0x27, reserved bits 7..6 preserved), makes an OFFLEVEL hold a power-off rather than a restart in PWROFF_EN (0x22, bit2 preserved), and sets the power-key field of INTEN2 (0x41) to short and long press only, leaving its VBUS and battery enables untouched. A register that already holds the value is not rewritten. All three registers are attempted even when one fails.
- Parameters
-
Name Direction Meaning dev in The AXP2101 on the internal I2C bus.
- Return values
-
Value Meaning true All three registers hold the pinned values. false An I2C transaction failed; that register keeps its old value.
- See also
- clearIrqStatus, powerOff
createPmic() #
Probes the PMIC at address, returning a ready singleton driver for the detected chip, or nullptr if none is present/
The AXP192 and AXP2101 share I2C address 0x34 — the factory probes kRegChipId to disambiguate. The IP5306 sits on 0x75. The PY32/M5PM1 PMIC is not exposed through this interface; it has its own Py32Pmic driver because its register layout and lifecycle are fundamentally different.
- Parameters
-
Name Direction Meaning address in I2C address to probe.
- Returns
- Pointer to the singleton PMIC driver, or nullptr.
gpioFieldReg() #
Register holding PYG pin's two-bit field, given the first of the pair.
- Parameters
-
Name Direction Meaning firstReg in GPIO_FUNC0 (0x16) or GPIO_PU_PD0 (0x14). pin in PM1 GPIO index (0..4).
- Returns
firstRegfor PYG0..PYG3, the next register for PYG4.
gpioFieldShift() #
Bit position of PYG pin's two-bit field in its register.
- Parameters
-
Name Direction Meaning pin in PM1 GPIO index (0..4).
- Returns
- 0, 2, 4 or 6.
parkUnusedOutputs() #
Put the AXP192 outputs a board never uses in their off state.
The chip keeps its registers across an ESP32 reset or a reflash, so an output the firmware never writes holds whatever the last firmware on the board left there. This writes each output named in outputs:
| Output | Register | Written |
|---|---|---|
| EXTEN | OUTPUT_ENABLE (0x12) bit6 | 0 |
| DC-DC2 | OUTPUT_ENABLE (0x12) bit4 | 0 |
| DC-DC3 | OUTPUT_ENABLE (0x12) bit1 | 0 |
| LDO3 | OUTPUT_ENABLE (0x12) bit3 | 0 |
| GPIO0 | GPIO0_CTL (0x90) bits2..0 | 11x, floating |
| GPIO1 | GPIO1_CTL (0x92) bits2..0 | 11x, floating |
| GPIO2 | GPIO2_CTL (0x93) bits2..0 | 101, held low |
The other bits of each register are preserved, a register that already holds the value is not rewritten, and every register is attempted even after one fails. Nothing is written unless the chip at dev identifies itself as an AXP192.
- Parameters
-
Name Direction Meaning dev in The AXP192 on the internal I2C bus. outputs in Which outputs the board leaves unused.
- Return values
-
Value Meaning true Every named output holds its off state (also when none is named). false The chip is not an AXP192, or an I2C transaction failed.
powerOff() [1/2] #
Switch the board off at the AXP192.
Clears every IRQ latch, then sets OFF_CTL (0x32) bit7, preserving the register's other bits. Every output except LDO1 (the RTC supply) drops, and the board returns only through a power-on source of the chip (its power key), as a cold boot. The power-off bit is not written when a latch could not be cleared.
- Parameters
-
Name Direction Meaning dev in The AXP192 on the internal I2C bus.
- Return values
-
Value Meaning true The power-off command was written. If execution continues afterwards, the board did not switch off. false A step failed and the power-off command was not written.
- See also
- clearIrqStatus
powerOff() [2/2] #
Switch the board off at the AXP2101.
Masks every IRQ enable (0x40-0x42), clears every IRQ latch, then sets COMMON_CONFIG (0x10) bit0, preserving the register's other bits. Every output except the RTC LDO drops, and the board returns only through a power-on source of the chip (its power key, or its IRQ pin pulled low), as a cold boot. The power-off bit is not written when an enable could not be masked or a latch could not be cleared. A power-off that lands does not keep the masks: the chip's next power-on restores INTEN1..3 to their power-on values (read back on the CoreS3 SE). One that does not land leaves them masked: the next configurePowerKey() (every begin()) re-enables only the short- and long-press bits of INTEN2, and every other enable of INTEN1..3 stays at 0 until the next PMIC power cycle.
- Parameters
-
Name Direction Meaning dev in The AXP2101 on the internal I2C bus.
- Return values
-
Value Meaning true The power-off command was written. If execution continues afterwards, the board did not switch off. false A step failed and the power-off command was not written.
- See also
- clearIrqStatus, configurePowerKey
releaseKeyIrq() #
Return PYG1 to the PMIC's reset state, a plain input.
Gives PYG1 the GPIO function first, which leaves no IRQ pin, so the PMIC clears its latches; then input direction, open-drain, no pull, output latch low. Every step is attempted even after a failed one.
- Parameters
-
Name Direction Meaning dev in The M5PM1 on the internal I2C bus.
- Return values
-
Value Meaning true Every step landed. false At least one I2C transaction failed.
- See also
- armKeyIrq
setGpioFunction() #
Set PYG pin's two-bit function field, preserving the other pins'.
- Parameters
-
Name Direction Meaning dev in The M5PM1 on the internal I2C bus. pin in PM1 GPIO index (0..4). function in kGpioFunctionGpioorkGpioFunctionIrq.
- Return values
-
Value Meaning true The field holds function.false pinorfunctionis out of range, or an I2C transaction failed.
setGpioLevel() #
Drive PYG pin high or low, and nothing else: its bit of the output register, preserving the other pins'.
For a pin already configured as a push-pull output with the GPIO function, which is how a line that toggles often is switched (the speaker amplifier's gate, raised and lowered around every sound): one read and one write, where the whole pad sequence is four of each.
- Parameters
-
Name Direction Meaning dev in The M5PM1 on the internal I2C bus. pin in PM1 GPIO index (0..4). high in True to drive the pin high.
- Return values
-
Value Meaning true The pin's output bit holds high.false pinis out of range, or an I2C transaction failed.
Variable Documentation
kBoardRailsEnable #
The CoreS3 SE's LDO rails, written in one go before the panel's first init: ALDO1 (VDD_1V8, the AW88298's DVDD), ALDO2 (VDDA_3V3, the ES7210's supplies), ALDO4 (VDD_3V3_SD, the microSD socket) and DLDO1 (VCC_BL, the backlight). The panel's own logic is on DC-DC1. ALDO3 (VDDCAM_3V3), BLDO1 (AVDD) and BLDO2 (DVDD) reach only the camera footprint the SE leaves empty, and CPUSLDO no pin of the board: the write switches all four off (M5Stack's schematic, boards repo cores3-se netlist). Their power-on state left ALDO3 on, and M5Stack's CoreS3 bring-up, which this value replaced, wrote 0xBF.
kBusOutEnableBit #
AW9523 P0.1 BUS_OUT_EN: high closes U14 (the boost's 5 V out to the bus) and opens U19 (the bus's 5 V in).
kDc2EnableBit #
DC-DC2 enable. On the StickC Plus boards and the Core2 v1.3 no part takes DC-DC2's output: the schematics leave its pins unconnected.
kDc3EnableBit #
0x02
kDldo1EnableBit #
DLDO1 enable (the CoreS3 SE's backlight).
kExtenEnableBit #
EXTEN pin: the board's 5 V boost enable. The datasheet (rev 1.1, p. 36) documents the switch at REG10H bit 2; REG12H bit 6 is the same switch: on the M5StickC Plus SE and the Core2 v1.3, writing either bit sets the other on read-back, and clearing either clears both; on the Core2 v1.3 either bit brings the boost's BUS_5V up on the AXP192's own VBUS input, read at 5.0-5.2 V. The datasheet pairs DC-DC2 the same way (REG10H bit 0, REG12H bit 4).
kGpioFunctionLow #
Function 101: the pin is driven low.
kIrqEnablePowerKeyLong #
Long-press IRQ enable.
kIrqEnablePowerKeyPress #
The pinned key enables: short and long press latch, the raw edges do not (nothing reads or clears them, so an enabled edge would keep the IRQ output asserted).
kIrqMask1All #
IRQ_MASK1: every PYG0..PYG4 level change
kIrqPowerKeyRising #
PWRON rising edge.
kOutputP0Init #
Port 0 pins begin() drives high.
kOutputP0InitMask #
Port 0 pins begin() writes: the ones it drives high, the amplifier gate and the two power-path switch enables.
kOutputP1Init #
Port 1 pins begin() drives high.
kPowerKeyOffLevel4s #
OFFLEVEL code 0: a 4 s hold powers off.
kPowerKeyOnLevel128Ms #
ONLEVEL code 0: 128 ms press powers on.
kRegAcinCurrent #
- 0x59[3:0]
kRegAcinVoltage #
- 0x57[3:0]
kRegBatteryChargeCurrent #
- 0x7B[3:0]
kRegBatteryDischargeCurrent #
- 0x7D[4:0]
kRegInternalTemp #
- 0x5F[3:0]
kRegIrqStatus3 #
INTSTS3: latches for INTEN3.
kRegIrqStatus5 #
INTSTS5: GPIO edges, timer timeout.
kRegTdieAdc #
- 0x3D
kRegVbusCurrent #
- 0x5D[3:0]
kRegVbusVoltage [1/2] #
- 0x5B[3:0]
kRegVbusVoltage [2/2] #
- 0x39
kUsbOtgEnableBit #
AW9523 P0.5 USB_OTG_EN: high closes U17 (5 V out to the USB-C port) and opens U18 (the port's VBUS into the PMIC), so a high level cuts the USB supply.