Skip to content

Commit 007b92b

Browse files
committed
Remove multithreaded application
1 parent 7b12e79 commit 007b92b

File tree

6 files changed

+25
-152
lines changed

6 files changed

+25
-152
lines changed

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Blinky Mbed OS Example
22

3-
The example project contains variants of an application to blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/).
3+
The example project contains an application to blink an LED on supported [Mbed boards](https://os.mbed.com/platforms/).
44

55
The project can be built with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/tools/index.html). However, this example project specifically refers to the command line interface tool [Arm Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). Please install Arm Mbed CLI.
66

@@ -14,18 +14,11 @@ Clone this repository on your system and change the current directory to where t
1414

1515
Modifying default Mbed OS configuration parameters can be done at application level using an application configuration file. By default ARM Mbed CLI looks for [`mbed_app.json`](https://os.mbed.com/docs/mbed-os/latest/reference/configuration.html), however the configuration file can be named anything. It can be passed to ARM Mbed CLI using the optional argument `--app-config` of the `compile` sub-command. This project comes with configuration files for the different variants and configurations of the blinky application.
1616

17-
Select the section for the variant of the application you wish to build:
18-
* [Blinky Wait application](#blinky_wait)
19-
* [Bare metal](#blinky_wait_bare_metal)
20-
* [Blinky multi-threaded application](#blinky_multi_threaded)
17+
## Application functionality
2118

22-
## <a name="blinky_wait"></a> Blinky Wait application
19+
The `main()` function is the single thread in the application, it toggles the state of a digital output connected to an LED on the target.
2320

24-
### Application functionality
25-
26-
The `main()` function calls `blinky_wait()`, as part of the single thread, which toggles the state of a digital output connected to an LED on the target.
27-
28-
### <a name="build_blinky_wait_rtos"></a> Building and Running
21+
## Building and Running
2922

3023
1. Connect a USB cable between the USB port on the target and the host computer.
3124
2. Run the following command to build the example project and program the microcontroller flash memory:
@@ -34,6 +27,7 @@ The `main()` function calls `blinky_wait()`, as part of the single thread, which
3427
```
3528
The binary is located at `./BUILD/<TARGET>/<TOOLCHAIN>/mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB.
3629

30+
<<<<<<< HEAD
3731
<<<<<<< HEAD
3832
### Application functionality
3933

@@ -45,17 +39,23 @@ The `main()` function calls `blinky_rtos()`, as part of the main thread, which s
4539
The variant of the application [above](#build_blinky_wait_rtos) is built with the full Mbed OS library including its RTOS components. However, for single-threaded applications running on targets with ultraconstrains, it is possible to obtain an application with an even smaller memory footprint using [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/latest/reference/mbed-os-bare-metal.html) profile.
4640
An application configuration file, [`config_blinky_wait_bare_metal.json`](./blinky_wait/config_blinky_wait_bare_metal.json) is provided to build a binary with Mbed OS bare metal profile.
4741
>>>>>>> Add application variants and Mbed OS bare metal tutorial
42+
=======
43+
## Bare metal
44+
The application above is built with the full Mbed OS library including its RTOS components. However, for single-threaded applications running on targets with ultraconstrains, it is possible to obtain an application with an even smaller memory footprint using [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/latest/reference/mbed-os-bare-metal.html) profile.
45+
An application configuration file, [`config_bare_metal.json`](./config_bare_metal.json) is provided to build a binary with Mbed OS bare metal profile.
46+
>>>>>>> Remove multithreaded application
4847
4948
1. Connect a USB cable between the USB port on the target and the host computer.
5049
2. Run the following command to build the example project with runtime statistics output:
5150
```bash
52-
$ mbed compile -m <TARGET> -t <TOOLCHAIN> --app-config=./blinky_wait/config_blinky_bare_metal.json --flash
51+
$ mbed compile -m <TARGET> -t <TOOLCHAIN> --app-config config_bare_metal.json --flash
5352
```
5453
The binary is located at `./BUILD/<TARGET>/<TOOLCHAIN>/mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB.
5554
5655
`"target.default_lib" : "small"` tells the build tool to use a small implementation of the C standard library for the toolchain selected if available. That would be Newlib-nano and MicroLib for GCC_ARM and ARM toolchains respectively.
5756
5857
58+
<<<<<<< HEAD
5959
## <a name="blinky_multi_threaded"></a> Blinky multi-threaded application
6060
6161
This variant shows Mbed OS features suchs as threads, thread delay, and inter-thread communication to blink an LED.
@@ -74,6 +74,9 @@ The `main()` function calls `blinky_multithreaded()`, as part of the main thread
7474
The binary is located at `./BUILD/<TARGET>/<TOOLCHAIN>/mbed-os-example-blinky.bin` and can alternatively be manually copied to the target which gets mounted on the host computer via USB.
7575
7676
### Optional RTOS runtime statistics
77+
=======
78+
## Optional RTOS runtime statistics
79+
>>>>>>> Remove multithreaded application
7780
7881
It is possible to take a snapshot of the device's runtime statistics and display it over serial to your PC. See how [here](https://os.mbed.com/docs/latest/apis/mbed-statistics.html).
7982

blinky_multithreaded/blinky_multithreaded.cpp

Lines changed: 0 additions & 96 deletions
This file was deleted.

blinky_multithreaded/config_blinky_multithreaded.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

blinky_wait/blinky_wait.cpp

Lines changed: 0 additions & 23 deletions
This file was deleted.

main.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2018-2019 ARM Limited
2+
* Copyright (c) 2019 ARM Limited
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

66
#include "mbed.h"
77
#include "platform/mbed_thread.h"
8-
#include "stats_report.h"
8+
9+
10+
// Blinking rate in milliseconds
11+
#define BLINKING_RATE_MS 500
12+
913

1014
int main()
1115
{
12-
SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */);
16+
// Initialise the digital pin LED1 as an output
17+
DigitalOut led(LED1);
1318

14-
int count = 0;
1519
while (true) {
16-
// Blink LED and wait 0.5 seconds
17-
led1 = !led1;
18-
thread_sleep_for(SLEEP_TIME);
19-
20-
if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) {
21-
// Following the main thread wait, report on the current system status
22-
sys_state.report_state();
23-
count = 0;
24-
}
25-
++count;
20+
led = !led;
21+
thread_sleep_for(BLINKING_RATE_MS);
2622
}
2723
}

0 commit comments

Comments
 (0)