SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
axp517_interrupt.ino File Reference

@license MIT License More...

#include <Arduino.h>
#include <Wire.h>
#include <PmicDrv.hpp>
Include dependency graph for axp517_interrupt.ino:

Go to the source code of this file.

Classes

struct  StatusSnapshot
 

Macros

#define PMIC_SDA   3
 
#define PMIC_SCL   2
 
#define PMIC_IRQ   44
 

Functions

void onPmicIrq ()
 
const char * bc12TypeName (PmicBc12Base::PortType type)
 
const char * presentName (bool present)
 
const char * attachedName (bool attached)
 
const char * yesNoName (bool value)
 
const char * chargeName (const StatusSnapshot &snapshot)
 
void printHex16 (uint16_t value)
 
void printHex32 (uint32_t value)
 
StatusSnapshot readStatusSnapshot ()
 
void printEventItem (bool &first, const char *text)
 
void printPdAlertLine (uint16_t pdAlert)
 
void printPmicIrqLine (uint64_t status)
 
bool printBoolChange (const char *label, bool before, bool after, const char *(*name)(bool), bool &first)
 
bool printChargeChange (const StatusSnapshot &before, const StatusSnapshot &after, bool &first)
 
void printStatusLine (const char *label, bool anyChange)
 
void printSnapshot (const StatusSnapshot &snapshot)
 
void printSnapshotChanges (const StatusSnapshot &before, const StatusSnapshot &after)
 
bool handleIrqOnce ()
 
void drainIrq ()
 
void setup ()
 
void loop ()
 

Variables

PmicAXP517 pmic
 
volatile bool irqTriggered = false
 
StatusSnapshot lastSnapshot
 
uint32_t irqCount = 0
 

Detailed Description

@license MIT License

Copyright (c) 2026 lewis he

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author
Lewis He (lewis.nosp@m.he@o.nosp@m.utloo.nosp@m.k.co.nosp@m.m)
Date
2026-07-29

Definition in file axp517_interrupt.ino.

Macro Definition Documentation

◆ PMIC_IRQ

#define PMIC_IRQ   44

Definition at line 43 of file axp517_interrupt.ino.

◆ PMIC_SCL

#define PMIC_SCL   2

Definition at line 39 of file axp517_interrupt.ino.

◆ PMIC_SDA

#define PMIC_SDA   3

Definition at line 35 of file axp517_interrupt.ino.

Function Documentation

◆ attachedName()

const char * attachedName ( bool  attached)

Definition at line 99 of file axp517_interrupt.ino.

Referenced by printSnapshot(), and printSnapshotChanges().

◆ bc12TypeName()

◆ chargeName()

const char * chargeName ( const StatusSnapshot snapshot)

Definition at line 109 of file axp517_interrupt.ino.

References StatusSnapshot::chargeDone, and StatusSnapshot::charging.

Referenced by printChargeChange(), and printSnapshot().

◆ drainIrq()

void drainIrq ( )

Definition at line 490 of file axp517_interrupt.ino.

References handleIrqOnce(), and PMIC_IRQ.

Referenced by loop().

◆ handleIrqOnce()

◆ loop()

void loop ( )

Definition at line 581 of file axp517_interrupt.ino.

References drainIrq(), irqTriggered, and PMIC_IRQ.

◆ onPmicIrq()

void onPmicIrq ( )

Definition at line 75 of file axp517_interrupt.ino.

References irqTriggered.

Referenced by setup().

◆ presentName()

const char * presentName ( bool  present)

Definition at line 94 of file axp517_interrupt.ino.

Referenced by printSnapshot(), and printSnapshotChanges().

◆ printBoolChange()

bool printBoolChange ( const char *  label,
bool  before,
bool  after,
const char *(*)(bool)  name,
bool &  first 
)

Definition at line 309 of file axp517_interrupt.ino.

Referenced by printSnapshotChanges().

◆ printChargeChange()

bool printChargeChange ( const StatusSnapshot before,
const StatusSnapshot after,
bool &  first 
)

Definition at line 327 of file axp517_interrupt.ino.

References chargeName().

Referenced by printSnapshotChanges().

◆ printEventItem()

void printEventItem ( bool &  first,
const char *  text 
)

Definition at line 151 of file axp517_interrupt.ino.

Referenced by printPdAlertLine(), and printPmicIrqLine().

◆ printHex16()

void printHex16 ( uint16_t  value)

Definition at line 116 of file axp517_interrupt.ino.

Referenced by handleIrqOnce(), printSnapshot(), and printSnapshotChanges().

◆ printHex32()

void printHex32 ( uint32_t  value)

Definition at line 123 of file axp517_interrupt.ino.

Referenced by handleIrqOnce(), printSnapshot(), and printSnapshotChanges().

◆ printPdAlertLine()

◆ printPmicIrqLine()

◆ printSnapshot()

◆ printSnapshotChanges()

◆ printStatusLine()

void printStatusLine ( const char *  label,
bool  anyChange 
)

Definition at line 346 of file axp517_interrupt.ino.

Referenced by printSnapshotChanges().

◆ readStatusSnapshot()

◆ setup()

◆ yesNoName()

const char * yesNoName ( bool  value)

Definition at line 104 of file axp517_interrupt.ino.

Referenced by printSnapshot(), and printSnapshotChanges().

Variable Documentation

◆ irqCount

uint32_t irqCount = 0

Definition at line 73 of file axp517_interrupt.ino.

Referenced by handleIrqOnce().

◆ irqTriggered

volatile bool irqTriggered = false

Definition at line 54 of file axp517_interrupt.ino.

Referenced by loop(), and onPmicIrq().

◆ lastSnapshot

StatusSnapshot lastSnapshot

Definition at line 72 of file axp517_interrupt.ino.

Referenced by handleIrqOnce(), and setup().

◆ pmic

PmicAXP517 pmic

Definition at line 53 of file axp517_interrupt.ino.

Referenced by handleIrqOnce(), printPmicIrqLine(), readStatusSnapshot(), and setup().