spi_check_regs example

This example demonstrates how to work with the SPI (Serial Peripheral Interface) on the Sense HAT add-on board in KasperskyOS.

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

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 some parts of the solution security policy description in the form of the PSL files dynld.psl and trusted.psl are included via the use declaration. (The declarations in the PSL files are annotated to explain the purpose of the declarations.) The dynld.psl file contains the part of the security policy that is used when dynamically linking the solution components. The trusted.psl file contains the part of the security policy description that regulates interactions between the Einit initializing program and the KasperskyOS kernel.

Resources

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

Operating scenario

The Client program performs the following actions:

  1. Initializes the following drivers: PinCtrl for the Radxa ROCK 3A or BSP for the Raspberry Pi 4 B, and GPIO and SPI drivers. Opens the GPIO port.
  2. Configures the GPIO pin specified by the HW_GPIO_RESET_PIN_NUM macro for output and sets it to the logical 1 state (deactivation of the RESET signal of the ATTiny microcontroller).
  3. Opens the SPI channel defined by the HW_SPI_MODULE_CHANNEL macro, receives the specifications of this channel, and prints them to standard error. Then it sets the operating mode for this channel as defined in the cfg structure.
  4. Sets the GPIO pin defined by the HW_GPIO_RESET_PIN_NUM macro to the logical zero state (activation of the RESET signal of the ATTiny microcontroller).
  5. Sends the Programming Enable command to the ATTiny microcontroller via the SPI channel. The signature bytes of the microcontroller are additionally read for the Radxa ROCK 3A.
  6. Returns the GPIO pin defined by the HW_GPIO_RESET_PIN_NUM macro to the logical 1 state.
  7. Prints the SPI exchange results to standard error and compares them with the expected values.
  8. Closes the SPI channel and GPIO port.

Building and running the example

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

For the example to work correctly, do the following:

See Building and running examples section.

Page top