git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6260 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2013-09-04 12:24:54 +00:00
parent a923a46007
commit 71ee071933
3 changed files with 30 additions and 7 deletions

View File

@ -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
/*

View File

@ -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.

View File

@ -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.