aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/demos/STM32/RT-STM32F469I-DISCOVERY/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/demos/STM32/RT-STM32F469I-DISCOVERY/main.c')
-rw-r--r--lib/chibios/demos/STM32/RT-STM32F469I-DISCOVERY/main.c126
1 files changed, 126 insertions, 0 deletions
diff --git a/lib/chibios/demos/STM32/RT-STM32F469I-DISCOVERY/main.c b/lib/chibios/demos/STM32/RT-STM32F469I-DISCOVERY/main.c
new file mode 100644
index 000000000..c25ed6a4b
--- /dev/null
+++ b/lib/chibios/demos/STM32/RT-STM32F469I-DISCOVERY/main.c
@@ -0,0 +1,126 @@
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
20#include "chprintf.h"
21#include "shell.h"
22
23/*
24 * Red LED blinker thread, times are in milliseconds.
25 */
26static THD_WORKING_AREA(waThread1, 128);
27static THD_FUNCTION(Thread1, arg) {
28
29 (void)arg;
30 chRegSetThreadName("blinker1");
31 while (true) {
32 palSetPad(GPIOG, GPIOG_LED1);
33 chThdSleepMilliseconds(50);
34 palSetPad(GPIOD, GPIOD_LED2);
35 chThdSleepMilliseconds(300);
36 palClearPad(GPIOG, GPIOG_LED1);
37 chThdSleepMilliseconds(50);
38 palClearPad(GPIOD, GPIOD_LED2);
39 chThdSleepMilliseconds(300);
40 }
41}
42
43/*
44 * Green LED blinker thread, times are in milliseconds.
45 */
46static THD_WORKING_AREA(waThread2, 128);
47static THD_FUNCTION(Thread2, arg) {
48
49 (void)arg;
50 chRegSetThreadName("blinker2");
51 while (true) {
52 palSetPad(GPIOD, GPIOD_LED3);
53 chThdSleepMilliseconds(50);
54 palSetPad(GPIOK, GPIOK_LED4);
55 chThdSleepMilliseconds(300);
56 palClearPad(GPIOD, GPIOD_LED3);
57 chThdSleepMilliseconds(50);
58 palClearPad(GPIOK, GPIOK_LED4);
59 chThdSleepMilliseconds(300);
60 }
61}
62
63/*===========================================================================*/
64/* Command line related. */
65/*===========================================================================*/
66
67#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
68
69static const ShellCommand commands[] = {
70 {NULL, NULL}
71};
72
73static const ShellConfig shell_cfg1 = {
74 (BaseSequentialStream *)&SD3,
75 commands
76};
77
78/*===========================================================================*/
79/* Initialization and main thread. */
80/*===========================================================================*/
81
82/*
83 * Application entry point.
84 */
85int main(void) {
86
87 /*
88 * System initializations.
89 * - HAL initialization, this also initializes the configured device drivers
90 * and performs the board-specific initializations.
91 * - Kernel initialization, the main() function becomes a thread and the
92 * RTOS is active.
93 */
94 halInit();
95 chSysInit();
96
97 /*
98 * Shell manager initialization.
99 */
100 shellInit();
101
102 /*
103 * Activates the serial driver 2 using the driver default configuration.
104 */
105 sdStart(&SD3, NULL);
106
107 /*
108 * Creating the blinker threads.
109 */
110 chThdCreateStatic(waThread1, sizeof(waThread1),
111 NORMALPRIO + 10, Thread1, NULL);
112 chThdSleepMilliseconds(100);
113 chThdCreateStatic(waThread2, sizeof(waThread2),
114 NORMALPRIO + 10, Thread2, NULL);
115
116 /*
117 * Normal main() thread activity, spawning shells.
118 */
119 while (true) {
120 thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
121 "shell", NORMALPRIO + 1,
122 shellThread, (void *)&shell_cfg1);
123 chThdWait(shelltp); /* Waiting termination. */
124 chThdSleepMilliseconds(1000);
125 }
126}