Nordic nPM1300 PMIC core.
More...
Nordic nPM1300 PMIC core.
The core is a struct pbl_npm1300 device on its I2C bus. It owns the register access, under a lock so its cells cannot interleave read-modify-write sequences, and brings its cells up from its init. Each cell is a child device in its own subsystem: the charger (nPM1300 charger), the GPIO port (nPM1300 GPIO) and one regulator per rail (nPM1300 regulators).
{.peripheral = hwp_gpio1, .gpio_pin = 26});
#define PBL_NPM1300_GPIO_DEFINE(sym, _pmic)
Define the GPIO port.
Definition npm1300.h:50
#define PBL_NPM1300_DEFINE(sym, _bus, _addr)
Define the core.
Definition npm1300.h:61
const Npm1300Config NPM1300_CONFIG
The board's charger configuration.
#define PBL_NPM1300_CHARGER_DEFINE(sym, _pmic, _cfg, _irq)
Define the charger.
Definition npm1300.h:90
#define PBL_NPM1300_REGULATOR_DEFINE(sym, _name, _pmic, _rail, _voltage_mv, _ldo, _always_on)
Define a PMIC rail.
Definition npm1300.h:57
@ PBL_NPM1300_LDSW2
Load switch / LDO 2.
Definition npm1300.h:27
◆ pbl_npm1300
| Data Fields |
|
struct pbl_device |
dev |
Device, child of the I2C bus. |
|
struct pbl_i2c_dev |
i2c |
I2C device. |
|
struct pbl_npm1300_state * |
state |
Runtime state. |
◆ PBL_NPM1300_DEFINE
| #define PBL_NPM1300_DEFINE |
( |
|
sym, |
|
|
|
_bus, |
|
|
|
_addr |
|
) |
| |
Value:
static struct pbl_npm1300_state sym##_npm1300_state; \
.
state = &sym##_npm1300_state, \
}; \
PBL_DEVICE_REGISTER(sym, &sym.
dev)
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:109
#define PBL_DEVICE_INIT(sym, _name, _init, _parent, _deps)
Initializer for the struct pbl_device of device instance sym.
Definition device.h:142
#define PBL_I2C_DEV(_bus, _addr)
Initializer for a struct pbl_i2c_dev.
Definition i2c.h:135
struct pbl_device dev
Device, child of the I2C bus.
Definition npm1300.h:43
nPM1300 core.
Definition npm1300.h:41
struct pbl_device_state * state
Runtime state.
Definition device.h:98
Define the core.
- Parameters
-
| sym | Symbol of the core. |
| _bus | I2C bus. |
| _addr | 7-bit I2C address. |
◆ pbl_npm1300_from_cell()
◆ pbl_npm1300_lock()
| void pbl_npm1300_lock |
( |
const struct pbl_npm1300 * |
pmic | ) |
|
Lock the registers, around a read-modify-write sequence.
Single accesses lock on their own.
- Parameters
-
◆ pbl_npm1300_read()
| int pbl_npm1300_read |
( |
const struct pbl_npm1300 * |
pmic, |
|
|
uint16_t |
reg, |
|
|
uint8_t * |
val |
|
) |
| |
Read a register.
- Parameters
-
| pmic | Core. |
| reg | Register address. |
| [out] | val | Register value. |
- Returns
- 0 on success, or a negative errno.
◆ pbl_npm1300_unlock()
| void pbl_npm1300_unlock |
( |
const struct pbl_npm1300 * |
pmic | ) |
|
Unlock the registers.
- Parameters
-
◆ pbl_npm1300_write()
| int pbl_npm1300_write |
( |
const struct pbl_npm1300 * |
pmic, |
|
|
uint16_t |
reg, |
|
|
uint8_t |
val |
|
) |
| |
Write a register.
- Parameters
-
| pmic | Core. |
| reg | Register address. |
| val | Value. |
- Returns
- 0 on success, or a negative errno.