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