diff options
Diffstat (limited to 'lib/chibios/demos/STM32/RT-STM32L452RE-NUCLEO64-P/main.c')
-rw-r--r-- | lib/chibios/demos/STM32/RT-STM32L452RE-NUCLEO64-P/main.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/chibios/demos/STM32/RT-STM32L452RE-NUCLEO64-P/main.c b/lib/chibios/demos/STM32/RT-STM32L452RE-NUCLEO64-P/main.c new file mode 100644 index 000000000..b6addb011 --- /dev/null +++ b/lib/chibios/demos/STM32/RT-STM32L452RE-NUCLEO64-P/main.c | |||
@@ -0,0 +1,74 @@ | |||
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 "ch.h" | ||
18 | #include "hal.h" | ||
19 | #include "rt_test_root.h" | ||
20 | #include "oslib_test_root.h" | ||
21 | |||
22 | /* | ||
23 | * Green LED blinker thread, times are in milliseconds. | ||
24 | */ | ||
25 | static THD_WORKING_AREA(waThread1, 128); | ||
26 | static THD_FUNCTION(Thread1, arg) { | ||
27 | |||
28 | (void)arg; | ||
29 | chRegSetThreadName("blinker"); | ||
30 | while (true) { | ||
31 | palClearLine(LINE_LED_GREEN); | ||
32 | chThdSleepMilliseconds(500); | ||
33 | palSetLine(LINE_LED_GREEN); | ||
34 | chThdSleepMilliseconds(500); | ||
35 | } | ||
36 | } | ||
37 | |||
38 | /* | ||
39 | * Application entry point. | ||
40 | */ | ||
41 | int main(void) { | ||
42 | |||
43 | /* | ||
44 | * System initializations. | ||
45 | * - HAL initialization, this also initializes the configured device drivers | ||
46 | * and performs the board-specific initializations. | ||
47 | * - Kernel initialization, the main() function becomes a thread and the | ||
48 | * RTOS is active. | ||
49 | */ | ||
50 | halInit(); | ||
51 | chSysInit(); | ||
52 | |||
53 | /* | ||
54 | * Activates the serial driver 2 using the driver default configuration. | ||
55 | */ | ||
56 | sdStart(&LPSD1, NULL); | ||
57 | |||
58 | /* | ||
59 | * Creates the blinker thread. | ||
60 | */ | ||
61 | chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); | ||
62 | |||
63 | /* | ||
64 | * Normal main() thread activity, in this demo it does nothing except | ||
65 | * sleeping in a loop and check the button state. | ||
66 | */ | ||
67 | while (true) { | ||
68 | if (!palReadLine(LINE_BUTTON)) { | ||
69 | test_execute((BaseSequentialStream *)&LPSD1, &rt_test_suite); | ||
70 | test_execute((BaseSequentialStream *)&LPSD1, &oslib_test_suite); | ||
71 | } | ||
72 | chThdSleepMilliseconds(500); | ||
73 | } | ||
74 | } | ||