From 71ee071933334f72b5c69ee682cffc9565500215 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 4 Sep 2013 12:24:54 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6260 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/nil/NIL-STM32F051-DISCOVERY/main.c | 31 ++++++++++++++++++--- demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h | 2 +- os/hal/include/hal_channels.h | 4 +-- 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.