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
Client – application that uses the SPI driver interface.SPI – SPI driver. The client library of the SPI driver is statically linked to the Client program.DCM – system program that lets you dynamically create IPC channels.When you build an example for the target hardware platform, platform-specific drivers are automatically included in the solution:
GPIO – GPIO support driver for the Radxa ROCK 3A and Raspberry Pi 4 B.BSP – Board Support Package that provides cross-platform peripheral configuration for the Radxa ROCK 3A and Raspberry Pi 4 B.PinCtrl – low-level pin multiplexing (pinmux) configuration driver for the Radxa ROCK 3A.Bcm2711MboxArmToVc – driver for working with the VideoCore (VC6) coprocessor via mailbox technology for Raspberry Pi 4 B.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:
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).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.HW_GPIO_RESET_PIN_NUM macro to the logical zero state (activation of the RESET signal of the ATTiny microcontroller).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.HW_GPIO_RESET_PIN_NUM macro to the logical 1 state.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:
Full alignment of all pins is required on the Raspberry Pi 4 B. On the Radxa ROCK 3A, manual connection of the pins is required according to the connection diagram in the table below.
Diagram for connecting Sense HAT to hardware platforms
Pin |
Sense HAT |
Raspberry Pi 4 B |
Radxa ROCK 3A |
|---|---|---|---|
17 |
3V3 Power |
3V3 power |
+3.3V |
19 |
GPIO10 (SPI0 MOSI) |
GPIO 10 (MOSI) |
GPIO 147 (SPI3_MOSI_M1) |
20 |
Ground |
Ground |
GND |
21 |
GPIO9 (SPI0 MISO) |
GPIO 9 (MISO) |
GPIO 149 (SPI3_MISO_M1) |
22 |
GPIO25 (Atmel Prog Reset) |
GPIO 25 |
GPIO 17 |
23 |
GPIO11 (SPI0 SCLK) |
GPIO 11 (SCLK) |
GPIO 146 (SPI3_CLK_M1) |
24 |
GPIO8 (Atmel Chip Select) |
GPIO 8 (CE0) |
GPIO 150 (SPI3_CS0_M1) |
rk3568-spi3-m1-cs0-spidev.dtbo to the hardware configuration description binary file rk3568-rock-3a.dtb according to the instructions on applying overlays provided in the Building drivers for the Radxa ROCK 3A hardware platform section.See Building and running examples section.
Page top