Controlling nPM1300 LEDs
1. Overview
This application note describes how to configure nPM1300 LEDs in Zephyr BSP and use it in the user application.
2. Configuring nPM1300 LEDs in Zephyr BSP
The nPM1300 LEDs device is declared in nrf9151som_nrf9151_ns.dts
as a child node of the npm1300_pmic device:
npm1300_pmic: pmic@6b {
compatible = "nordic,npm1300";
...
npm1300_leds: npm1300_leds {
compatible = "nordic,npm1300-led";
nordic,led0-mode = "host";
nordic,led1-mode = "host";
nordic,led2-mode = "host";
};
...
};
The devicetree node configures the following parameters:
Parameter | Value | Description |
---|---|---|
|
| Enables the |
|
| LED |
|
| |
|
|
3. Controlling nPM1300 LEDs in User Application
3.1. nPM1300 LEDs C-binding API
The Customized Asset Tracker v2 application makes use of the Zephyr LED API to control nPM1300 LEDs:
Function | Description | Comments |
| Turn on the LED. |
Returns zero on success, otherwise a negative error code is returned. |
| Turn off the LED. |
Returns zero on success, otherwise a negative error code is returned. |
3.2. nPM1300 LEDs Shell Commands
The Customized Asset Tracker v2 application provides a set of Zephyr shell commands for nPM1300 LEDs:
Command | Parameters | Comments |
|
| Turn the LED on. |
|
| Turn the LED off. |
4. Validating nPM1300 LED Operations
Turn on the Charging LED and verify that the green LED has been turned on:
uart:~$ led on npm1300_leds 0 npm1300_leds: turning on LED 0
Turn on the Charging LED and verify that the green LED has been turned off:
uart:~$ led off npm1300_leds 0 npm1300_leds: turning off LED 0
Turn on the Error LED and verify that the red LED has been turned on:
uart:~$ led on npm1300_leds 1 npm1300_leds: turning on LED 1
Turn on the Error LED and verify that the red LED has been turned off:
uart:~$ led off npm1300_leds 1 npm1300_leds: turning off LED 1