IC:

Introduction

There are two kinds of examples in the SDK.

  • Application examples

  • Peripheral examples

Items

Path

Description

Application example

{SDK}\component\example

xml, ssl, …

Peripheral example

{SDK}\component\example\peripheral

ADC, UART, I2C, SPI, Timer, …

This chapter illustrates the contents of examples and how to build example source code.

Application Example

In each folder of application example, there are C source files, header files and README.txt. You should check for detailed configurations of the example according to README.txt.

Note

The application examples are shared by all Realtek SoC, so you need to refer to README.txt for detailed information of different ICs.

The entry function of application example is app_example(), and each application example has its own app_example().

The app_example() in main.c under {SDK}\amebadplus_gcc_project\project_km4\src will be replaced automatically when the application example is built.

// default main
int main(void)
{
   ...
   app_example();
   ...
   /* enable schedule, start kernel */
   vTaskStartSchedule();
}

The application examples normally run on KM4. To run application example, you only need to:

  1. Check software and hardware settings in README.txt of the example.

  2. Add compile options EXAMPLE={examplefolder name} when building the project, and replace {example folder name} with the specific folder name of this example.

For example, if you want to build xml example to start an xml example thread, you need to:

  1. Set the macro in SDK according to README.txt in {SDK}\component\example\xml

  2. Enter make EXAMPLE=xml for KM4 on MSYS2 MinGW 64-bit (Windows) or terminal (Linux).

../../_images/building_xml_application_example_21Dx.png

Building XML application example

Peripheral Example

The peripheral examples are demos of peripherals. Most examples consist of raw and mbed folders, you can choose raw or mbed demos as you like.

Comparison of raw and mbed examples

Items

Path

Description

mbed

{SDK}\component\example\peripheral\{peripheral}\mbed

mbed APIs are used.

raw

{SDK}\component\example\peripheral\{peripheral}\raw

Low-level driver APIs are used.

Each example folder contains:

  • main.c: Main program entry file

  • README.txt: Technical documentation with:

    • Example description

    • Required components

    • HW connections

    • Expected behavior

The peripheral examples normally run on KM4. To run peripheral examples, you only need to:

  1. Check software and hardware settings in README.txt of the example.

  2. Replace the original main.c under {SDK}\amebadplus_gcc_project\project_km4\src with main.c in the example directory.

  3. (Optional) Copy other header files that are depicted in README.txt to {SDK}\amebadplus_gcc_project\project_km4\src if needed.

  4. Re-build the project by command make.