X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=drv%2Fser.h;h=a315562ab01a02fe30c600dd0fedbcf5f6ca3828;hb=b25aabb82dd47404b0697e1394fd3a14963e1224;hp=738c572b92cdc35fe77d10d7a4593cfe4c8d6b83;hpb=59f756174ecfff7ac9435ba62f7dc0aa636b73bd;p=bertos.git diff --git a/drv/ser.h b/drv/ser.h index 738c572b..a315562a 100755 --- a/drv/ser.h +++ b/drv/ser.h @@ -3,7 +3,7 @@ * * * \brief High level serial I/O API @@ -14,6 +14,39 @@ /*#* *#* $Log$ + *#* Revision 1.26 2006/05/18 00:39:13 bernie + *#* Add struct Serial friendly typedef. + *#* + *#* Revision 1.25 2006/02/17 22:28:00 bernie + *#* Rename ser_emul.c to ser_posix.c. + *#* + *#* Revision 1.24 2006/02/17 22:23:06 bernie + *#* Update POSIX serial emulator. + *#* + *#* Revision 1.23 2005/11/27 23:33:40 bernie + *#* Use appconfig.h instead of cfg/config.h. + *#* + *#* Revision 1.22 2005/11/04 16:20:02 bernie + *#* Fix reference to README.devlib in header. + *#* + *#* Revision 1.21 2005/04/11 19:10:27 bernie + *#* Include top-level headers from cfg/ subdir. + *#* + *#* Revision 1.20 2005/01/22 04:20:01 bernie + *#* Reformat. + *#* + *#* Revision 1.19 2005/01/11 18:08:16 aleph + *#* Add missing include + *#* + *#* Revision 1.18 2004/12/08 08:57:17 bernie + *#* Rename time_t to mtime_t. + *#* + *#* Revision 1.17 2004/11/16 21:54:56 bernie + *#* Changes for SC Monoboard support. + *#* + *#* Revision 1.16 2004/10/19 11:48:05 bernie + *#* Reformat. + *#* *#* Revision 1.15 2004/10/19 08:11:53 bernie *#* SERRF_TX, SERRF_RX: New macros; Enhance documentation. *#* @@ -61,8 +94,10 @@ #define DRV_SER_H #include -#include -#include +#include +#include /* BV() */ +#include +#include /*! \name Serial Error/status flags. */ /*\{*/ @@ -76,7 +111,7 @@ /* * Hardware errors. - * These flags map directly to the AVR UART Status Register (USR). + * These flags map directly to the AVR UART Status Register (USR). */ #define SERRF_RXSROVERRUN BV(3) /*!< Rx shift register overrun */ #define SERRF_FRAMEERROR BV(4) /*!< Stop bit missing */ @@ -92,27 +127,42 @@ /* * Hardware errors. - * These flags map directly to the SCI Control Register. + * These flags map directly to the SCI Control Register. */ #define SERRF_PARITYERROR BV(8) /*!< Parity error */ #define SERRF_FRAMEERROR BV(9) /*!< Stop bit missing */ #define SERRF_NOISEERROR BV(10) /*!< Noise error */ #define SERRF_RXSROVERRUN BV(11) /*!< Rx shift register overrun */ +#elif OS_HOSTED + typedef uint16_t serstatus_t; + + /* Software errors */ + #define SERRF_RXFIFOOVERRUN BV(0) /*!< Rx FIFO buffer overrun */ + #define SERRF_RXTIMEOUT BV(1) /*!< Receive timeout */ + #define SERRF_TXTIMEOUT BV(2) /*!< Transmit timeout */ + + /* Hardware errors */ + #define SERRF_RXSROVERRUN 0 /*!< Unsupported in emulated serial port. */ + #define SERRF_FRAMEERROR 0 /*!< Unsupported in emulated serial port. */ + #define SERRF_PARITYERROR 0 /*!< Unsupported in emulated serial port. */ + #define SERRF_NOISEERROR 0 /*!< Unsupported in emulated serial port. */ + #else #error unknown architecture #endif /*\}*/ -/*! \name Masks to group TX/RX errors. */ -/*\{*/ -#define SERRF_RX (SERRF_RXFIFOOVERRUN \ +/** Mask to group all RX errors. */ +#define SERRF_RX \ + ( SERRF_RXFIFOOVERRUN \ | SERRF_RXTIMEOUT \ | SERRF_RXSROVERRUN \ | SERRF_PARITYERROR \ | SERRF_FRAMEERROR \ | SERRF_NOISEERROR) + +/** Mask to group all TX errors. */ #define SERRF_TX (SERRF_TXTIMEOUT) -/*\}*/ /*! @@ -143,6 +193,11 @@ enum SER_UART0, SER_SPI, #elif CPU_DSP56K + // \todo since we now support "fake" multiplexed serials, this should be moved to hw.h + SER_UART0, + SER_PUNTALI, + SER_BARCODE, +#elif OS_HOSTED SER_UART0, SER_UART1, #else @@ -159,7 +214,7 @@ struct SerialHardware; extern const char * const serial_errors[8]; /*! Serial handle structure */ -struct Serial +typedef struct Serial { /*! Physical port number */ unsigned int unit; @@ -180,10 +235,10 @@ struct Serial /* \} */ #if CONFIG_SER_RXTIMEOUT != -1 - time_t rxtimeout; + mtime_t rxtimeout; #endif #if CONFIG_SER_TXTIMEOUT != -1 - time_t txtimeout; + mtime_t txtimeout; #endif /*! Holds the flags defined above. Will be 0 when no errors have occurred. */ @@ -191,7 +246,7 @@ struct Serial /*! Low-level interface to hardware. */ struct SerialHardware* hw; -}; +} Serial; /* Function prototypes */ @@ -210,8 +265,8 @@ extern int ser_gets_echo(struct Serial *port, char *buf, int size, bool echo); extern void ser_setbaudrate(struct Serial *port, unsigned long rate); extern void ser_setparity(struct Serial *port, int parity); -extern void ser_settimeouts(struct Serial *port, time_t rxtimeout, time_t txtimeout); -extern void ser_resync(struct Serial *port, time_t delay); +extern void ser_settimeouts(struct Serial *port, mtime_t rxtimeout, mtime_t txtimeout); +extern void ser_resync(struct Serial *port, mtime_t delay); extern void ser_purge(struct Serial *port); extern void ser_drain(struct Serial *port);