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:
Check software and hardware settings in
README.txt
of the example.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:
Set the macro in SDK according to
README.txt
in{SDK}\component\example\xml
Enter
make EXAMPLE=xml
for KM4 on MSYS2 MinGW 64-bit (Windows) or terminal (Linux).

Building XML application example
The app_example()
in main.c
under {SDK}\amebalite_gcc_project\project_km4\src
or {SDK}\amebalite_gcc_project\project_kr4\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 AP (KM4 or KR4). To run application example, you only need to:
Check software and hardware settings in
README.txt
of the example.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:
Set the macro in SDK according to
README.txt
in{SDK}\component\example\xml
Enter
make EXAMPLE=xml
for AP on MSYS2 MinGW 64-bit (Windows) or terminal (Linux).

Building XML application example
The app_example()
in main.c
under {SDK}\amebalite_gcc_project\project_km4\src
or {SDK}\amebalite_gcc_project\project_kr4\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 AP (KM4 or KR4). To run application example, you only need to:
Check software and hardware settings in
README.txt
of the example.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:
Set the macro in SDK according to
README.txt
in{SDK}\component\example\xml
Enter
make EXAMPLE=xml
for AP on MSYS2 MinGW 64-bit (Windows) or terminal (Linux).

Building XML application example
The app_example()
in main.c
under {SDK}\amebasmart_gcc_project\project_ap\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 CA32. To run application example, you only need to:
Check software and hardware settings in
README.txt
of the example.Add compile options
EXAMPLE={example folder 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:
Set the macro in SDK according to
README.txt
in{SDK}\component\example\xml
Enter
make EXAMPLE=xml
for CA32 on MSYS2 MinGW 64-bit (Windows) or terminal (Linux).

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.
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 fileREADME.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:
Check software and hardware settings in
README.txt
of the example.Replace the original
main.c
under{SDK}\amebadplus_gcc_project\project_km4\src
withmain.c
in the example directory.(Optional) Copy other header files that are depicted in
README.txt
to{SDK}\amebadplus_gcc_project\project_km4\src
if needed.Re-build the project by command
make
.
The peripheral examples normally run on AP (KM4 or KR4). To run peripheral examples, you only need to:
Check software and hardware settings in README.txt of the example.
Replace the original
main.c
under\amebalite_gcc_project\project_km4\src
or\amebalite_gcc_project\project_kr4\src
withmain.c
in the example directory.(Optional) Copy other header files that are depicted in
README.txt
to\amebalite_gcc_project\project_km4\src
or\amebalite_ gcc_project\project_kr4\src
if needed.Re-build project using command
make
.
The peripheral examples normally run on AP (KM4 or KR4). To run peripheral examples, you only need to:
Check software and hardware settings in README.txt of the example.
Replace the original
main.c
under\amebalite_gcc_project\project_km4\src
or\amebalite_gcc_project\project_kr4\src
withmain.c
in the example directory.(Optional) Copy other header files that are depicted in
README.txt
to\amebalite_gcc_project\project_km4\src
or\amebalite_ gcc_project\project_kr4\src
if needed.Re-build project using command
make
.
The peripheral examples normally run on CA32. To run peripheral examples, you only need to:
Check software and hardware settings in
README.txt
of the example.Replace the original
main.c
under{SDK}\amebasmart_gcc_project\project_ap\src
withmain.c
in the example.(Optional) Copy other header files that are depicted in
README.txt
to{SDK}\amebasmart_gcc_project\project_ap\src
if needed.Re-build the project by using
make
command.