diff options
Diffstat (limited to 'lib/chibios/demos/STM32/RT-STM32F103-OLIMEX_STM32_P103/main.c')
-rw-r--r-- | lib/chibios/demos/STM32/RT-STM32F103-OLIMEX_STM32_P103/main.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/chibios/demos/STM32/RT-STM32F103-OLIMEX_STM32_P103/main.c b/lib/chibios/demos/STM32/RT-STM32F103-OLIMEX_STM32_P103/main.c new file mode 100644 index 000000000..a0fc424a6 --- /dev/null +++ b/lib/chibios/demos/STM32/RT-STM32F103-OLIMEX_STM32_P103/main.c | |||
@@ -0,0 +1,77 @@ | |||
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 | * Blinker thread. | ||
24 | */ | ||
25 | static THD_WORKING_AREA(waThread1, 128); | ||
26 | static THD_FUNCTION(Thread1, arg) { | ||
27 | |||
28 | (void)arg; | ||
29 | |||
30 | chRegSetThreadName("blinker"); | ||
31 | while (true) { | ||
32 | palSetPad(GPIOC, GPIOC_LED); | ||
33 | chThdSleepMilliseconds(500); | ||
34 | palClearPad(GPIOC, GPIOC_LED); | ||
35 | chThdSleepMilliseconds(500); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | /* | ||
40 | * Application entry point. | ||
41 | */ | ||
42 | int main(void) { | ||
43 | |||
44 | /* | ||
45 | * System initializations. | ||
46 | * - HAL initialization, this also initializes the configured device drivers | ||
47 | * and performs the board-specific initializations. | ||
48 | * - Kernel initialization, the main() function becomes a thread and the | ||
49 | * RTOS is active. | ||
50 | */ | ||
51 | halInit(); | ||
52 | chSysInit(); | ||
53 | |||
54 | /* | ||
55 | * Activates the serial driver 1 using the driver default configuration. | ||
56 | * PA9(TX) and PA10(RX) are routed to USART1. | ||
57 | */ | ||
58 | sdStart(&SD2, NULL); | ||
59 | |||
60 | /* | ||
61 | * Creates the example thread. | ||
62 | */ | ||
63 | chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO+1, Thread1, NULL); | ||
64 | |||
65 | /* | ||
66 | * Normal main() thread activity, in this demo it does nothing except | ||
67 | * sleeping in a loop and check the button state, when the button is | ||
68 | * pressed the test procedure is launched. | ||
69 | */ | ||
70 | while (true) { | ||
71 | if (palReadPad(GPIOA, GPIOA_BUTTON)) { | ||
72 | test_execute((BaseSequentialStream *)&SD2, &rt_test_suite); | ||
73 | test_execute((BaseSequentialStream *)&SD2, &oslib_test_suite); | ||
74 | } | ||
75 | chThdSleepMilliseconds(500); | ||
76 | } | ||
77 | } | ||