diff options
Diffstat (limited to 'lib/chibios-contrib/demos/KINETIS/RT-FREEDOM-KL25Z-SHELL/main.c')
-rw-r--r-- | lib/chibios-contrib/demos/KINETIS/RT-FREEDOM-KL25Z-SHELL/main.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/lib/chibios-contrib/demos/KINETIS/RT-FREEDOM-KL25Z-SHELL/main.c b/lib/chibios-contrib/demos/KINETIS/RT-FREEDOM-KL25Z-SHELL/main.c new file mode 100644 index 000000000..99eeeb2da --- /dev/null +++ b/lib/chibios-contrib/demos/KINETIS/RT-FREEDOM-KL25Z-SHELL/main.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Jonathan Struebel | ||
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 | #include "hal.h" | ||
17 | |||
18 | #include "shellcfg.h" | ||
19 | |||
20 | SerialConfig s0cfg = { | ||
21 | 115200 | ||
22 | }; | ||
23 | |||
24 | /* | ||
25 | * Blue LED blinker thread, times are in milliseconds. | ||
26 | */ | ||
27 | static THD_WORKING_AREA(waBlinkThread, 128); | ||
28 | static THD_FUNCTION(BlinkThread, arg) { | ||
29 | systime_t time = 500; | ||
30 | |||
31 | (void)arg; | ||
32 | |||
33 | chRegSetThreadName("blinker"); | ||
34 | while (true) { | ||
35 | palTogglePad(GPIO_LED_BLUE, PIN_LED_BLUE); | ||
36 | chThdSleepMilliseconds(time); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | /* | ||
41 | * Application entry point. | ||
42 | */ | ||
43 | int main(void) { | ||
44 | /* | ||
45 | * System initializations. | ||
46 | * - HAL initialization, this also initializes the configured device drivers | ||
47 | * and performs the board-specific initializations. | ||
48 | * - Kernel initialization, the main() function becomes a thread and the | ||
49 | * RTOS is active. | ||
50 | */ | ||
51 | halInit(); | ||
52 | chSysInit(); | ||
53 | |||
54 | /* | ||
55 | * Turn off the RGB LED. | ||
56 | */ | ||
57 | palSetPad(GPIO_LED_RED, PIN_LED_RED); /* red */ | ||
58 | palSetPad(GPIO_LED_GREEN, PIN_LED_GREEN); /* green */ | ||
59 | palSetPad(GPIO_LED_BLUE, PIN_LED_BLUE); /* blue */ | ||
60 | |||
61 | sdStart(&SD1, &s0cfg); | ||
62 | |||
63 | /* | ||
64 | * Shell manager initialization. | ||
65 | */ | ||
66 | shellInit(); | ||
67 | |||
68 | /* | ||
69 | * Creates the blinker thread. | ||
70 | */ | ||
71 | chThdCreateStatic(waBlinkThread, sizeof(waBlinkThread), NORMALPRIO, BlinkThread, NULL); | ||
72 | |||
73 | while (true) { | ||
74 | if (SD1.state == SD_READY) { | ||
75 | thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, | ||
76 | "shell", NORMALPRIO + 1, | ||
77 | shellThread, (void *)&shell_cfg); | ||
78 | chThdWait(shelltp); /* Waiting termination. */ | ||
79 | } | ||
80 | palTogglePad(GPIO_LED_RED, PIN_LED_RED); | ||
81 | chThdSleepMilliseconds(1000); | ||
82 | } | ||
83 | } | ||