SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
AXP2101Core.cpp
Go to the documentation of this file.
1
31#include "../../../SensorBuildOpt.h"
32#if !SENSORLIB_EXCLUDE_PMIC_AXP2101
33
34#include "AXP2101Core.hpp"
35#include "AXP2101Regs.hpp"
36
37bool AXP2101Core::enableModule(Module module, bool enable)
38{
39 switch (module) {
46 case Module::GAUGE:
62 default:
63 return false;
64 }
65}
66
96
98{
99 // Bit 5:4 : 00 = IRQ only, 01 = IRQ + reset, 10 = IRQ + reset + pull down PWROK, 11 = IRQ + reset after power off
100 return updateBits(axp2101_regs::ctrl::WDT_CTRL, static_cast<uint8_t>(config), 0x30);
101}
102
103bool AXP2101Core::initImpl(uint8_t param)
104{
106 if (id < 0 || id != axp2101_regs::CHIP_ID) {
107 return false;
108 }
110 if (val >= 0) {
111 val &= 0xF0;
114 }
115 return true;
116}
117
118#endif
@license MIT License
WatchdogConfig
Watchdog timer configuration options.
bool isModuleEnabled(Module module)
Check whether an internal module is enabled.
bool enableModule(Module module, bool enable)
Enable or disable an internal functional module.
bool setWatchdogConfig(WatchdogConfig config)
Set watchdog timer configuration.
Module
Identifiers for AXP2101 internal functional modules.
@ TS_MEASURE
TS pin ADC (REG 0x30 bit 1)
@ CELL_CHARGE
Cell battery charger (REG 0x18 bit 1)
@ TEMP_MEASURE
Die temperature ADC (REG 0x30 bit 4)
@ GAUGE
Fuel gauge (REG 0x18 bit 3)
@ VSYS_MEASURE
VSYS voltage ADC (REG 0x30 bit 3)
@ BAT_VOLT_MEASURE
Battery voltage ADC (REG 0x30 bit 0)
@ BTN_CHARGE
Button/backup battery charger (REG 0x18 bit 2)
@ BAT_DETECT
Battery detection (REG 0x68 bit 0)
@ VBUS_MEASURE
VBUS voltage ADC (REG 0x30 bit 2)
@ WATCHDOG
Watchdog timer (REG 0x18 bit 0)
@ GENERAL_ADC
General-purpose ADC (REG 0x30 bit 5)
bool clrRegBit(uint8_t reg, uint8_t bit)
bool getRegBit(uint8_t reg, uint8_t bit)
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)
bool setRegBit(uint8_t reg, uint8_t bit)
static constexpr uint8_t CHANNEL_CTRL
static constexpr uint8_t IC_TYPE
static constexpr uint8_t BAT_DETECT_CTRL
static constexpr uint8_t WDT_CTRL
static constexpr uint8_t MODULE_EN
static constexpr uint8_t TS_PIN_CTRL
static constexpr uint8_t CHIP_ID