diff options
Diffstat (limited to 'lib/chibios/demos/STM32/NIL-STM32L476-DISCOVERY/main.c')
-rw-r--r-- | lib/chibios/demos/STM32/NIL-STM32L476-DISCOVERY/main.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/lib/chibios/demos/STM32/NIL-STM32L476-DISCOVERY/main.c b/lib/chibios/demos/STM32/NIL-STM32L476-DISCOVERY/main.c new file mode 100644 index 000000000..376fd679b --- /dev/null +++ b/lib/chibios/demos/STM32/NIL-STM32L476-DISCOVERY/main.c | |||
@@ -0,0 +1,110 @@ | |||
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 "ch.h" | ||
19 | #include "nil_test_root.h" | ||
20 | #include "oslib_test_root.h" | ||
21 | |||
22 | /* | ||
23 | * Blinker thread #1. | ||
24 | */ | ||
25 | THD_WORKING_AREA(waThread1, 128); | ||
26 | THD_FUNCTION(Thread1, arg) { | ||
27 | |||
28 | (void)arg; | ||
29 | |||
30 | while (true) { | ||
31 | palSetLine(LINE_LED_RED); | ||
32 | chThdSleepMilliseconds(250); | ||
33 | palClearLine(LINE_LED_RED); | ||
34 | chThdSleepMilliseconds(250); | ||
35 | } | ||
36 | } | ||
37 | |||
38 | /* | ||
39 | * Blinker thread #2. | ||
40 | */ | ||
41 | THD_WORKING_AREA(waThread2, 128); | ||
42 | THD_FUNCTION(Thread2, arg) { | ||
43 | |||
44 | (void)arg; | ||
45 | |||
46 | while (true) { | ||
47 | palSetLine(LINE_LED_GREEN); | ||
48 | chThdSleepMilliseconds(500); | ||
49 | palClearLine(LINE_LED_GREEN); | ||
50 | chThdSleepMilliseconds(500); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | /* | ||
55 | * Tester thread. | ||
56 | */ | ||
57 | THD_WORKING_AREA(waThread3, 256); | ||
58 | THD_FUNCTION(Thread3, arg) { | ||
59 | |||
60 | (void)arg; | ||
61 | |||
62 | /* | ||
63 | * Activates the serial driver 2 using the driver default configuration. | ||
64 | */ | ||
65 | sdStart(&SD2, NULL); | ||
66 | |||
67 | /* Welcome message.*/ | ||
68 | chnWrite(&SD2, (const uint8_t *)"Hello World!\r\n", 14); | ||
69 | |||
70 | /* Waiting for button push and activation of the test suite.*/ | ||
71 | while (true) { | ||
72 | if (palReadLine(LINE_JOY_CENTER)) { | ||
73 | test_execute((BaseSequentialStream *)&SD2, &nil_test_suite); | ||
74 | test_execute((BaseSequentialStream *)&SD2, &oslib_test_suite); | ||
75 | } | ||
76 | chThdSleepMilliseconds(500); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | /* | ||
81 | * Threads creation table, one entry per thread. | ||
82 | */ | ||
83 | THD_TABLE_BEGIN | ||
84 | THD_TABLE_THREAD(0, "blinker1", waThread1, Thread1, NULL) | ||
85 | THD_TABLE_THREAD(1, "blinker2", waThread2, Thread2, NULL) | ||
86 | THD_TABLE_THREAD(4, "tester", waThread3, Thread3, NULL) | ||
87 | THD_TABLE_END | ||
88 | |||
89 | /* | ||
90 | * Application entry point. | ||
91 | */ | ||
92 | int main(void) { | ||
93 | |||
94 | /* | ||
95 | * System initializations. | ||
96 | * - HAL initialization, this also initializes the configured device drivers | ||
97 | * and performs the board-specific initializations. | ||
98 | * - Kernel initialization, the main() function becomes a thread and the | ||
99 | * RTOS is active. | ||
100 | */ | ||
101 | halInit(); | ||
102 | chSysInit(); | ||
103 | |||
104 | /* This is now the idle thread loop, you may perform here a low priority | ||
105 | task but you must never try to sleep or wait in this loop. Note that | ||
106 | this tasks runs at the lowest priority level so any instruction added | ||
107 | here will be executed after all other tasks have been started.*/ | ||
108 | while (true) { | ||
109 | } | ||
110 | } | ||