diff options
Diffstat (limited to 'demos')
-rw-r--r-- | demos/nil/NIL-STM32F051-DISCOVERY/main.c | 31 | ||||
-rw-r--r-- | demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h | 2 |
2 files changed, 28 insertions, 5 deletions
diff --git a/demos/nil/NIL-STM32F051-DISCOVERY/main.c b/demos/nil/NIL-STM32F051-DISCOVERY/main.c index 60eab1fd1..b27cd5911 100644 --- a/demos/nil/NIL-STM32F051-DISCOVERY/main.c +++ b/demos/nil/NIL-STM32F051-DISCOVERY/main.c @@ -31,7 +31,7 @@ THD_FUNCTION(Thread1, arg) { while (true) {
palSetPad(GPIOC, GPIOC_LED4);
chThdSleepMilliseconds(500);
- palSetPad(GPIOC, GPIOC_LED4);
+ palClearPad(GPIOC, GPIOC_LED4);
chThdSleepMilliseconds(500);
}
}
@@ -47,18 +47,41 @@ THD_FUNCTION(Thread2, arg) { while (true) {
palSetPad(GPIOC, GPIOC_LED3);
chThdSleepMilliseconds(250);
- palSetPad(GPIOC, GPIOC_LED3);
+ palClearPad(GPIOC, GPIOC_LED3);
chThdSleepMilliseconds(250);
}
}
/*
+ * Thread 3.
+ */
+THD_WORKING_AREA(waThread3, 128);
+THD_FUNCTION(Thread3, arg) {
+
+ (void)arg;
+
+ /*
+ * Activates the serial driver 1 using the driver default configuration.
+ * PA9 and PA10 are routed to USART1.
+ */
+ sdStart(&SD1, NULL);
+ palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(1)); /* USART1 TX. */
+ palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(1)); /* USART1 RX. */
+
+ while (true) {
+ chnWrite(&SD1, (const uint8_t *)"Hello World!\r\n", 14);
+ chThdSleepMilliseconds(2000);
+ }
+}
+
+/*
* Threads static table, one entry per thread. The number of entries must
* match NIL_CFG_NUM_THREADS.
*/
THD_TABLE_BEGIN
- THD_TABLE_ENTRY("thread1", Thread1, NULL, waThread1, sizeof(waThread1))
- THD_TABLE_ENTRY("thread2", Thread2, NULL, waThread2, sizeof(waThread2))
+ THD_TABLE_ENTRY("blinker1", Thread1, NULL, waThread1, sizeof(waThread1))
+ THD_TABLE_ENTRY("blinker2", Thread2, NULL, waThread2, sizeof(waThread2))
+ THD_TABLE_ENTRY("hello", Thread3, NULL, waThread3, sizeof(waThread3))
THD_TABLE_END
/*
diff --git a/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h b/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h index 8c3293769..c8a0b34c5 100644 --- a/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h +++ b/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h @@ -36,7 +36,7 @@ * @note This number is not inclusive of the idle thread which is
* Implicitly handled.
*/
-#define NIL_CFG_NUM_THREADS 2
+#define NIL_CFG_NUM_THREADS 3
/**
* @brief System tick frequency.
|