aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c')
-rw-r--r--lib/chibios-contrib/demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/lib/chibios-contrib/demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c b/lib/chibios-contrib/demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c
new file mode 100644
index 000000000..7feea14fb
--- /dev/null
+++ b/lib/chibios-contrib/demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c
@@ -0,0 +1,110 @@
1/*
2 Copyright (C) 2014..2017 Marco Veeneman
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 "rt_test_root.h"
20#include "oslib_test_root.h"
21
22typedef struct led_config
23{
24 ioline_t line;
25 uint32_t sleep;
26} led_config_t;
27
28/*
29 * LED blinker thread.
30 */
31static THD_WORKING_AREA(waBlinkLedRed, 128);
32static THD_WORKING_AREA(waBlinkLedGreen, 128);
33static THD_WORKING_AREA(waBlinkLedBlue, 128);
34static THD_FUNCTION(blinkLed, arg) {
35 led_config_t *ledConfig = (led_config_t*) arg;
36
37 chRegSetThreadName("Blinker");
38
39 palSetLineMode(ledConfig->line, PAL_MODE_OUTPUT_PUSHPULL);
40
41 while (TRUE) {
42 chThdSleepMilliseconds(ledConfig->sleep);
43 palToggleLine(ledConfig->line);
44 }
45}
46
47/*
48 * Application entry point.
49 */
50int main(void)
51{
52 led_config_t ledRed, ledGreen, ledBlue;
53
54 /*
55 * System initializations.
56 * - HAL initialization, this also initializes the configured device drivers
57 * and performs the board-specific initializations.
58 * - Kernel initialization, the main() function becomes a thread and the
59 * RTOS is active.
60 */
61 halInit();
62 chSysInit();
63
64 /* Configure RX and TX pins for UART0.*/
65 palSetLineMode(LINE_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
66 palSetLineMode(LINE_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
67
68 /* Start the serial driver with the default configuration.*/
69 sdStart(&SD1, NULL);
70
71 if (!palReadLine(LINE_SW2)) {
72 test_execute((BaseSequentialStream *)&SD1, &rt_test_suite);
73 test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite);
74 }
75
76 ledRed.line = LINE_LED_RED;
77 ledRed.sleep = 100;
78
79 ledGreen.line = LINE_LED_GREEN;
80 ledGreen.sleep = 101;
81
82 ledBlue.line = LINE_LED_BLUE;
83 ledBlue.sleep = 102;
84
85 /* Creating the blinker threads.*/
86 chThdCreateStatic(waBlinkLedRed,
87 sizeof(waBlinkLedRed),
88 NORMALPRIO,
89 blinkLed,
90 &ledRed);
91
92 chThdCreateStatic(waBlinkLedGreen,
93 sizeof(waBlinkLedGreen),
94 NORMALPRIO,
95 blinkLed,
96 &ledGreen);
97
98 chThdCreateStatic(waBlinkLedBlue,
99 sizeof(waBlinkLedBlue),
100 NORMALPRIO,
101 blinkLed,
102 &ledBlue);
103
104 /* Normal main() thread activity.*/
105 while (TRUE) {
106 chThdSleepMilliseconds(100);
107 }
108
109 return 0;
110}