aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-09-04 12:24:54 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-09-04 12:24:54 +0000
commit71ee071933334f72b5c69ee682cffc9565500215 (patch)
tree64d66b84671c5b23b77eac33e987a3b21bfa592a
parenta923a46007f6ae63deac2183319ba064e7b2921c (diff)
downloadChibiOS-71ee071933334f72b5c69ee682cffc9565500215.tar.gz
ChibiOS-71ee071933334f72b5c69ee682cffc9565500215.tar.bz2
ChibiOS-71ee071933334f72b5c69ee682cffc9565500215.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6260 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/nil/NIL-STM32F051-DISCOVERY/main.c31
-rw-r--r--demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h2
-rw-r--r--os/hal/include/hal_channels.h4
3 files changed, 30 insertions, 7 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.
diff --git a/os/hal/include/hal_channels.h b/os/hal/include/hal_channels.h
index bd9a26c77..06198b5e1 100644
--- a/os/hal/include/hal_channels.h
+++ b/os/hal/include/hal_channels.h
@@ -143,7 +143,7 @@ typedef struct {
*
* @api
*/
-#define chnWrite(ip, bp, n) chSequentialStreamWrite(ip, bp, n)
+#define chnWrite(ip, bp, n) streamSequentialStreamWrite(ip, bp, n)
/**
* @brief Channel blocking write with timeout.
@@ -177,7 +177,7 @@ typedef struct {
*
* @api
*/
-#define chnRead(ip, bp, n) chSequentialStreamRead(ip, bp, n)
+#define chnRead(ip, bp, n) streamSequentialStreamRead(ip, bp, n)
/**
* @brief Channel blocking read with timeout.