i2c_bm8563_rtc example

This example demonstrates how to work with I2C (Inter-Integrated Circuit) to control a real-time clock module based on the BM8563 chip in KasperskyOS.

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

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

List of programs

To ensure the correct operation of I2C and BSP drivers, the following conditions must be met:

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/bm8563_rtc directory contains the BM8563.edl file, which is the EDL description for the BM8563 program.

Operating scenario

The BM8563 program performs the following actions:

  1. Initializes the BSP driver and applies the predefined configuration of the I2C module, which configures output multiplexing for the specified I2C channel.
  2. Initializes the I2C driver and opens the I2C channel for operation.
  3. Sequentially reads the current values of the real-time clock registers (starting from the register defined by the BM8563_SECONDS_REG macro) and prints them to standard error in the date and time format.
  4. Stops the clock by setting the BM8563_STOP_RTC_BIT in the BM8563_CTRLSTS1_REG control register.
  5. Reads and prints the updated values of the clock registers to confirm the stop.
  6. Writes test date and time values to registers (starting from the BM8563_SECONDS_REG register).
  7. Starts the clock by clearing the stop bit (writing a zero value to the BM8563_CTRLSTS1_REG register).
  8. Reads and prints the updated values of the clock registers to confirm the start.
  9. Closes the I2C channel 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.

See Building and running examples section.

Page top