|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <PmicGpioBase.hpp>
Public Types | |
| enum class | Direction : uint8_t { Input = 0 , Output = 1 } |
| GPIO pin direction. More... | |
| enum class | DriveType : uint8_t { PushPull = 0 , OpenDrain = 1 , Keep = 0xFF } |
| GPIO drive type. More... | |
| enum class | Level : uint8_t { Low = 0 , HiZ = 1 , High = 2 } |
| Output level control. More... | |
| enum class | Pull : uint8_t { None = 0 , Down = 1 , Up = 2 , Keep = 0xFF } |
| Internal pull resistor configuration. More... | |
| enum class | Status : uint8_t { Ok = 0 , InvalidPin = 1 , Failed = 2 } |
| GPIO operation status code. More... | |
Public Member Functions | |
| virtual | ~PmicGpioBase ()=default |
| Virtual destructor. | |
| Status | pinMode (uint8_t pin, Direction dir, DriveType drive=DriveType::Keep, Pull pull=Pull::Keep, uint8_t func=0xFF) |
| Configure a pin with a single high-level call. | |
| virtual uint8_t | getPinCount () const =0 |
| Get number of GPIO pins supported by this PMIC. | |
| virtual Status | setDirection (uint8_t pin, Direction dir)=0 |
| Set GPIO pin direction. | |
| virtual Direction | getDirection (uint8_t pin)=0 |
| Get current GPIO pin direction. | |
| virtual Status | setDrive (uint8_t pin, DriveType drive)=0 |
| Set GPIO drive type. | |
| virtual DriveType | getDrive (uint8_t pin)=0 |
| Get current GPIO drive type. | |
| virtual Status | read (uint8_t pin, bool &high)=0 |
| Read input level. | |
| virtual Status | write (uint8_t pin, Level level)=0 |
| Set output level. | |
| virtual Status | setFunction (uint8_t pin, uint8_t func) |
| Set GPIO pin function mode (chip-specific multiplexing) | |
| virtual uint8_t | getFunction (uint8_t pin) |
| Get current GPIO pin function mode. | |
| virtual Status | setPull (uint8_t pin, Pull pull) |
| Set internal pull resistor. | |
| virtual Pull | getPull (uint8_t pin) |
| Get current internal pull resistor setting. | |
Static Public Member Functions | |
| static constexpr bool | isOk (Status s) |
Definition at line 34 of file PmicGpioBase.hpp.
|
strong |
GPIO pin direction.
| Enumerator | |
|---|---|
| Input | Configure pin as input (read external signals) |
| Output | Configure pin as output (drive external circuits) |
Definition at line 45 of file PmicGpioBase.hpp.
|
strong |
GPIO drive type.
| Enumerator | |
|---|---|
| PushPull | Push-pull output: actively drives high or low. |
| OpenDrain | Open-drain output: only pulls low, high-impedance for high. |
| Keep | Keep current drive type (do not change) |
Definition at line 53 of file PmicGpioBase.hpp.
|
strong |
Output level control.
Some PMICs support Hi-Z/Low/High; others only Low/Hi-Z for open-drain.
| Enumerator | |
|---|---|
| Low | Logic low (active drive low or open-drain pulled low) |
| HiZ | High-impedance (input mode or open-drain not pulling low) |
| High | Logic high (active drive high) |
Definition at line 64 of file PmicGpioBase.hpp.
|
strong |
Internal pull resistor configuration.
| Enumerator | |
|---|---|
| None | No pull resistor. |
| Down | Pull-down enabled. |
| Up | Pull-up enabled. |
| Keep | Keep current pull setting (do not change) |
Definition at line 73 of file PmicGpioBase.hpp.
|
strong |
GPIO operation status code.
| Enumerator | |
|---|---|
| Ok | |
| InvalidPin | |
| Failed | |
Definition at line 83 of file PmicGpioBase.hpp.
|
virtualdefault |
Virtual destructor.
|
pure virtual |
Get current GPIO pin direction.
| pin | GPIO pin number |
Implemented in AXP192Gpio, AXP202Gpio, and AXP517Gpio.
|
pure virtual |
Get current GPIO drive type.
| pin | GPIO pin number |
Implemented in AXP192Gpio, AXP202Gpio, and AXP517Gpio.
Referenced by pinMode().
|
inlinevirtual |
Get current GPIO pin function mode.
| pin | GPIO pin number |
Reimplemented in AXP192Gpio, and AXP202Gpio.
Definition at line 211 of file PmicGpioBase.hpp.
|
pure virtual |
Get number of GPIO pins supported by this PMIC.
Implemented in AXP192Gpio, AXP202Gpio, and AXP517Gpio.
|
inlinevirtual |
Get current internal pull resistor setting.
| pin | GPIO pin number |
Reimplemented in AXP192Gpio.
Definition at line 239 of file PmicGpioBase.hpp.
References None.
Referenced by pinMode().
|
inlinestaticconstexpr |
Definition at line 89 of file PmicGpioBase.hpp.
References Ok.
Referenced by configurePdIrqOutput(), pinMode(), and AXP192Gpio::setPwm().
|
inline |
Configure a pin with a single high-level call.
| pin | GPIO pin number |
| dir | Direction |
| drive | Drive type. Use DriveType::Keep to skip drive configuration. |
Definition at line 100 of file PmicGpioBase.hpp.
References getDrive(), getPull(), isOk(), Keep, Ok, setDrive(), and setPull().
|
pure virtual |
Read input level.
| pin | GPIO pin number |
| high | Reference to store the read level (true = high, false = low) |
Implemented in AXP192Gpio, AXP202Gpio, and AXP517Gpio.
Set GPIO pin direction.
| pin | GPIO pin number (if multiple pins are supported by the PMIC) |
| dir | Direction to set (Input or Output) |
Implemented in AXP192Gpio, AXP202Gpio, and AXP517Gpio.
Set GPIO drive type.
| pin | GPIO pin number |
| drive | Drive type (PushPull or OpenDrain) |
Implemented in AXP192Gpio, AXP202Gpio, and AXP517Gpio.
Referenced by pinMode().
|
inlinevirtual |
Set GPIO pin function mode (chip-specific multiplexing)
| pin | GPIO pin number |
| func | Function mode value (chip-specific, see chip header for valid values) |
Reimplemented in AXP192Gpio, and AXP202Gpio.
Definition at line 199 of file PmicGpioBase.hpp.
References Failed.
Set internal pull resistor.
| pin | GPIO pin number |
| pull | Pull configuration (None, Down, or Up) |
Reimplemented in AXP192Gpio.
Definition at line 227 of file PmicGpioBase.hpp.
References Failed.
Referenced by pinMode().
Set output level.
| pin | GPIO pin number |
| level | Level to set (HiZ, Low, or High) |
Implemented in AXP192Gpio, AXP202Gpio, and AXP517Gpio.