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