X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=drv%2Fser.c;h=10757d0e3b91b8f0b0db6f8f05bff6d215c8df6f;hb=27fef4ed34eb237817defa14242e726ccad70948;hp=0d5d7ec258c67a060be9b85a81e7c4fc4ec767d7;hpb=8e67b786e5aa96e6d4628687cf230a8f64d3791a;p=bertos.git diff --git a/drv/ser.c b/drv/ser.c old mode 100755 new mode 100644 index 0d5d7ec2..10757d0e --- a/drv/ser.c +++ b/drv/ser.c @@ -1,9 +1,34 @@ /** * \file * * * \brief Buffered serial I/O driver @@ -28,6 +53,24 @@ /*#* *#* $Log$ + *#* Revision 1.38 2007/06/21 17:07:21 batt + *#* Remove CONFIG_WATCHDOG stuff: watchdog macros expand to nothing when wdt is active. + *#* + *#* Revision 1.37 2007/06/07 14:35:12 batt + *#* Merge from project_ks. + *#* + *#* Revision 1.36 2007/01/29 11:30:29 batt + *#* Reimplement ser_clearstatus as a macro. + *#* + *#* Revision 1.35 2007/01/27 20:47:12 batt + *#* Add clear status. + *#* + *#* Revision 1.34 2006/11/20 15:07:40 batt + *#* Revert unneeded locked functions. + *#* + *#* Revision 1.33 2006/11/17 18:15:55 batt + *#* Avoid race conditions. + *#* *#* Revision 1.32 2006/11/17 17:03:58 batt *#* Implement ser_setstatus and ser_getstatus as functions to avoid race conditions. *#* @@ -124,6 +167,9 @@ *#*/ #include "ser.h" + +#include "wdt.h" + #include "ser_p.h" #include #include @@ -189,6 +235,7 @@ int ser_putchar(int c, struct Serial *port) /* Attende finche' il buffer e' pieno... */ do { + wdt_reset(); #if CONFIG_KERNEL && CONFIG_KERN_SCHED /* Give up timeslice to other processes. */ proc_switch(); @@ -196,7 +243,7 @@ int ser_putchar(int c, struct Serial *port) #if CONFIG_SER_TXTIMEOUT != -1 if (timer_clock() - start_time >= port->txtimeout) { - port->status |= SERRF_TXTIMEOUT; + ATOMIC(port->status |= SERRF_TXTIMEOUT); return EOF; } #endif /* CONFIG_SER_TXTIMEOUT */ @@ -233,6 +280,7 @@ int ser_getchar(struct Serial *port) /* Wait while buffer is empty */ do { + wdt_reset(); #if CONFIG_KERNEL && CONFIG_KERN_SCHED /* Give up timeslice to other processes. */ proc_switch(); @@ -240,19 +288,19 @@ int ser_getchar(struct Serial *port) #if CONFIG_SER_RXTIMEOUT != -1 if (timer_clock() - start_time >= port->rxtimeout) { - port->status |= SERRF_RXTIMEOUT; + ATOMIC(port->status |= SERRF_RXTIMEOUT); return EOF; } #endif /* CONFIG_SER_RXTIMEOUT */ } - while (fifo_isempty_locked(&port->rxfifo) && (port->status & SERRF_RX) == 0); + while (fifo_isempty_locked(&port->rxfifo) && (ser_getstatus(port) & SERRF_RX) == 0); } /* * Get a byte from the FIFO (avoiding sign-extension), * re-enable RTS, then return result. */ - if (port->status & SERRF_RX) + if (ser_getstatus(port) & SERRF_RX) return EOF; return (int)(unsigned char)fifo_pop_locked(&port->rxfifo); } @@ -457,26 +505,6 @@ void ser_purge(struct Serial *port) fifo_flush_locked(&port->txfifo); } -/** - * Get status of port \c port. - */ -serstatus_t ser_getstatus(struct Serial *port) -{ - serstatus_t status; - ATOMIC(status = port->status); - - return status; -} - - -/** - * Set new \c port status. - */ -void ser_setstatus(struct Serial *port, serstatus_t status) -{ - ATOMIC(port->status = status); -} - /** * Wait until all pending output is completely @@ -499,6 +527,7 @@ void ser_drain(struct Serial *ser) /* Give up timeslice to other processes. */ proc_switch(); #endif + wdt_reset(); } }