aboutsummaryrefslogtreecommitdiffstats
path: root/demos/TIVA
diff options
context:
space:
mode:
authormarcoveeneman <marco-veeneman@hotmail.com>2015-03-03 23:07:15 +0100
committermarcoveeneman <marco-veeneman@hotmail.com>2015-03-03 23:07:15 +0100
commitc6d7c1f7dc04820eaa5fbfef6f29fb8d79b2b1ff (patch)
tree05a97b918a8a04d06e003885fbe7b5bec3caa6df /demos/TIVA
parentff68a0b1f09bcb5b5ed53a2366a3077bdc18d058 (diff)
downloadChibiOS-Contrib-c6d7c1f7dc04820eaa5fbfef6f29fb8d79b2b1ff.tar.gz
ChibiOS-Contrib-c6d7c1f7dc04820eaa5fbfef6f29fb8d79b2b1ff.tar.bz2
ChibiOS-Contrib-c6d7c1f7dc04820eaa5fbfef6f29fb8d79b2b1ff.zip
Adapted the RT-TM4C123G-LAUNCHPAD and RT-TM4C1294-LAUNCHPAD demos to configure the used pins at runtime and moved the TestThread execution before the blink threads are started.
Diffstat (limited to 'demos/TIVA')
-rw-r--r--demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c48
-rw-r--r--demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c43
2 files changed, 36 insertions, 55 deletions
diff --git a/demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c b/demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c
index bb6e963..0a64adb 100644
--- a/demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c
+++ b/demos/TIVA/RT-TM4C123G-LAUNCHPAD/main.c
@@ -37,6 +37,8 @@ static msg_t blinkLed(void *arg)
chRegSetThreadName("Blinker");
+ palSetPadMode(ledConfig->port, ledConfig->pin, PAL_MODE_OUTPUT_PUSHPULL);
+
while (TRUE) {
chThdSleepMilliseconds(ledConfig->sleep);
palTogglePad(ledConfig->port, ledConfig->pin);
@@ -62,6 +64,17 @@ int main(void)
halInit();
chSysInit();
+ /* Configure RX and TX pins for UART0.*/
+ palSetPadMode(GPIOA, GPIOA_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
+ palSetPadMode(GPIOA, GPIOA_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
+
+ /* Start the serial driver with the default configuration.*/
+ sdStart(&SD1, NULL);
+
+ if (!palReadPad(GPIOF, GPIOF_SW2)) {
+ TestThread(&SD1);
+ }
+
ledRed.port = GPIOF;
ledRed.pin = GPIOF_LED_RED;
ledRed.sleep = 100;
@@ -74,39 +87,18 @@ int main(void)
ledBlue.pin = GPIOF_LED_BLUE;
ledBlue.sleep = 102;
- /*
- * Creating the blinker threads.
- */
- chThdCreateStatic(waBlinkLedRed,
- sizeof(waBlinkLedRed),
- NORMALPRIO,
- blinkLed,
+ /* Creating the blinker threads.*/
+ chThdCreateStatic(waBlinkLedRed, sizeof(waBlinkLedRed), NORMALPRIO, blinkLed,
&ledRed);
- chThdCreateStatic(waBlinkLedGreen,
- sizeof(waBlinkLedGreen),
- NORMALPRIO,
- blinkLed,
- &ledGreen);
+ chThdCreateStatic(waBlinkLedGreen, sizeof(waBlinkLedGreen), NORMALPRIO,
+ blinkLed, &ledGreen);
- chThdCreateStatic(waBlinkLedBlue,
- sizeof(waBlinkLedBlue),
- NORMALPRIO,
- blinkLed,
- &ledBlue);
+ chThdCreateStatic(waBlinkLedBlue, sizeof(waBlinkLedBlue), NORMALPRIO,
+ blinkLed, &ledBlue);
- /*
- * Start the serial driver with the default configuration.
- */
- sdStart(&SD1, NULL);
-
- /*
- * Normal main() thread activity
- */
+ /* Normal main() thread activity.*/
while (TRUE) {
- if (!palReadPad(GPIOF, GPIOF_SW2)) {
- TestThread(&SD1);
- }
chThdSleepMilliseconds(100);
}
diff --git a/demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c b/demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c
index 86262f9..bb2b0e3 100644
--- a/demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c
+++ b/demos/TIVA/RT-TM4C1294-LAUNCHPAD/main.c
@@ -66,6 +66,17 @@ int main(void)
halInit();
chSysInit();
+ /* Configure RX and TX pins for UART0.*/
+ palSetPadMode(GPIOA, GPIOA_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
+ palSetPadMode(GPIOA, GPIOA_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
+
+ /* Start the serial driver with the default configuration.*/
+ sdStart(&SD1, NULL);
+
+ if (!palReadPad(GPIOJ, GPIOJ_SW1)) {
+ TestThread(&SD1);
+ }
+
led1.port = GPIOF;
led1.pin = GPIOF_LED0;
led1.sleep = 100;
@@ -82,45 +93,23 @@ int main(void)
led4.pin = GPION_LED3;
led4.sleep = 103;
- /*
- * Creating the blinker threads.
- */
- chThdCreateStatic(waBlinkLed1,
- sizeof(waBlinkLed1),
- NORMALPRIO,
- blinkLed,
+ /* Creating the blinker threads.*/
+ chThdCreateStatic(waBlinkLed1, sizeof(waBlinkLed1), NORMALPRIO, blinkLed,
&led1);
- chThdCreateStatic(waBlinkLed2,
- sizeof(waBlinkLed2),
- NORMALPRIO,
- blinkLed,
+ chThdCreateStatic(waBlinkLed2, sizeof(waBlinkLed2), NORMALPRIO, blinkLed,
&led2);
- chThdCreateStatic(waBlinkLed3,
- sizeof(waBlinkLed3),
- NORMALPRIO,
- blinkLed,
+ chThdCreateStatic(waBlinkLed3, sizeof(waBlinkLed3), NORMALPRIO, blinkLed,
&led3);
- chThdCreateStatic(waBlinkLed4,
- sizeof(waBlinkLed4),
- NORMALPRIO,
- blinkLed,
+ chThdCreateStatic(waBlinkLed4, sizeof(waBlinkLed4), NORMALPRIO, blinkLed,
&led4);
/*
- * Start the serial driver with the default configuration.
- */
- sdStart(&SD1, NULL);
-
- /*
* Normal main() thread activity
*/
while (TRUE) {
- if (!palReadPad(GPIOJ, GPIOJ_SW1)) {
- TestThread(&SD1);
- }
chThdSleepMilliseconds(100);
}