• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

boards/29-Dec-2025-702575

src/29-Dec-2025-193132

CMakeLists.txtD29-Dec-2025225 106

KconfigD29-Dec-20252.1 KiB6654

README.rstD29-Dec-20251.7 KiB5037

prj.confD29-Dec-202556 63

sample.yamlD29-Dec-2025728 2625

README.rst

1.. zephyr:code-sample:: led-pwm
2   :name: LED PWM
3   :relevant-api: led_interface
4
5   Control PWM LEDs using the LED API.
6
7Overview
8********
9
10This sample allows to test the led-pwm driver. The first "pwm-leds" compatible
11device instance found in DT is used. For each LEDs attached to this device
12(child nodes) the same test pattern (described below) is executed. The LED API
13functions are used to control the LEDs.
14
15Test pattern
16============
17
18For each PWM LEDs (one after the other):
19
20- Turning on
21- Turning off
22- Increasing brightness gradually
23- Decreasing brightness gradually
24- Blinking on: 0.1 sec, off: 0.1 sec
25- Blinking on: 1 sec, off: 1 sec
26- Turning off
27
28Fallback Blink Delay Calculation
29=================================
30
31When the configured blink delays exceed the platform's timer range limitations,
32the sample automatically calculates fallback delays based on each LED's PWM
33period defined in the devicetree. The calculation uses configurable divisors:
34
35- Short delay = LED PWM period / :kconfig:option:`CONFIG_BLINK_DELAY_SHORT_LED_PERIOD_DIV` / 2
36- Long delay = LED PWM period / :kconfig:option:`CONFIG_BLINK_DELAY_LONG_LED_PERIOD_DIV` / 2
37
38This ensures the sample works correctly on platforms with timer limitations by
39providing hardware-appropriate delays that are compatible with each LED's PWM
40configuration.
41
42Building and Running
43********************
44
45This sample can be built and executed on all the boards with PWM LEDs connected.
46The LEDs must be correctly described in the DTS: the compatible property of the
47device node must match "pwm-leds". And for each LED, a child node must be
48defined and the PWM configuration must be provided through a "pwms" phandle's
49node.
50