pwm_led example

The example demonstrates the use of a pulse-width modulation (PWM) driver to control the LED in a KasperskyOS-based solution.

Example directory in the SDK

The code of the example and build scripts are available at the following path:

/opt/KasperskyOS-Community-Edition-<platform>-<version>/examples/pwm_led

List of programs

When building an example for a target hardware platform, a platform-specific BSP driver is automatically included in the solution. BSP is a Board Support Package that provides cross-platform configuration of peripherals.

For the PWM driver to work correctly, you need to link the PwmLed program to the client library named pwm::client.

Initialization description

The solution initialization description file named init.yaml is generated during the solution build process based on the ./einit/src/init.yaml.in template. Macros in @INIT_*@‌ ‌format contained in the template are automatically expanded in the resulting init.yaml file. For more details, refer to init.yaml.in template.

Security policy description

The security.psl file contains a description of a security policy for a KasperskyOS-based solution and is located in the ./einit/src directory. The declarations in the PSL file are provided with comments that explain the purpose of these declarations.

Resources

The ./resources/xdl/pwm_led directory contains the PwmLed.edl file, which is the EDL description for the PwmLed program.

Operating scenario

The PwmLed program performs the following actions:

  1. Initializes the PWM driver and opens the pwm0 PWM channel for operation.
  2. The program performs 5 cycles of smooth change in the brightness of the LED from the minimum to the maximum value and vice versa by changing the value of the duty cycle of the output signal.
  3. Closes the PWM channel, deinitializes the driver, and terminates with the EXIT_SUCCESS code if there are no errors, otherwise it shows the EXIT_FAILURE code.

Building and running the example

The CMake system, which is included with KasperskyOS Community Edition, is used to build and run the example.

This example is intended to run only on Radxa ROCK 3A.

For the example to work correctly, apply the DTBO overlay rk3568-pwm0-m0.dtbo to the hardware configuration description binary file rk3568-rock-3a.dtb according to the instructions on applying overlays provided in the section titled Building drivers for the Radxa ROCK 3A hardware platform.

See Building and running examples section.

Page top