boards: shields: add npm1304_ek shield

Add an nPM1304 EK shield, update samples/shields/npm1300_ek to support
both shields, improve the sample description.

Signed-off-by: Sergei Ovchinnikov <sergei.ovchinnikov@nordicsemi.no>
This commit is contained in:
Sergei Ovchinnikov 2025-07-08 09:26:13 +02:00 committed by Chris Friedt
parent 93117d98ad
commit f0f2b941f0
17 changed files with 348 additions and 113 deletions

View File

@ -22,10 +22,5 @@ Usage
*****
The shield can be used in any application by setting ``--shield npm1300_ek``
when invoking ``west build``. You can check :zephyr:code-sample:`npm1300_ek` for a
when invoking ``west build``. You can check :zephyr:code-sample:`npm13xx_ek` for a
comprehensive sample.
References
**********
TBC

View File

@ -0,0 +1,5 @@
# Copyright (c) 2025 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
config SHIELD_NPM1304_EK
def_bool $(shields_list_contains,npm1304_ek)

View File

@ -0,0 +1,30 @@
.. _npm1304_ek:
nPM1304 EK
##########
Overview
********
The nPM1304 EK lets you test different functions and features of the nPM1304
Power Management Integrated Circuit (PMIC).
Requirements
************
The nPM1304 EK board is not a direct fit into an Arduino connector. However,
the Zephyr shield is expected to be connected to the Arduino shield connectors.
That is, you need to connect the I2C lines to the ``arduino_i2c`` bus. This allows to
use the shield with any host board that supports the Arduino connector.
Usage
*****
To use the shield in any application, build it with the following command:
.. zephyr-app-commands::
:board: your_board
:shield: npm1304_ek
:goals: build
For a comprehensive sample, refer to :zephyr:code-sample:`npm13xx_ek`.

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2025 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/
#include <dt-bindings/regulator/npm13xx.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>
&arduino_i2c {
npm1304_ek_pmic: pmic@6b {
compatible = "nordic,npm1304";
reg = <0x6b>;
npm1304_ek_gpio: gpio-controller {
compatible = "nordic,npm1304-gpio";
gpio-controller;
#gpio-cells = <2>;
ngpios = <5>;
};
npm1304_ek_regulators: regulators {
compatible = "nordic,npm1304-regulator";
/* limits are set to min/max allowed values */
npm1304_ek_buck1: BUCK1 {
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <3300000>;
};
npm1304_ek_buck2: BUCK2 {
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <3300000>;
};
npm1304_ek_ldo1: LDO1 {
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <3300000>;
};
npm1304_ek_ldo2: LDO2 {
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <3300000>;
};
};
npm1304_ek_charger: charger {
compatible = "nordic,npm1304-charger";
term-microvolt = <4150000>;
term-warm-microvolt = <4000000>;
current-microamp = <4000>;
vbus-limit-microamp = <500000>;
thermistor-ohms = <10000>;
thermistor-beta = <3380>;
charging-enable;
};
npm1304_ek_buttons: buttons {
compatible = "gpio-keys";
pmic_button0: pmic_button_0 {
gpios = <&npm1304_ek_gpio 0 GPIO_ACTIVE_LOW>;
label = "Pmic button switch 0";
zephyr,code = <INPUT_KEY_0>;
};
pmic_button1: pmic_button_1 {
gpios = <&npm1304_ek_gpio 1 GPIO_ACTIVE_LOW>;
label = "Pmic button switch 1";
zephyr,code = <INPUT_KEY_1>;
};
pmic_button2: pmic_button_2 {
gpios = <&npm1304_ek_gpio 2 GPIO_ACTIVE_LOW>;
label = "Pmic button switch 2";
zephyr,code = <INPUT_KEY_2>;
};
};
npm1304_ek_leds: leds {
compatible = "nordic,npm1304-led";
nordic,led0-mode = "error";
nordic,led1-mode = "charging";
nordic,led2-mode = "host";
};
};
};

View File

@ -0,0 +1,11 @@
shield:
name: npm1304_ek
full_name: nPM1304 EK
vendor: nordic
supported_features:
- mfd
- input
- gpio
- led
- regulator
- sensor

View File

@ -304,6 +304,7 @@ REDIRECTS = [
('samples/sensor/max44009/README', 'samples/sensor/light_polling/README'),
('samples/sensor/wsen_hids/README', 'samples/sensor/sensor'),
('samples/sensor/wsen_itds/README', 'samples/sensor/sensor'),
('samples/shields/npm1300_ek/doc/index', 'samples/shields/npm13xx_ek/doc/index'),
('samples/subsys/video/capture/README', 'samples/drivers/video/capture/README'),
('samples/subsys/video/tcpserversink/README', 'samples/drivers/video/tcpserversink/README'),
('samples/subsys/video/video', 'samples/drivers/video/video'),

View File

@ -1,11 +0,0 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.20.0)
set(SHIELD npm1300_ek)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(npm1300_ek)
target_sources(app PRIVATE src/main.c)

View File

@ -1,71 +0,0 @@
.. zephyr:code-sample:: npm1300_ek
:name: nPM1300 EK
Interact with the nPM1300 PMIC using the shell interface.
Overview
********
This sample is provided for evaluation of the :ref:`npm1300_ek`.
The sample provides a shell interface to support the features of the
nPM1300 PMIC, including:
- Regulators (BUCK1/2, LDO1/2)
- GPIO
Requirements
************
The shield needs to be wired to a host board supporting the Arduino connector.
Examples and images to follow
Building and Running
********************
The sample is designed so that it can run on any platform. For example, when
building for the nRF52 DK, the following command can be used:
.. zephyr-app-commands::
:zephyr-app: samples/shields/npm1300_ek
:board: nrf52dk/nrf52832
:goals: build
:compact:
Note that this sample automatically sets ``SHIELD`` to ``npm1300_ek``. Once
flashed, you should boot into the shell interface. The ``regulator`` command is
provided to test the PMIC. Below you can find details for each subcommand.
Regulators
==========
The ``regulator`` shell interface provides several subcommand to test
the regulators embedded in the PMIC. Below you can find some command examples.
.. code-block:: bash
# list all the supported voltages by BUCK1
regulator vlist BUCK1
1.000 V
1.100 V
...
.. code-block:: bash
# enable BUCK2
regulator enable BUCK2
# disable BUCK2
regulator disable BUCK2
.. code-block:: bash
# set BUCK2 voltage to exactly 2V
regulator vset BUCK2 2V
# obtain the actual BUCK1 configured voltage
regulator vget BUCK1
1.800 V
# set BUCK1 voltage to a value between 2.35V and 2.45V
regulator set BUCK1 2.35V 2.45V
# obtain the actual BUCK1 configured voltage
regulator get BUCK1
2.400 V

View File

@ -1,12 +0,0 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
sample:
name: nPM1300 EK
tests:
sample.shields.npm1300_ek:
platform_allow: nrf52dk/nrf52832
harness: shield
tags: shield
extra_args: SHIELD=npm1300_ek
depends_on: arduino_i2c

View File

@ -0,0 +1,17 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.20.0)
if(SHIELD STREQUAL "npm1300_ek")
set(EXTRA_DTC_OVERLAY_FILE npm1300.overlay)
elseif(SHIELD STREQUAL "npm1304_ek")
set(EXTRA_DTC_OVERLAY_FILE npm1304.overlay)
else()
message(FATAL_ERROR "either npm1300_ek or npm1304_ek must be selected with --shield")
endif()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(npm13xx_ek)
target_sources(app PRIVATE src/main.c)

View File

@ -0,0 +1,10 @@
/*
* Copyright (C) 2023 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/
&i2c0_default {
group1 {
bias-pull-up;
};
};

View File

@ -0,0 +1,110 @@
.. zephyr:code-sample:: npm13xx_ek
:name: nPM13xx EK
Interact with an nPM1300 or nPM1304 PMIC using the shell interface and buttons.
Overview
********
This sample is provided for evaluation of :ref:`npm1300_ek` and :ref:`npm1304_ek`. The sample
demonstrates use of Dynamic Voltage Scaling (DVS) regulator API feature which allows to switch
between chosen voltage levels or regulator modes by toggling configured GPIOs with a single
regulator API call.
It also provides a shell interface to support the features of the nPM1300 and nPM1304 PMICs,
including:
- Regulators (BUCK1/2, LDO1/2)
- GPIO
Requirements
************
The shield needs to be wired to a host board featuring the Arduino I2C connector. PMIC's GPIO3 acts
as an interrupt output, pins GPIO1 and GPIO2 are configured to control regulator modes (controlled
by the MCU software through DVS).
In addition, PMIC's VDDIO pin should be connected to an appropriate voltage reference.
E.g. for an nRF52 Series DK the wiring is as follows:
+------------------+-------+-------+-------+-------+-------+-------+-----+
| nPM13xx EK pins | SDA | SCL | GPIO1 | GPIO2 | GPIO3 | VDDIO | GND |
+------------------+-------+-------+-------+-------+-------+-------+-----+
| nRF52 DK pins | P0.26 | P0.27 | P0.17 | P0.18 | P0.22 | VDD | GND |
+------------------+-------+-------+-------+-------+-------+-------+-----+
Building and Running
********************
The sample is designed so that it can run on any platform (references to host GPIOs connected to
the nPM13xx EK need to be updated in the ``npm13xx.overlay`` files to reflect chosen HW).
For example, when building for the nRF52 DK and the nPM1300 EK, the following command can be used:
.. zephyr-app-commands::
:zephyr-app: samples/shields/npm13xx_ek
:board: nrf52dk/nrf52832
:shield: npm1300_ek
:goals: build
:compact:
Testing
*******
After flashing the sample FW, you need to connect to the shell interface, where in case of
successful initialization you will see the nPM13xx PMIC status messages containing charger status
and battery voltage, current and temperature. Pressing and releasing the SHPHLD button on the EK
will generate interrupts and these events will also be printed in the shell.
Pressing a dedicated button on the host DK (Button 1 on an nRF52 Series DK) will cycle DVS states.
+-------------------------------------+----------------+---------------+---------------+
| **DVS state** (GPIO1 | GPIO2 level) | **BUCK2 mode** | **LDO1 mode** | **LDO2 mode** |
+-------------------------------------+----------------+---------------+---------------+
| **0** (HIGH | HIGH) | OFF | OFF | OFF |
+-------------------------------------+----------------+---------------+---------------+
| **1** (LOW | HIGH) | ON retention | OFF | OFF |
+-------------------------------------+----------------+---------------+---------------+
| **2** (HIGH | LOW) | OFF | ON | ON |
+-------------------------------------+----------------+---------------+---------------+
| **3** (LOW | LOW) | ON PWM | ON | ON |
+-------------------------------------+----------------+---------------+---------------+
.. note::
On an nRF52 Series DK, DVS pins are also used for the onboard LED1 and LED2, so you can observe
the DVS state pins visually: an LED lights up when the respective pin is LOW
Regulators
**********
The ``regulator`` shell interface provides several subcommand to test
the regulators embedded in the PMIC. Below you can find some command examples.
.. code-block:: console
# list all the supported voltages by BUCK1
uart:~$ regulator vlist BUCK1
1.000 V
1.100 V
...
.. code-block:: console
# enable BUCK2
uart:~$ regulator enable BUCK2
# disable BUCK2
uart:~$ regulator disable BUCK2
.. code-block:: console
# set BUCK2 voltage to exactly 2V
uart:~$ regulator vset BUCK2 2V
# obtain the actual BUCK1 configured voltage
uart:~$ regulator vget BUCK1
1.800 V
# set BUCK1 voltage to a value between 2.35V and 2.45V
uart:~$ regulator set BUCK1 2.35V 2.45V
# obtain the actual BUCK1 configured voltage
uart:~$ regulator get BUCK1
2.400 V

View File

@ -1,12 +1,7 @@
/*
* Copyright (C) 2023 Nordic Semiconductor ASA
* Copyright (C) 2025 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/
&i2c0_default {
group1 {
bias-pull-up;
};
};
&npm1300_ek_regulators {
dvs-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>,

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2025 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/
&npm1304_ek_regulators {
dvs-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>,
<&gpio0 18 GPIO_ACTIVE_LOW>;
};
&npm1304_ek_buck1 {
regulator-init-microvolt = <2000000>;
};
&npm1304_ek_buck2 {
regulator-init-microvolt = <3300000>;
retention-microvolt = <2500000>;
enable-gpio-config = <1 GPIO_ACTIVE_LOW>;
retention-gpio-config = <2 GPIO_ACTIVE_HIGH>;
pwm-gpio-config = <2 GPIO_ACTIVE_LOW>;
};
&npm1304_ek_ldo1 {
regulator-initial-mode = <NPM13XX_LDSW_MODE_LDO>;
enable-gpio-config = <2 GPIO_ACTIVE_LOW>;
};
&npm1304_ek_ldo2 {
regulator-initial-mode = <NPM13XX_LDSW_MODE_LDSW>;
enable-gpio-config = <2 GPIO_ACTIVE_LOW>;
};
&npm1304_ek_pmic {
host-int-gpios = <&gpio0 22 0>;
pmic-int-pin = <3>;
};

View File

@ -0,0 +1,17 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
sample:
name: nPM13xx EK
common:
platform_allow: nrf52dk/nrf52832
depends_on: arduino_i2c
tags:
- shield
- regulator
- sensor
tests:
sample.shields.npm1300_ek:
extra_args: SHIELD=npm1300_ek
sample.shields.npm1304_ek:
extra_args: SHIELD=npm1304_ek

View File

@ -19,15 +19,25 @@
#define SLEEP_TIME_MS 100
#define UPDATE_TIME_MS 2000
#if CONFIG_SHIELD_NPM1300_EK
#define SHIELD_LABEL(component) DT_NODELABEL(npm1300_ek_ ## component)
#elif CONFIG_SHIELD_NPM1304_EK
#define SHIELD_LABEL(component) DT_NODELABEL(npm1304_ek_ ## component)
#else
#error "either npm1300_ek or npm1304_ek shield should be selected"
#endif
#define NPM13XX_DEVICE(dev) DEVICE_DT_GET(SHIELD_LABEL(dev))
static const struct gpio_dt_spec button1 = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios);
static const struct device *regulators = DEVICE_DT_GET(DT_NODELABEL(npm1300_ek_regulators));
static const struct device *regulators = NPM13XX_DEVICE(regulators);
static const struct device *charger = DEVICE_DT_GET(DT_NODELABEL(npm1300_ek_charger));
static const struct device *charger = NPM13XX_DEVICE(charger);
static const struct device *leds = DEVICE_DT_GET(DT_NODELABEL(npm1300_ek_leds));
static const struct device *leds = NPM13XX_DEVICE(leds);
static const struct device *pmic = DEVICE_DT_GET(DT_NODELABEL(npm1300_ek_pmic));
static const struct device *pmic = NPM13XX_DEVICE(pmic);
void configure_ui(void)
{
@ -53,9 +63,14 @@ void configure_ui(void)
}
}
static void event_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins)
static void event_callback(const struct device *dev, struct gpio_callback *cb, uint32_t events)
{
printk("Event detected\n");
if (events & BIT(NPM13XX_EVENT_SHIPHOLD_PRESS)) {
printk("SHPHLD pressed\n");
}
if (events & BIT(NPM13XX_EVENT_SHIPHOLD_RELEASE)) {
printk("SHPHLD released\n");
}
}
void configure_events(void)
@ -68,7 +83,8 @@ void configure_events(void)
/* Setup callback for shiphold button press */
static struct gpio_callback event_cb;
gpio_init_callback(&event_cb, event_callback, BIT(NPM13XX_EVENT_SHIPHOLD_PRESS));
gpio_init_callback(&event_cb, event_callback, BIT(NPM13XX_EVENT_SHIPHOLD_PRESS) |
BIT(NPM13XX_EVENT_SHIPHOLD_RELEASE));
mfd_npm13xx_add_callback(pmic, &event_cb);
}