diff options
Diffstat (limited to 'lib/chibios/demos/STM32/RT-STM32F334-DISCOVERY/main.c')
-rw-r--r-- | lib/chibios/demos/STM32/RT-STM32F334-DISCOVERY/main.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/lib/chibios/demos/STM32/RT-STM32F334-DISCOVERY/main.c b/lib/chibios/demos/STM32/RT-STM32F334-DISCOVERY/main.c new file mode 100644 index 000000000..cfad33222 --- /dev/null +++ b/lib/chibios/demos/STM32/RT-STM32F334-DISCOVERY/main.c | |||
@@ -0,0 +1,93 @@ | |||
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 | * LEDs 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 | palSetLine(LINE_LED_RED); | ||
32 | chThdSleepMilliseconds(50); | ||
33 | palSetLine(LINE_LED_GREEN); | ||
34 | chThdSleepMilliseconds(50); | ||
35 | palSetLine(LINE_LED_BLUE); | ||
36 | chThdSleepMilliseconds(50); | ||
37 | palSetLine(LINE_LED_ORANGE); | ||
38 | chThdSleepMilliseconds(200); | ||
39 | palClearLine(LINE_LED_RED); | ||
40 | chThdSleepMilliseconds(50); | ||
41 | palClearLine(LINE_LED_GREEN); | ||
42 | chThdSleepMilliseconds(50); | ||
43 | palClearLine(LINE_LED_BLUE); | ||
44 | chThdSleepMilliseconds(50); | ||
45 | palClearLine(LINE_LED_ORANGE); | ||
46 | chThdSleepMilliseconds(200); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | /* | ||
51 | * Application entry point. | ||
52 | */ | ||
53 | int main(void) { | ||
54 | |||
55 | /* | ||
56 | * System initializations. | ||
57 | * - HAL initialization, this also initializes the configured device drivers | ||
58 | * and performs the board-specific initializations. | ||
59 | * - Kernel initialization, the main() function becomes a thread and the | ||
60 | * RTOS is active. | ||
61 | */ | ||
62 | halInit(); | ||
63 | chSysInit(); | ||
64 | |||
65 | /* | ||
66 | * Turning off buck switch. Note that this means to completely turn of the | ||
67 | * High Brightness LED which is driven by the buck converter. | ||
68 | */ | ||
69 | palSetLineMode(LINE_BK_DRIVE, PAL_MODE_OUTPUT_PUSHPULL); | ||
70 | palClearLine(LINE_BK_DRIVE); | ||
71 | |||
72 | /* | ||
73 | * Activates the serial driver 2 using the driver default configuration. | ||
74 | */ | ||
75 | sdStart(&SD2, NULL); | ||
76 | |||
77 | /* | ||
78 | * Creates the blinker thread. | ||
79 | */ | ||
80 | chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); | ||
81 | |||
82 | /* | ||
83 | * Normal main() thread activity, in this demo it does nothing except | ||
84 | * sleeping in a loop and check the button state. | ||
85 | */ | ||
86 | while (true) { | ||
87 | if (palReadPad(GPIOA, GPIOA_BUTTON)) { | ||
88 | test_execute((BaseSequentialStream *)&SD2, &rt_test_suite); | ||
89 | test_execute((BaseSequentialStream *)&SD2, &oslib_test_suite); | ||
90 | } | ||
91 | chThdSleepMilliseconds(500); | ||
92 | } | ||
93 | } | ||