|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
AXP517 GPIO module (REG 0x11). More...
#include <AXP517Gpio.hpp>
Public Types | |
| enum class | OutputSource : uint8_t { ByReg11 = 0 , PdIrq = 1 } |
| Hardware source selected for the GPIO output path. More... | |
Public Types inherited from PmicGpioBase | |
| 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 | |
| AXP517Gpio (AXP517Core &core) | |
| Construct an AXP517 GPIO driver. | |
| ~AXP517Gpio ()=default | |
| uint8_t | getPinCount () const override |
| Get number of GPIO pins (1) | |
| Status | setDirection (uint8_t pin, Direction dir) override |
| Set GPIO pin direction. | |
| Direction | getDirection (uint8_t pin) override |
| Get GPIO pin direction. | |
| Status | setDrive (uint8_t pin, DriveType drive) override |
| Set GPIO pin drive type. | |
| DriveType | getDrive (uint8_t pin) override |
| Get GPIO pin drive type. | |
| Status | read (uint8_t pin, bool &high) override |
| Read input level. | |
| Status | write (uint8_t pin, Level level) override |
| Set output level. | |
| bool | setOutputSource (uint8_t pin, OutputSource src) |
| Select GPIO output source. | |
| OutputSource | getOutputSource (uint8_t pin) |
| Get current GPIO output source. | |
| int | readRaw () |
| Read raw REG11 for debug. | |
Public Member Functions inherited from PmicGpioBase | |
| 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 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. | |
Additional Inherited Members | |
Static Public Member Functions inherited from PmicGpioBase | |
| static constexpr bool | isOk (Status s) |
AXP517 GPIO module (REG 0x11).
From manual:
Notes:
Definition at line 60 of file AXP517Gpio.hpp.
|
strong |
Hardware source selected for the GPIO output path.
| Enumerator | |
|---|---|
| ByReg11 | by reg11[1:0] |
| PdIrq | PD_IRQ. |
Definition at line 67 of file AXP517Gpio.hpp.
|
explicit |
Construct an AXP517 GPIO driver.
| core | Shared AXP517 register transport. |
Definition at line 8 of file AXP517Gpio.cpp.
|
default |
|
overridevirtual |
Get GPIO pin direction.
| pin | GPIO pin number (must be 0) |
Implements PmicGpioBase.
Definition at line 30 of file AXP517Gpio.cpp.
References PmicGpioBase::Input, PmicGpioBase::Output, and readRaw().
Referenced by write().
|
overridevirtual |
Get GPIO pin drive type.
| pin | GPIO pin number (must be 0) |
Implements PmicGpioBase.
Definition at line 45 of file AXP517Gpio.cpp.
References PmicGpioBase::OpenDrain, PmicGpioBase::PushPull, and readRaw().
Referenced by write().
| AXP517Gpio::OutputSource AXP517Gpio::getOutputSource | ( | uint8_t | pin | ) |
Get current GPIO output source.
| pin | GPIO pin number (must be 0) |
Definition at line 61 of file AXP517Gpio.cpp.
References ByReg11, PdIrq, and readRaw().
Referenced by write().
|
overridevirtual |
Get number of GPIO pins (1)
Implements PmicGpioBase.
Definition at line 13 of file AXP517Gpio.cpp.
|
overridevirtual |
Read input level.
| pin | GPIO pin number (must be 0) |
| high | Reference to store the read level (true = high, false = low) |
Implements PmicGpioBase.
Definition at line 71 of file AXP517Gpio.cpp.
References PmicGpioBase::Failed, PmicGpioBase::InvalidPin, PmicGpioBase::Ok, and readRaw().
| int AXP517Gpio::readRaw | ( | ) |
Read raw REG11 for debug.
Definition at line 18 of file AXP517Gpio.cpp.
References axp517_regs::ctrl::GPIO_CFG, and SensorCommWrapper::readReg().
Referenced by getDirection(), getDrive(), getOutputSource(), and read().
|
overridevirtual |
Set GPIO pin direction.
| pin | GPIO pin number (must be 0) |
| dir | Direction (Input or Output) |
Implements PmicGpioBase.
Definition at line 23 of file AXP517Gpio.cpp.
References PmicGpioBase::Failed, axp517_regs::ctrl::GPIO_CFG, PmicGpioBase::InvalidPin, PmicGpioBase::Ok, PmicGpioBase::Output, and SensorCommWrapper::updateBits().
|
overridevirtual |
Set GPIO pin drive type.
| pin | GPIO pin number (must be 0) |
| drive | Drive type (PushPull or OpenDrain) |
Implements PmicGpioBase.
Definition at line 38 of file AXP517Gpio.cpp.
References PmicGpioBase::Failed, axp517_regs::ctrl::GPIO_CFG, PmicGpioBase::InvalidPin, PmicGpioBase::Ok, PmicGpioBase::OpenDrain, and SensorCommWrapper::updateBits().
| bool AXP517Gpio::setOutputSource | ( | uint8_t | pin, |
| OutputSource | src | ||
| ) |
Select GPIO output source.
| pin | GPIO pin number (must be 0) |
| src | Output source: OutputSource::ByReg11 - output controlled by write() OutputSource::PdIrq - output follows PD_IRQ hardware signal |
| true | on success, false if pin != 0 or on register access failure. |
Definition at line 53 of file AXP517Gpio.cpp.
References axp517_regs::ctrl::GPIO_CFG, PdIrq, and SensorCommWrapper::updateBits().
Referenced by configurePdIrqOutput().
|
overridevirtual |
Set output level.
| pin | GPIO pin number (must be 0) |
| level | Level to set (HiZ, Low, or High) |
Implements PmicGpioBase.
Definition at line 82 of file AXP517Gpio.cpp.
References PmicGpioBase::Failed, getDirection(), getDrive(), getOutputSource(), axp517_regs::ctrl::GPIO_CFG, PmicGpioBase::High, PmicGpioBase::HiZ, PmicGpioBase::InvalidPin, level, PmicGpioBase::Low, PmicGpioBase::Ok, PmicGpioBase::OpenDrain, PmicGpioBase::Output, PdIrq, and SensorCommWrapper::updateBits().