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 ++++++++++++++---------------- os/hal/platforms/Posix/serial_lld.c | 6 +++--- os/hal/platforms/Posix/serial_lld.h | 9 --------- os/hal/platforms/Win32/serial_lld.h | 5 ----- 4 files changed, 17 insertions(+), 33 deletions(-) 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; } diff --git a/os/hal/platforms/Posix/serial_lld.c b/os/hal/platforms/Posix/serial_lld.c index 95b654f17..128f3e2fb 100644 --- a/os/hal/platforms/Posix/serial_lld.c +++ b/os/hal/platforms/Posix/serial_lld.c @@ -119,7 +119,7 @@ static bool_t connint(SerialDriver *sdp) { printf("%s: Unable to setup non blocking mode on data socket\n", sdp->com_name); goto abort; } - sdAddFlagsI(sdp, SD_CONNECTED); + chIOAddFlagsI(sdp, IO_CONNECTED); return TRUE; } return FALSE; @@ -145,7 +145,7 @@ static bool_t inint(SerialDriver *sdp) { case 0: close(sdp->com_data); sdp->com_data = INVALID_SOCKET; - sdAddFlagsI(sdp, SD_DISCONNECTED); + chIOAddFlagsI(sdp, IO_DISCONNECTED); return FALSE; case INVALID_SOCKET: if (errno == EWOULDBLOCK) @@ -179,7 +179,7 @@ static bool_t outint(SerialDriver *sdp) { case 0: close(sdp->com_data); sdp->com_data = INVALID_SOCKET; - sdAddFlagsI(sdp, SD_DISCONNECTED); + chIOAddFlagsI(sdp, IO_DISCONNECTED); return FALSE; case INVALID_SOCKET: if (errno == EWOULDBLOCK) diff --git a/os/hal/platforms/Posix/serial_lld.h b/os/hal/platforms/Posix/serial_lld.h index 996af333e..282b68314 100644 --- a/os/hal/platforms/Posix/serial_lld.h +++ b/os/hal/platforms/Posix/serial_lld.h @@ -87,11 +87,6 @@ /* Driver data structures and types. */ /*===========================================================================*/ -/** - * @brief Serial Driver condition flags type. - */ -typedef uint32_t sdflags_t; - /** * @brief Generic Serial Driver configuration structure. * @details An instance of this structure must be passed to @p sdStart() @@ -114,10 +109,6 @@ typedef struct { InputQueue iqueue; \ /* Output queue.*/ \ OutputQueue oqueue; \ - /* Status Change @p EventSource.*/ \ - EventSource sevent; \ - /* I/O driver status flags.*/ \ - sdflags_t flags; \ /* Input circular buffer.*/ \ uint8_t ib[SERIAL_BUFFERS_SIZE]; \ /* Output circular buffer.*/ \ diff --git a/os/hal/platforms/Win32/serial_lld.h b/os/hal/platforms/Win32/serial_lld.h index 5adf63998..fd6bff34d 100644 --- a/os/hal/platforms/Win32/serial_lld.h +++ b/os/hal/platforms/Win32/serial_lld.h @@ -83,11 +83,6 @@ /* Driver data structures and types. */ /*===========================================================================*/ -/** - * @brief Serial Driver condition flags type. - */ -typedef uint32_t sdflags_t; - /** * @brief Generic Serial Driver configuration structure. * @details An instance of this structure must be passed to @p sdStart() -- cgit v1.2.3