aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c')
-rw-r--r--lib/chibios-contrib/demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c123
1 files changed, 123 insertions, 0 deletions
diff --git a/lib/chibios-contrib/demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c b/lib/chibios-contrib/demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c
new file mode 100644
index 000000000..4afc71f59
--- /dev/null
+++ b/lib/chibios-contrib/demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c
@@ -0,0 +1,123 @@
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(waBlinkLed1, 128);
32static THD_WORKING_AREA(waBlinkLed2, 128);
33static THD_WORKING_AREA(waBlinkLed3, 128);
34static THD_WORKING_AREA(waBlinkLed4, 128);
35static THD_FUNCTION(blinkLed, arg) {
36 led_config_t *ledConfig = (led_config_t*) arg;
37
38 chRegSetThreadName("Blinker");
39
40 /* Configure pin as push-pull output.*/
41 palSetLineMode(ledConfig->line, PAL_MODE_OUTPUT_PUSHPULL);
42
43 while (TRUE) {
44 chThdSleepMilliseconds(ledConfig->sleep);
45 palToggleLine(ledConfig->line);
46 }
47}
48
49/*
50 * Application entry point.
51 */
52int main(void)
53{
54 led_config_t led1, led2, led3, led4;
55
56 /*
57 * System initializations.
58 * - HAL initialization, this also initializes the configured device drivers
59 * and performs the board-specific initializations.
60 * - Kernel initialization, the main() function becomes a thread and the
61 * RTOS is active.
62 */
63 halInit();
64 chSysInit();
65
66 /* Configure RX and TX pins for UART0.*/
67 palSetLineMode(LINE_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
68 palSetLineMode(LINE_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
69
70 /* Start the serial driver with the default configuration.*/
71 sdStart(&SD1, NULL);
72
73 if (!palReadLine(LINE_SW1)) {
74 test_execute((BaseSequentialStream *)&SD1, &rt_test_suite);
75 test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite);
76 }
77
78 led1.line = LINE_LED0;
79 led1.sleep = 100;
80
81 led2.line = LINE_LED1;
82 led2.sleep = 101;
83
84 led3.line = LINE_LED2;
85 led3.sleep = 102;
86
87 led4.line = LINE_LED3;
88 led4.sleep = 103;
89
90 /* Creating the blinker threads.*/
91 chThdCreateStatic(waBlinkLed1,
92 sizeof(waBlinkLed1),
93 NORMALPRIO,
94 blinkLed,
95 &led1);
96
97 chThdCreateStatic(waBlinkLed2,
98 sizeof(waBlinkLed2),
99 NORMALPRIO,
100 blinkLed,
101 &led2);
102
103 chThdCreateStatic(waBlinkLed3,
104 sizeof(waBlinkLed3),
105 NORMALPRIO,
106 blinkLed,
107 &led3);
108
109 chThdCreateStatic(waBlinkLed4,
110 sizeof(waBlinkLed4),
111 NORMALPRIO,
112 blinkLed,
113 &led4);
114
115 /*
116 * Normal main() thread activity
117 */
118 while (TRUE) {
119 chThdSleepMilliseconds(100);
120 }
121
122 return 0;
123}