X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=drv%2Fser.c;h=9b42a70dbfaf1a936684bbb26e4f736e033b0458;hb=00e009957d70dab15575ab310ed83f0b78cc8656;hp=a65d078a64bcd0c5d2b8d8a93fd76764827181ef;hpb=7453dd6f0dd60211a8a947017b0544dc4dd454ac;p=bertos.git diff --git a/drv/ser.c b/drv/ser.c index a65d078a..9b42a70d 100755 --- a/drv/ser.c +++ b/drv/ser.c @@ -28,6 +28,12 @@ /*#* *#* $Log$ + *#* Revision 1.21 2004/11/16 18:10:13 bernie + *#* Add sanity checks for missing configuration parameters. + *#* + *#* Revision 1.20 2004/10/19 11:48:00 bernie + *#* Remove unused variable. + *#* *#* Revision 1.19 2004/10/19 08:14:13 bernie *#* Fix a few longstanding bugs wrt status handling (made by rasky on scfirm). *#* @@ -84,15 +90,39 @@ *#* *#*/ -#include -#include #include "ser.h" #include "ser_p.h" -#include "hw.h" +#include +#include +#include +#include -#ifdef CONFIG_KERNEL +/* + * Sanity check for config parameters required by this module. + */ +#if !defined(CONFIG_KERNEL) || ((CONFIG_KERNEL != 0) && CONFIG_KERNEL != 1) + #error CONFIG_KERNEL must be set to either 0 or 1 in config.h +#endif +#if !defined(CONFIG_SER_RXTIMEOUT) + #error CONFIG_SER_TXTIMEOUT missing in config.h +#endif +#if !defined(CONFIG_SER_RXTIMEOUT) + #error CONFIG_SER_RXTIMEOUT missing in config.h +#endif +#if !defined(CONFIG_SER_GETS) || ((CONFIG_SER_GETS != 0) && CONFIG_SER_GETS != 1) + #error CONFIG_SER_GETS must be set to either 0 or 1 in config.h +#endif +#if !defined(CONFIG_SER_DEFBAUDRATE) + #error CONFIG_SER_DEFBAUDRATE missing in config.h +#endif +#if !defined(CONFIG_PRINTF) + #error CONFIG_PRINTF missing in config.h +#endif + +#if CONFIG_KERNEL #include #endif + #if CONFIG_SER_TXTIMEOUT != -1 || CONFIG_SER_RXTIMEOUT != -1 #include #endif @@ -127,7 +157,7 @@ int ser_putchar(int c, struct Serial *port) /* Attende finche' il buffer e' pieno... */ do { -#if defined(CONFIG_KERN_SCHED) && CONFIG_KERN_SCHED +#if CONFIG_KERNEL && CONFIG_KERN_SCHED /* Give up timeslice to other processes. */ proc_switch(); #endif @@ -163,8 +193,6 @@ int ser_putchar(int c, struct Serial *port) */ int ser_getchar(struct Serial *port) { - int result; - if (fifo_isempty_locked(&port->rxfifo)) { #if CONFIG_SER_RXTIMEOUT != -1 @@ -173,7 +201,7 @@ int ser_getchar(struct Serial *port) /* Wait while buffer is empty */ do { -#if defined(CONFIG_KERN_SCHED) && CONFIG_KERN_SCHED +#if CONFIG_KERNEL && CONFIG_KERN_SCHED /* Give up timeslice to other processes. */ proc_switch(); #endif @@ -410,10 +438,10 @@ void ser_drain(struct Serial *ser) { while (!fifo_isempty(&ser->txfifo)) { -#if defined(CONFIG_KERN_SCHED) && CONFIG_KERN_SCHED + #if CONFIG_KERNEL && CONFIG_KERN_SCHED /* Give up timeslice to other processes. */ proc_switch(); -#endif + #endif } } @@ -451,6 +479,9 @@ struct Serial *ser_open(unsigned int unit) ser_setbaudrate(port, CONFIG_SER_DEFBAUDRATE); #endif + /* Clear error flags */ + ser_setstatus(port, 0); + return port; }