gpio_output example

This example demonstrates use of the GPIO driver for output via GPIO pins.

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/gpio_output

List of programs

When you build an example for the target hardware platform, platform-specific drivers are automatically included in the solution:

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 policy description files for a KasperskyOS-based solution are located in the ./einit/src directory.

The security.psl file contains description of the solution security policy. This file is a top-level file into which a portion of the solution security policy description in the form of the PSL file dynld.psl is included via the use declaration. (The declarations in the PSL files are annotated to explain the purpose of these declarations.) The dynld.psl file contains the part of the security policy description that is used when dynamically linking the solution components.

Resources

The ./resources/xdl/gpio_output directory contains the Client.edl file, which is the EDL description of the Client program.

Operating scenario

The example checks the functionality of the GPIO pin output. The total number of GPIO pins on the card is defined by the GPIO_PIN_NUM macro. All GPIO pins other than those indicated in the ExceptionPinArr array are configured for output. Each GPIO pin will be sequentially changed to a logical one (voltage on the pin) and then to a logical zero. The delay between the changes of GPIO pin state is defined by the DELAY_S macro (the time is indicated in seconds).

ExceptionPinArr is an array of GPIO pin numbers that need to be excluded from the example. This may be necessary if some GPIO pins are already being used for other functions, e.g. if pins are being used for a UART connection during debugging.

Building and running the example

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

[Optional] Before starting the example, it is recommended to assemble a circuit in which a LED is connected to each GPIO pin (except for those specified in the ExceptionPinArr array) through a current-limiting resistor. While the example is running, the LED will light up in the logical 1 state on the corresponding GPIO pin and will go out in the logical zero state. This will let you visually track the change in the state of each GPIO pin.

See Building and running examples section.

Page top