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