Skip to content

Commit 129d7fc

Browse files
seov-nordicnordicjm
authored andcommitted
samples: pmic: npm2100_one_button
nPM2100 sample application demostrating power mode control and user interractions through a single button connected the PMIC. Signed-off-by: Sergei Ovchinnikov <[email protected]>
1 parent e6671b5 commit 129d7fc

File tree

10 files changed

+455
-0
lines changed

10 files changed

+455
-0
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ Peripheral samples
564564
PMIC samples
565565
------------
566566

567+
* Added the :ref:`npm2100_one_button` sample that demonstrates how to support wake-up, shutdown,
568+
and user interactions through a single button connected to the nPM2100 PMIC.
569+
567570
* Added the :ref:`npm2100_fuel_gauge` sample that demonstrates how to calculate the battery state of charge of primary cell batteries using the :ref:`nrfxlib:nrf_fuel_gauge`.
568571

569572
* :ref:`npm1300_fuel_gauge` sample:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7+
8+
project(npm2100_one_button)
9+
target_sources(app PRIVATE src/main.c)
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
.. _npm2100_one_button:
2+
3+
nPM2100: One button
4+
###################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The One button sample demonstrates how to support wake-up, shutdown, and user interactions
11+
through a single button connected to the `nPM2100 PMIC <nPM2100 product website_>`_.
12+
13+
Requirements
14+
************
15+
16+
The sample supports the following development kits:
17+
18+
.. table-from-sample-yaml::
19+
20+
The sample also requires an nPM2100 Evaluation Kit (EK) that you need to connect to the
21+
development kit as described in `Wiring`_.
22+
23+
Overview
24+
********
25+
26+
The **SHPHLD** button of the nPM2100 EK controls the device state.
27+
The sample controls an LED and the power mode based on the button press duration.
28+
29+
The **GPIO1** pin of the nPM2100 EK is configured as an interrupt output and used to signal button press events to the host.
30+
31+
.. _npm2100_one_button_wiring:
32+
33+
Wiring
34+
******
35+
36+
With this configuration, the nPM2100 EK is wired to supply power to the DK.
37+
This ensures that the TWI communication is at compatible voltage levels, and represents a realistic use case for the nPM2100 PMIC.
38+
39+
.. note::
40+
41+
To prevent leakage currents and program the DK, do not remove the USB connection.
42+
43+
Unplug the battery from the nPM2100 EK and set the DK power switch to "OFF" while
44+
applying the wiring.
45+
If you have issues communicating with the DK or programming it after applying the wiring, try to power cycle the DK and EK.
46+
47+
To connect your DK to the nPM2100 EK, complete the following steps:
48+
49+
#. Prepare the DK for being powered by the nPM2100 EK:
50+
51+
.. tabs::
52+
53+
.. group-tab:: nRF52840 and nRF5340 DKs
54+
55+
* Set switch **SW9** ("nRF power source") to position "VDD".
56+
* Set switch **SW10** ("VEXT -> VnRF") to position "ON".
57+
58+
.. group-tab:: nRF54L15 DK
59+
60+
* Remove jumper from **P6** ("VDDM CURRENT MEASURE").
61+
62+
#. Connect the TWI interface and power supply between the chosen DK and the nPM2100 EK
63+
as described in the following table:
64+
65+
.. list-table:: nPM2100 EK connections.
66+
:widths: auto
67+
:header-rows: 1
68+
69+
* - nPM2100 EK pins
70+
- nRF52840 DK pins
71+
- nRF5340 DK pins
72+
- nRF54L15 DK pins
73+
* - SDA
74+
- P0.26
75+
- P1.02
76+
- P1.11
77+
* - SCL
78+
- P0.27
79+
- P1.03
80+
- P1.12
81+
* - GPIO1
82+
- P1.12
83+
- P1.12
84+
- P1.08
85+
* - VOUT
86+
- P21 External supply +
87+
- P21 External supply +
88+
- P6 VDDM current measure, VDD:nRF pin
89+
* - GND
90+
- GND / P21 External supply -
91+
- GND / P21 External supply -
92+
- GND
93+
94+
#. Make the following connections on the nPM2100 EK:
95+
96+
* Remove the USB power supply from the **J4** connector.
97+
* On the **P6** pin header, connect pins 1 and 2 with a jumper.
98+
* On the **BOOTMON** pin header, select **OFF** with a jumper.
99+
* On the **VSET** pin header, select **3.0V** with a jumper.
100+
* On the **VBAT SEL** switch, select **VBAT** position.
101+
* Connect a battery board to the **BATTERY INPUT** connector.
102+
103+
.. note::
104+
105+
When using the :ref:`zephyr:nrf54l15dk_nrf54l15`, the nPM2100 **GPIO1** interrupt
106+
pin assignment uses the **BUTTON 2** pin of the DK.
107+
108+
Building and running
109+
********************
110+
111+
.. |sample path| replace:: :file:`samples/pmic/native/npm2100_one_button`
112+
113+
.. include:: /includes/build_and_run.txt
114+
115+
Testing
116+
*******
117+
118+
|test_sample|
119+
120+
#. |connect_kit|
121+
#. |connect_terminal|
122+
123+
If the initialization was successful, the terminal displays the following message with status information:
124+
125+
.. code-block:: console
126+
127+
PMIC device ok
128+
129+
The following table describes the output and outcome of button presses:
130+
131+
.. _table::
132+
:widths: auto
133+
134+
============ ============ ===================================
135+
Duration Log output Outcome
136+
============ ============ ===================================
137+
< 1 sec Short press Sample flashes **LED** at 5 Hz
138+
1 - 5 sec Medium press Sample flashes **LED** at 1 Hz
139+
5 - 10 sec Ship mode... nPM2100 enters ship mode (VOUT off)
140+
> 10 sec None nPM2100 resets (VOUT briefly off)
141+
============ ============ ===================================
142+
143+
Ship mode is the lowest power state of the nPM2100 PMIC.
144+
Entering it powers off the host SoC and you will lose connection to the shell interface.
145+
To exit the ship mode, press the **SHPHLD** button at least for one second.
146+
147+
A long press reset performs a full power cycle of the nPM2100 PMIC and resets all settings to powerup defaults.
148+
This will also power cycle the host SoC.
149+
150+
Dependencies
151+
************
152+
153+
The sample uses the following Zephyr libraries:
154+
155+
* :ref:`zephyr:logging_api`
156+
* :ref:`zephyr:shell_api`
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
npm2100_pmic: pmic@74 {
8+
compatible = "nordic,npm2100";
9+
reg = <0x74>;
10+
pmic-int-pin = <1>;
11+
pmic-int-flags = <GPIO_ACTIVE_HIGH>;
12+
host-int-type = "level";
13+
shiphold-longpress = "reset";
14+
15+
npm2100_gpio: gpio-controller {
16+
compatible = "nordic,npm2100-gpio";
17+
gpio-controller;
18+
#gpio-cells = <2>;
19+
ngpios = <2>;
20+
};
21+
22+
npm2100_regulators: regulators {
23+
compatible = "nordic,npm2100-regulator";
24+
25+
/* limits are set to min/max allowed values */
26+
npm2100_boost: BOOST {
27+
regulator-min-microvolt = <1800000>;
28+
regulator-max-microvolt = <3300000>;
29+
regulator-init-microamp = <0>;
30+
};
31+
32+
npm2100_ldosw: LDOSW {
33+
regulator-min-microvolt = <800000>;
34+
regulator-max-microvolt = <3000000>;
35+
};
36+
};
37+
38+
npm2100_wdt: watchdog {
39+
compatible = "nordic,npm2100-wdt";
40+
};
41+
42+
npm2100_vbat: vbat {
43+
compatible = "nordic,npm2100-vbat";
44+
};
45+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <dt-bindings/regulator/npm2100.h>
8+
9+
&i2c0_default {
10+
group1 {
11+
bias-pull-up;
12+
};
13+
};
14+
15+
&arduino_i2c {
16+
#include "npm2100_pmic.dtsi"
17+
};
18+
19+
&npm2100_pmic {
20+
host-int-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
21+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <dt-bindings/regulator/npm2100.h>
8+
9+
&i2c1_default {
10+
group1 {
11+
bias-pull-up;
12+
};
13+
};
14+
15+
&arduino_i2c {
16+
#include "npm2100_pmic.dtsi"
17+
};
18+
19+
&npm2100_pmic {
20+
host-int-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
21+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
&pinctrl {
8+
i2c21_default: i2c21_default {
9+
group1 {
10+
psels = <NRF_PSEL(TWIM_SDA, 1, 11)>,
11+
<NRF_PSEL(TWIM_SCL, 1, 12)>;
12+
bias-pull-up;
13+
};
14+
};
15+
16+
i2c21_sleep: i2c21_sleep {
17+
group1 {
18+
psels = <NRF_PSEL(TWIM_SDA, 1, 11)>,
19+
<NRF_PSEL(TWIM_SCL, 1, 12)>;
20+
low-power-enable;
21+
};
22+
};
23+
};
24+
25+
&i2c21 {
26+
compatible = "nordic,nrf-twim";
27+
status = "okay";
28+
pinctrl-0 = <&i2c21_default>;
29+
pinctrl-1 = <&i2c21_sleep>;
30+
pinctrl-names = "default", "sleep";
31+
32+
#include "npm2100_pmic.dtsi"
33+
};
34+
35+
&npm2100_pmic {
36+
host-int-gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
37+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3+
4+
CONFIG_SHELL=y
5+
CONFIG_LOG=y
6+
CONFIG_GPIO=y
7+
CONFIG_REGULATOR=y
8+
CONFIG_I2C=y
9+
CONFIG_I2C_SHELL=y
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2025 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3+
sample:
4+
name: nPM2100 one button
5+
6+
common:
7+
integration_platforms:
8+
- nrf52840dk/nrf52840
9+
- nrf5340dk/nrf5340/cpuapp
10+
- nrf54l15dk/nrf54l15/cpuapp
11+
platform_allow:
12+
- nrf52840dk/nrf52840
13+
- nrf5340dk/nrf5340/cpuapp
14+
- nrf54l15dk/nrf54l15/cpuapp
15+
tags:
16+
- pmic
17+
- ci_samples_pmic
18+
19+
tests:
20+
samples.npm2100_one_button_compile:
21+
sysbuild: true
22+
platform_allow:
23+
- nrf52840dk/nrf52840
24+
- nrf5340dk/nrf5340/cpuapp
25+
- nrf54l15dk/nrf54l15/cpuapp
26+
tags:
27+
- sysbuild
28+
- ci_samples_pmic

0 commit comments

Comments
 (0)