aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/main.c')
-rw-r--r--lib/chibios/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/main.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/chibios/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/main.c b/lib/chibios/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/main.c
new file mode 100644
index 000000000..03b6396af
--- /dev/null
+++ b/lib/chibios/demos/STM32/NASA-OSAL-STM32F407-DISCOVERY/main.c
@@ -0,0 +1,72 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#include "hal.h"
18#include "nasa_osal_test_root.h"
19#include "osapi.h"
20
21/*
22 * This is a periodic thread that does absolutely nothing except flashing
23 * a LED.
24 * Note, the working area is created using ChibiOS/RT macro because alignment
25 * constraints.
26 */
27static THD_WORKING_AREA(wa_blinker, 128);
28static void blinker(void) {
29
30 OS_TaskRegister();
31
32 while (true) {
33 palSetLine(LINE_LED3); /* Orange. */
34 OS_TaskDelay(500);
35 palClearLine(LINE_LED3); /* Orange. */
36 OS_TaskDelay(500);
37 }
38}
39
40/*
41 * Application entry point.
42 */
43int main(void) {
44 uint32 blinker_id;
45
46 /* HAL initialization, this also initializes the configured device drivers
47 and performs the board-specific initializations.*/
48 halInit();
49
50 /* OS initialization.*/
51 (void) OS_API_Init();
52
53 /* Activates the serial driver 2 using the driver default configuration.
54 PA2(TX) and PA3(RX) are routed to USART2.*/
55 sdStart(&SD2, NULL);
56 palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
57 palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));
58
59 /* Starting the blinker thread.*/
60 (void) OS_TaskCreate(&blinker_id, "blinker", blinker,
61 (uint32 *)wa_blinker, sizeof wa_blinker,
62 128, 0);
63
64 /* In the ChibiOS/RT OSAL implementation the main() function is an
65 usable thread with priority 128 (NORMALPRIO), here we just sleep
66 waiting for a button event, then the test suite is executed.*/
67 while (true) {
68 if (palReadLine(LINE_BUTTON))
69 test_execute((BaseSequentialStream *)&SD2, &nasa_osal_test_suite);
70 OS_TaskDelay(500);
71 }
72}