1#include "../../../SensorBuildOpt.h"
2#if !SENSORLIB_EXCLUDE_PMIC_AXP202
17uint8_t AXP202Gpio::getCtrlReg(uint8_t pin)
const
30 uint8_t reg = getCtrlReg(pin);
51 v = (v & 0xF8) | 0x00;
56 v = (v & 0xF8) | 0x04;
62 uint8_t reg = getCtrlReg(pin);
66 uint8_t func = val & 0x07;
92 uint8_t reg = getCtrlReg(pin);
98 high = (val >> (pin + 4)) & 0x01;
105 high = !(val & 0x01);
111 uint8_t reg = getCtrlReg(pin);
120 case Level::Low: val = (val & 0xF8) | 0x00;
break;
121 case Level::High: val = (val & 0xF8) | 0x01;
break;
122 case Level::HiZ: val = (val & 0xF8) | 0x07;
break;
142 uint8_t reg = getCtrlReg(pin);
153 uint8_t reg = getCtrlReg(pin);
154 if (reg == 0)
return 0xFF;
156 if (v < 0)
return 0xFF;
161 return (v & 0x04) ? 0x01 : 0x00;
AXP202Gpio(AXP202Core &core)
Construct AXP202 GPIO interface.
DriveType getDrive(uint8_t pin) override
Get GPIO pin drive type.
Status setDrive(uint8_t pin, DriveType drive) override
Set GPIO pin drive type.
uint8_t getFunction(uint8_t pin) override
Get current GPIO pin function mode.
Direction getDirection(uint8_t pin) override
Get GPIO pin direction.
uint8_t getPinCount() const override
Get number of GPIO pins (4: GPIO0-GPIO3)
Status setDirection(uint8_t pin, Direction dir) override
Set GPIO pin direction.
Status read(uint8_t pin, bool &high) override
Read digital level from a GPIO pin.
Status setFunction(uint8_t pin, uint8_t func) override
Set GPIO pin function mode.
Status write(uint8_t pin, Level level) override
Write digital level to a GPIO pin.
DriveType
GPIO drive type.
@ OpenDrain
Open-drain output: only pulls low, high-impedance for high.
@ PushPull
Push-pull output: actively drives high or low.
Level
Output level control.
@ Low
Logic low (active drive low or open-drain pulled low)
@ High
Logic high (active drive high)
@ HiZ
High-impedance (input mode or open-drain not pulling low)
Direction
GPIO pin direction.
@ Output
Configure pin as output (drive external circuits)
@ Input
Configure pin as input (read external signals)
Status
GPIO operation status code.
int readReg(uint8_t reg) const
int writeReg(uint8_t reg, uint8_t val)
int updateBits(uint8_t reg, uint8_t mask, uint8_t value_shifted)
static constexpr uint8_t GPIO0_CTL
static constexpr uint8_t GPIO1_CTL
static constexpr uint8_t GPIO2_CTL
static constexpr uint8_t GPIO3_CTL
static constexpr uint8_t GPIO012_SIGNAL