From 0a09cc089d0c8947b4309952482a24a1cafd2477 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 21 Feb 2010 11:29:54 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1650 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 222 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 demos/Posix-GCC/main.c (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c new file mode 100644 index 000000000..28e136bc8 --- /dev/null +++ b/demos/Posix-GCC/main.c @@ -0,0 +1,222 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include + +#include "ch.h" +#include "hal.h" +#include "test.h" +#include "shell.h" + +#define SHELL_WA_SIZE THD_WA_SIZE(4096) +#define CONSOLE_WA_SIZE THD_WA_SIZE(4096) +#define TEST_WA_SIZE THD_WA_SIZE(4096) + +#define cputs(msg) chMsgSend(cdtp, (msg_t)msg) + +static Thread *cdtp; +static Thread *shelltp1; +static Thread *shelltp2; + +void cmd_test(BaseChannel *chp, int argc, char *argv[]) { + Thread *tp; + + (void)argv; + if (argc > 0) { + shellPrintLine(chp, "Usage: test"); + return; + } + tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriority(), + TestThread, chp); + if (tp == NULL) { + shellPrintLine(chp, "out of memory"); + return; + } + chThdWait(tp); +} + +static const ShellCommand commands[] = { + {"test", cmd_test}, + {NULL, NULL} +}; + +static const ShellConfig shell_cfg1 = { + (BaseChannel *)&SD1, + commands +}; + +static const ShellConfig shell_cfg2 = { + (BaseChannel *)&SD2, + commands +}; + +/* + * Console print server done using synchronous messages. This makes the access + * to the C printf() thread safe and the print operation atomic among threads. + * In this example the message is the zero termitated string itself. + */ +static msg_t console_thread(void *arg) { + + (void)arg; + while (!chThdShouldTerminate()) { + puts((char *)chMsgWait()); + fflush(stdout); + chMsgRelease(RDY_OK); + } + return 0; +} + +/** + * @brief Shell termination handler. + * + * @param[in] id event id. + */ +static void termination_handler(eventid_t id) { + + (void)id; + if (shelltp1 && chThdTerminated(shelltp1)) { + chThdWait(shelltp1); + shelltp1 = NULL; + chThdSleepMilliseconds(10); + cputs("Init: shell on SD1 terminated"); + chSysLock(); + chOQResetI(&SD1.oqueue); + chSysUnlock(); + } + if (shelltp2 && chThdTerminated(shelltp2)) { + chThdWait(shelltp2); + shelltp2 = NULL; + chThdSleepMilliseconds(10); + cputs("Init: shell on SD2 terminated"); + chSysLock(); + chOQResetI(&SD2.oqueue); + chSysUnlock(); + } +} + +/** + * @brief SD1 status change handler. + * + * @param[in] id event id. + */ +static void sd1_handler(eventid_t id) { + + sdflags_t flags; + + (void)id; + flags = sdGetAndClearFlags(&SD1); + if ((flags & SD_CONNECTED) && (shelltp1 == NULL)) { + cputs("Init: connection on SD1"); + shelltp1 = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO + 1); + } + if (flags & SD_DISCONNECTED) { + cputs("Init: disconnection on SD1"); + chSysLock(); + chIQResetI(&SD1.iqueue); + chSysUnlock(); + } +} + +/** + * @brief SD2 status change handler. + * + * @param[in] id event id. + */ +static void sd2_handler(eventid_t id) { + + sdflags_t flags; + + (void)id; + flags = sdGetAndClearFlags(&SD2); + if ((flags & SD_CONNECTED) && (shelltp2 == NULL)) { + cputs("Init: connection on SD2"); + shelltp2 = shellCreate(&shell_cfg2, SHELL_WA_SIZE, NORMALPRIO + 10); + } + if (flags & SD_DISCONNECTED) { + cputs("Init: disconnection on SD2"); + chSysLock(); + chIQResetI(&SD2.iqueue); + chSysUnlock(); + } +} + +static evhandler_t fhandlers[] = { + termination_handler, + sd1_handler, + sd2_handler +}; + +/*------------------------------------------------------------------------* + * Simulator main. * + *------------------------------------------------------------------------*/ +int main(void) { + EventListener sd1fel, sd2fel, tel; + + /* + * HAL initialization. + */ + halInit(); + + /* + * ChibiOS/RT initialization. + */ + chSysInit(); + + /* + * Serial ports (simulated) initialization. + */ + sdStart(&SD1, NULL); + sdStart(&SD2, NULL); + + /* + * Shell manager initialization. + */ + shellInit(); + chEvtRegister(&shell_terminated, &tel, 0); + + /* + * Console thread started. + */ + cdtp = chThdCreateFromHeap(NULL, CONSOLE_WA_SIZE, NORMALPRIO + 1, + console_thread, NULL); + + /* + * Initializing connection/disconnection events. + */ + cputs("Shell service started on SD1, SD2"); + cputs(" - Listening for connections on SD1"); + (void) sdGetAndClearFlags(&SD1); + chEvtRegister(&SD1.sevent, &sd1fel, 1); + cputs(" - Listening for connections on SD2"); + (void) sdGetAndClearFlags(&SD2); + chEvtRegister(&SD2.sevent, &sd2fel, 2); + + /* + * Events servicing loop. + */ + while (!chThdShouldTerminate()) + chEvtDispatch(fhandlers, chEvtWaitOne(ALL_EVENTS)); + + /* + * Clean simulator exit. + */ + chEvtUnregister(&SD1.sevent, &sd1fel); + chEvtUnregister(&SD2.sevent, &sd2fel); + return 0; +} -- cgit v1.2.3 From 7c1828c96c3b05cba909d6051d112725f2310d66 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 19 Dec 2010 11:38:07 +0000 Subject: Updated Posix simulator. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2508 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index 28e136bc8..fdce30ffd 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -169,13 +169,13 @@ int main(void) { EventListener sd1fel, sd2fel, tel; /* - * HAL initialization. + * System initializations. + * - HAL initialization, this also initializes the configured device drivers + * and performs the board-specific initializations. + * - Kernel initialization, the main() function becomes a thread and the + * RTOS is active. */ halInit(); - - /* - * ChibiOS/RT initialization. - */ chSysInit(); /* -- cgit v1.2.3 From 700b05269e497d468e095b55bb562659d7b9a7e3 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 9 Jan 2011 10:31:53 +0000 Subject: Posix demo updated and re-tested. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2626 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index fdce30ffd..0ce59da9d 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -116,16 +116,15 @@ static void termination_handler(eventid_t id) { * @param[in] id event id. */ static void sd1_handler(eventid_t id) { - - sdflags_t flags; + ioflags_t flags; (void)id; - flags = sdGetAndClearFlags(&SD1); - if ((flags & SD_CONNECTED) && (shelltp1 == NULL)) { + flags = chIOGetAndClearFlags(&SD1); + if ((flags & IO_CONNECTED) && (shelltp1 == NULL)) { cputs("Init: connection on SD1"); shelltp1 = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO + 1); } - if (flags & SD_DISCONNECTED) { + if (flags & IO_DISCONNECTED) { cputs("Init: disconnection on SD1"); chSysLock(); chIQResetI(&SD1.iqueue); @@ -139,16 +138,15 @@ static void sd1_handler(eventid_t id) { * @param[in] id event id. */ static void sd2_handler(eventid_t id) { - - sdflags_t flags; + ioflags_t flags; (void)id; - flags = sdGetAndClearFlags(&SD2); - if ((flags & SD_CONNECTED) && (shelltp2 == NULL)) { + flags = chIOGetAndClearFlags(&SD2); + if ((flags & IO_CONNECTED) && (shelltp2 == NULL)) { cputs("Init: connection on SD2"); shelltp2 = shellCreate(&shell_cfg2, SHELL_WA_SIZE, NORMALPRIO + 10); } - if (flags & SD_DISCONNECTED) { + if (flags & IO_DISCONNECTED) { cputs("Init: disconnection on SD2"); chSysLock(); chIQResetI(&SD2.iqueue); @@ -201,11 +199,11 @@ int main(void) { */ cputs("Shell service started on SD1, SD2"); cputs(" - Listening for connections on SD1"); - (void) sdGetAndClearFlags(&SD1); - chEvtRegister(&SD1.sevent, &sd1fel, 1); + (void) chIOGetAndClearFlags(&SD1); + chEvtRegister(chIOGetEventSource(&SD1), &sd1fel, 1); cputs(" - Listening for connections on SD2"); - (void) sdGetAndClearFlags(&SD2); - chEvtRegister(&SD2.sevent, &sd2fel, 2); + (void) chIOGetAndClearFlags(&SD2); + chEvtRegister(chIOGetEventSource(&SD2), &sd2fel, 2); /* * Events servicing loop. @@ -216,7 +214,7 @@ int main(void) { /* * Clean simulator exit. */ - chEvtUnregister(&SD1.sevent, &sd1fel); - chEvtUnregister(&SD2.sevent, &sd2fel); + chEvtUnregister(chIOGetEventSource(&SD1), &sd1fel); + chEvtUnregister(chIOGetEventSource(&SD2), &sd2fel); return 0; } -- cgit v1.2.3 From e7e79a6ccb4f3e320b2b8b7bad1b14d65218641d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 18 Mar 2011 18:38:08 +0000 Subject: License updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2827 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index 0ce59da9d..adfcf6925 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -1,5 +1,6 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 698e37b41c08fd2a3b250ba3d0737c942af14f19 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 15 Aug 2011 08:49:20 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3236 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index adfcf6925..543386a85 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -24,6 +24,7 @@ #include "hal.h" #include "test.h" #include "shell.h" +#include "chprintf.h" #define SHELL_WA_SIZE THD_WA_SIZE(4096) #define CONSOLE_WA_SIZE THD_WA_SIZE(4096) @@ -35,24 +36,76 @@ static Thread *cdtp; static Thread *shelltp1; static Thread *shelltp2; -void cmd_test(BaseChannel *chp, int argc, char *argv[]) { +static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { + size_t n, size; + + (void)argv; + if (argc > 0) { + chprintf(chp, "Usage: mem\r\n"); + return; + } + n = chHeapStatus(NULL, &size); + chprintf(chp, "core free memory : %u bytes\r\n", chCoreStatus()); + chprintf(chp, "heap fragments : %u\r\n", n); + chprintf(chp, "heap free total : %u bytes\r\n", size); +} + +static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { + static const char *states[] = { + "READY", + "CURRENT", + "SUSPENDED", + "WTSEM", + "WTMTX", + "WTCOND", + "SLEEPING", + "WTEXIT", + "WTOREVT", + "WTANDEVT", + "SNDMSGQ", + "SNDMSG", + "WTMSG", + "WTQUEUE", + "FINAL" + }; + Thread *tp; + + (void)argv; + if (argc > 0) { + chprintf(chp, "Usage: threads\r\n"); + return; + } + chprintf(chp, " addr stack prio refs state time\r\n"); + tp = chRegFirstThread(); + do { + chprintf(chp, "%.8lx %.8lx %4lu %4lu %9s %lu\r\n", + (uint32_t)tp, (uint32_t)tp->p_ctx.esp, + (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1), + states[tp->p_state], (uint32_t)tp->p_time); + tp = chRegNextThread(tp); + } while (tp != NULL); +} + +static void cmd_test(BaseChannel *chp, int argc, char *argv[]) { Thread *tp; (void)argv; if (argc > 0) { - shellPrintLine(chp, "Usage: test"); + chprintf(chp, "Usage: test\r\n"); return; } tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriority(), TestThread, chp); if (tp == NULL) { - shellPrintLine(chp, "out of memory"); + chprintf(chp, "out of memory\r\n"); return; } chThdWait(tp); } static const ShellCommand commands[] = { + {"mem", cmd_mem}, + {"threads", cmd_threads}, {"test", cmd_test}, {NULL, NULL} }; @@ -76,9 +129,10 @@ static msg_t console_thread(void *arg) { (void)arg; while (!chThdShouldTerminate()) { - puts((char *)chMsgWait()); + Thread *tp = chMsgWait(); + puts((char *)chMsgGet(tp)); fflush(stdout); - chMsgRelease(RDY_OK); + chMsgRelease(tp, RDY_OK); } return 0; } -- cgit v1.2.3 From 309b1e411426e8d36d9a552ef2870da3db912a80 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 23 Oct 2011 11:39:45 +0000 Subject: Improvements to the USB driver, first phase. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3449 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index 543386a85..4904edec0 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -51,23 +51,7 @@ static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { } static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { - static const char *states[] = { - "READY", - "CURRENT", - "SUSPENDED", - "WTSEM", - "WTMTX", - "WTCOND", - "SLEEPING", - "WTEXIT", - "WTOREVT", - "WTANDEVT", - "SNDMSGQ", - "SNDMSG", - "WTMSG", - "WTQUEUE", - "FINAL" - }; + static const char *states[] = {THD_STATE_NAMES}; Thread *tp; (void)argv; -- cgit v1.2.3 From de5dcbba856524599a8f06d3a9bdbf1b01db44c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Jan 2012 14:29:42 +0000 Subject: License text updated with new year. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3846 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index 4904edec0..7b4a6750e 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011 Giovanni Di Sirio. + 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From c0f45d51ff8b2fa93602c3bf20755d586fd4b668 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 22 Jul 2012 08:13:52 +0000 Subject: Fixed Posix simulator demo. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4473 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index 7b4a6750e..afab51319 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -36,7 +36,7 @@ static Thread *cdtp; static Thread *shelltp1; static Thread *shelltp2; -static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { +static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) { size_t n, size; (void)argv; @@ -50,7 +50,7 @@ static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { chprintf(chp, "heap free total : %u bytes\r\n", size); } -static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { +static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) { static const char *states[] = {THD_STATE_NAMES}; Thread *tp; @@ -70,7 +70,7 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { } while (tp != NULL); } -static void cmd_test(BaseChannel *chp, int argc, char *argv[]) { +static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) { Thread *tp; (void)argv; @@ -95,12 +95,12 @@ static const ShellCommand commands[] = { }; static const ShellConfig shell_cfg1 = { - (BaseChannel *)&SD1, + (BaseSequentialStream *)&SD1, commands }; static const ShellConfig shell_cfg2 = { - (BaseChannel *)&SD2, + (BaseSequentialStream *)&SD2, commands }; @@ -155,15 +155,15 @@ static void termination_handler(eventid_t id) { * @param[in] id event id. */ static void sd1_handler(eventid_t id) { - ioflags_t flags; + chnflags_t flags; (void)id; - flags = chIOGetAndClearFlags(&SD1); - if ((flags & IO_CONNECTED) && (shelltp1 == NULL)) { + flags = chnGetAndClearFlags(&SD1); + if ((flags & CHN_CONNECTED) && (shelltp1 == NULL)) { cputs("Init: connection on SD1"); shelltp1 = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO + 1); } - if (flags & IO_DISCONNECTED) { + if (flags & CHN_DISCONNECTED) { cputs("Init: disconnection on SD1"); chSysLock(); chIQResetI(&SD1.iqueue); @@ -177,15 +177,15 @@ static void sd1_handler(eventid_t id) { * @param[in] id event id. */ static void sd2_handler(eventid_t id) { - ioflags_t flags; + chnflags_t flags; (void)id; - flags = chIOGetAndClearFlags(&SD2); - if ((flags & IO_CONNECTED) && (shelltp2 == NULL)) { + flags = chnGetAndClearFlags(&SD2); + if ((flags & CHN_CONNECTED) && (shelltp2 == NULL)) { cputs("Init: connection on SD2"); shelltp2 = shellCreate(&shell_cfg2, SHELL_WA_SIZE, NORMALPRIO + 10); } - if (flags & IO_DISCONNECTED) { + if (flags & CHN_DISCONNECTED) { cputs("Init: disconnection on SD2"); chSysLock(); chIQResetI(&SD2.iqueue); @@ -238,11 +238,11 @@ int main(void) { */ cputs("Shell service started on SD1, SD2"); cputs(" - Listening for connections on SD1"); - (void) chIOGetAndClearFlags(&SD1); - chEvtRegister(chIOGetEventSource(&SD1), &sd1fel, 1); + (void) chnGetAndClearFlags(&SD1); + chEvtRegister(chnGetEventSource(&SD1), &sd1fel, 1); cputs(" - Listening for connections on SD2"); - (void) chIOGetAndClearFlags(&SD2); - chEvtRegister(chIOGetEventSource(&SD2), &sd2fel, 2); + (void) chnGetAndClearFlags(&SD2); + chEvtRegister(chnGetEventSource(&SD2), &sd2fel, 2); /* * Events servicing loop. @@ -253,7 +253,7 @@ int main(void) { /* * Clean simulator exit. */ - chEvtUnregister(chIOGetEventSource(&SD1), &sd1fel); - chEvtUnregister(chIOGetEventSource(&SD2), &sd2fel); + chEvtUnregister(chnGetEventSource(&SD1), &sd1fel); + chEvtUnregister(chnGetEventSource(&SD2), &sd2fel); return 0; } -- cgit v1.2.3 From f90a0f37906a9363a6e702d8ac1c4c8257370efa Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 16 Sep 2012 09:08:43 +0000 Subject: Removed flags handling in BaseAsynchronousChannel. Modified serial drivers to use the new event flags. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4671 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index afab51319..bcdc6636b 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -149,16 +149,18 @@ static void termination_handler(eventid_t id) { } } +static EventListener sd1fel, sd2fel; + /** * @brief SD1 status change handler. * * @param[in] id event id. */ static void sd1_handler(eventid_t id) { - chnflags_t flags; + flagsmask_t flags; (void)id; - flags = chnGetAndClearFlags(&SD1); + flags = chEvtGetAndClearFlags(&sd1fel); if ((flags & CHN_CONNECTED) && (shelltp1 == NULL)) { cputs("Init: connection on SD1"); shelltp1 = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO + 1); @@ -177,10 +179,10 @@ static void sd1_handler(eventid_t id) { * @param[in] id event id. */ static void sd2_handler(eventid_t id) { - chnflags_t flags; + flagsmask_t flags; (void)id; - flags = chnGetAndClearFlags(&SD2); + flags = chEvtGetAndClearFlags(&sd2fel); if ((flags & CHN_CONNECTED) && (shelltp2 == NULL)) { cputs("Init: connection on SD2"); shelltp2 = shellCreate(&shell_cfg2, SHELL_WA_SIZE, NORMALPRIO + 10); @@ -238,10 +240,8 @@ int main(void) { */ cputs("Shell service started on SD1, SD2"); cputs(" - Listening for connections on SD1"); - (void) chnGetAndClearFlags(&SD1); chEvtRegister(chnGetEventSource(&SD1), &sd1fel, 1); cputs(" - Listening for connections on SD2"); - (void) chnGetAndClearFlags(&SD2); chEvtRegister(chnGetEventSource(&SD2), &sd2fel, 2); /* -- cgit v1.2.3 From 9d1013bf3117d74c668f2430c80f49271703737e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 29 Sep 2012 08:31:53 +0000 Subject: Fixed bug 3570532. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4725 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index bcdc6636b..7514faebf 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -18,8 +18,6 @@ along with this program. If not, see . */ -#include - #include "ch.h" #include "hal.h" #include "test.h" @@ -107,7 +105,7 @@ static const ShellConfig shell_cfg2 = { /* * Console print server done using synchronous messages. This makes the access * to the C printf() thread safe and the print operation atomic among threads. - * In this example the message is the zero termitated string itself. + * In this example the message is the zero terminated string itself. */ static msg_t console_thread(void *arg) { @@ -205,7 +203,7 @@ static evhandler_t fhandlers[] = { * Simulator main. * *------------------------------------------------------------------------*/ int main(void) { - EventListener sd1fel, sd2fel, tel; + EventListener tel; /* * System initializations. -- cgit v1.2.3 From a82dec52e68b99553e1793f46e49e297f03df635 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 26 Jan 2013 10:40:00 +0000 Subject: Fixed bug 3601621. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5091 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index 7514faebf..d4ed8f9c8 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -18,6 +18,8 @@ along with this program. If not, see . */ +#include + #include "ch.h" #include "hal.h" #include "test.h" -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index d4ed8f9c8..6d4785f63 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 853216256ad4cdacf5f94edb7d6b738c6be165a1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 30 Mar 2013 10:32:37 +0000 Subject: Relicensing parts of the tree under the Apache 2.0 license. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5521 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Posix-GCC/main.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'demos/Posix-GCC/main.c') diff --git a/demos/Posix-GCC/main.c b/demos/Posix-GCC/main.c index 6d4785f63..4aa18837d 100644 --- a/demos/Posix-GCC/main.c +++ b/demos/Posix-GCC/main.c @@ -1,21 +1,17 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012,2013 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - This file is part of ChibiOS/RT. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - ChibiOS/RT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + http://www.apache.org/licenses/LICENSE-2.0 - ChibiOS/RT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ #include -- cgit v1.2.3