From 1f7dd2586a16b6f47ba6214faf954481de6c4086 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 3 May 2009 10:43:54 +0000 Subject: [PATCH] Adjusted LPC214x serial driver and MinGW demo because the latest changes. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@942 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/Win32-MinGW/main.c | 30 ++++++++++++++++++----------- ports/ARM7-LPC214x/lpc214x_serial.c | 12 ++++++------ todo.txt | 4 ++-- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/demos/Win32-MinGW/main.c b/demos/Win32-MinGW/main.c index c2ac24868..68dc4eb06 100644 --- a/demos/Win32-MinGW/main.c +++ b/demos/Win32-MinGW/main.c @@ -83,7 +83,7 @@ static bool_t GetLineFDD(FullDuplexDriver *sd, char *line, int size) { char *p = line; while (TRUE) { - short c = chIQGet(&sd->sd_iqueue); + short c = chIQGet(&sd->d2.iqueue); if (c < 0) return TRUE; if (c == 4) { @@ -162,8 +162,10 @@ static msg_t ShellThread(void *arg) { Thread *tp; WORKING_AREA(tarea, 2048); - chIQReset(&sd->sd_iqueue); - chOQReset(&sd->sd_oqueue); + chSysLock(); + chIQResetI(&sd->d2.iqueue); + chOQResetI(&sd->d2.oqueue); + chSysUnlock(); PrintLineFDD(sd, "ChibiOS/RT Command Shell\r\n\n"); while (TRUE) { PrintLineFDD(sd, "ch> "); @@ -241,8 +243,11 @@ static void COM1Handler(eventid_t id) { chEvtRegister(chThdGetExitEventSource(s1), &s1tel, 0); chThdResume(s1); } - if ((flags & SD_DISCONNECTED) && (s1 != NULL)) - chIQReset(&COM1.sd_iqueue); + if ((flags & SD_DISCONNECTED) && (s1 != NULL)) { + chSysLock(); + chIQResetI(&COM1.d2.iqueue); + chSysUnlock(); + } } static WORKING_AREA(s2area, 4096); @@ -264,8 +269,11 @@ static void COM2Handler(eventid_t id) { chEvtRegister(chThdGetExitEventSource(s2), &s2tel, 1); chThdResume(s2); } - if ((flags & SD_DISCONNECTED) && (s2 != NULL)) - chIQReset(&COM2.sd_iqueue); + if ((flags & SD_DISCONNECTED) && (s2 != NULL)) { + chSysLock(); + chIQResetI(&COM2.d2.iqueue); + chSysUnlock(); + } } static evhandler_t fhandlers[2] = { @@ -288,13 +296,13 @@ int main(void) { cprint("Console service started on COM1, COM2\n"); cprint(" - Listening for connections on COM1\n"); chFDDGetAndClearFlags(&COM1); - chEvtRegister(&COM1.sd_sevent, &c1fel, 0); + chEvtRegister(&COM1.d2.sevent, &c1fel, 0); cprint(" - Listening for connections on COM2\n"); chFDDGetAndClearFlags(&COM2); - chEvtRegister(&COM2.sd_sevent, &c2fel, 1); + chEvtRegister(&COM2.d2.sevent, &c2fel, 1); while (!chThdShouldTerminate()) chEvtDispatch(fhandlers, chEvtWaitOne(ALL_EVENTS)); - chEvtUnregister(&COM2.sd_sevent, &c2fel); // Never invoked but this is an example... - chEvtUnregister(&COM1.sd_sevent, &c1fel); // Never invoked but this is an example... + chEvtUnregister(&COM2.d2.sevent, &c2fel); // Never invoked but this is an example... + chEvtUnregister(&COM1.d2.sevent, &c1fel); // Never invoked but this is an example... return 0; } diff --git a/ports/ARM7-LPC214x/lpc214x_serial.c b/ports/ARM7-LPC214x/lpc214x_serial.c index f9ed67260..e452cec8d 100644 --- a/ports/ARM7-LPC214x/lpc214x_serial.c +++ b/ports/ARM7-LPC214x/lpc214x_serial.c @@ -92,12 +92,12 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) { case IIR_SRC_RX: while (u->UART_LSR & LSR_RBR_FULL) { chSysLockFromIsr(); - if (chIQPutI(&com->sd_iqueue, u->UART_RBR) < Q_OK) + if (chIQPutI(&com->d2.iqueue, u->UART_RBR) < Q_OK) chFDDAddFlagsI(com, SD_OVERRUN_ERROR); chSysUnlockFromIsr(); } chSysLockFromIsr(); - chEvtBroadcastI(&com->sd_ievent); + chEvtBroadcastI(&com->d1.ievent); chSysUnlockFromIsr(); break; case IIR_SRC_TX: @@ -106,12 +106,12 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) { int i = UART_FIFO_PRELOAD; do { chSysLockFromIsr(); - msg_t b = chOQGetI(&com->sd_oqueue); + msg_t b = chOQGetI(&com->d2.oqueue); chSysUnlockFromIsr(); if (b < Q_OK) { u->UART_IER &= ~IER_THRE; chSysLockFromIsr(); - chEvtBroadcastI(&com->sd_oevent); + chEvtBroadcastI(&com->d1.oevent); chSysUnlockFromIsr(); break; } @@ -141,11 +141,11 @@ static void preload(UART *u, FullDuplexDriver *com) { int i = UART_FIFO_PRELOAD; do { chSysLockFromIsr(); - msg_t b = chOQGetI(&com->sd_oqueue); + msg_t b = chOQGetI(&com->d2.oqueue); chSysUnlockFromIsr(); if (b < Q_OK) { chSysLockFromIsr(); - chEvtBroadcastI(&com->sd_oevent); + chEvtBroadcastI(&com->d1.oevent); chSysUnlockFromIsr(); return; } diff --git a/todo.txt b/todo.txt index ab5dde005..6d381fe67 100644 --- a/todo.txt +++ b/todo.txt @@ -7,8 +7,8 @@ X = In progress, some work done. After 1.2.0: - Remove any instance of unnamed structures/unions. - Dedicated syscalls.c support for newlib users. -X Abstract I/O channels rather than just serial ports. - - Move the serial drivers implementations in library. Better keep the core +* Abstract I/O channels rather than just serial ports. + ? Move the serial drivers implementations in library. Better keep the core as compact as possible. - Threads Pools manager in the library. - New chThdCreate() that takes just two parameters, a pointer to a thread