SFBHWSerialBoard.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00029 #ifdef SFBHWSERIALHOST_H
00030 #error SFBHWSerialBoard.h and SFBHWSerialHost.h must not be #included together!
00031 #endif
00032
00033 #ifndef SFBHWSERIALBOARD_H
00034 #define SFBHWSERIALBOARD_H
00035
00036 #include "SFBFrame.h"
00037 #include "lpc/LPC23xx.h"
00038
00039 class SFBSerial;
00040
00041 #define CAN_WRITE(fd) (REGISTER_OFFSET(fd,UxLSR) & 0x20)
00042 #define WRITE_BYTE(fd,byte) (REGISTER_OFFSET(fd,UxTHR) = (byte))
00043 #define CAN_READ(fd) (REGISTER_OFFSET(fd,UxLSR) & 0x01)
00044 #define READ_BYTE(fd) REGISTER_OFFSET(fd,UxRBR)
00045
00058 class SFBHWSerial {
00059
00060 public:
00061
00062 SFBHWSerial(int face) ;
00063
00064 SFBFrame & getFrame() { return theFrame; }
00065
00066 void putcBlocking(const u8 byte) ;
00067
00068 static u32 getFirstFace() { return NORTH; }
00069 static bool moreFaces(u32 face) ;
00070 static u32 nextFace(u32 face) ;
00071
00072 static SFBSerial & getFace(u32 face) ;
00073
00074 bool getPreferOddParity() { return true; }
00075
00076 u8 getPreferredBaudCode() ;
00077 void setPreferredBaudCode(u8 code) ;
00078
00079 u8 getLowBaudCode() { return 0; }
00080
00081 u8 getHighBaudCode() ;
00082 void setHighBaudCode(u8 code) ;
00083
00084 void predispatch() { }
00085
00086 void start(u32 baud, bool oddParity = false);
00087 void stop() ;
00088 void setBaudRate(u32 baud, bool oddParity = false) ;
00089 void checkTx() ;
00090 u32 getFD();
00091 SFBRxByteBuffer & getRx() { return rxBytes; }
00092 SFBTxByteBuffer & getTx() { return txBytes; }
00093 private:
00094
00095 void uartCommonHandler() ;
00096 friend void Uart0Handler();
00097 friend void Uart1Handler();
00098 friend void Uart2Handler();
00099 friend void Uart3Handler();
00100
00101 void reinit();
00102
00103 PacketBuffer & rxBuf;
00104 SFBRxByteBuffer rxBytes;
00105 SFBTxByteBuffer txBytes;
00106 SFBFrame theFrame;
00107 u32 lastInputActivity;
00108 u32 currentBaudRate;
00109 u8 flags;
00110 const u8 face;
00111 u8 preferredBaudCode;
00112 u8 maxBaudCode;
00113
00114 enum {
00115 FLAG_TX_ACTIVE = 0x01,
00116 FLAG_STARTED = 0x02,
00117 FLAG_ODD_PARITY = 0x04,
00118 FLAG_RESERVED3 = 0x08,
00119 FLAG_RESERVED4 = 0x10,
00120 FLAG_RESERVED5 = 0x20,
00121 FLAG_RESERVED6 = 0x40,
00122 FLAG_RESERVED7 = 0x80
00123 };
00124
00125 public:
00126
00127 static void reinitAll();
00128 };
00129
00130 #endif
00131