00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef SERIALRX_H_INCLUDED
00027 #define SERIALRX_H_INCLUDED
00028
00029 #include "systemclocktypes.h"
00030 #include "ui.h"
00031 #include "pinnotify.h"
00032
00033
00034 class SerialRxBasic: public SimulationMember, public HasPinNotifyFunction {
00035 protected:
00036 Pin rx;
00037 std::map < std::string, Pin *> allPins;
00038 unsigned long long baudrate;
00039
00040 void PinStateHasChanged(Pin*);
00041 virtual void CharReceived(unsigned char c)=0;
00042
00043 int highCnt;
00044
00045 int bitCnt;
00046 int maxBitCnt;
00047 int dataByte;
00048
00049 enum T_RxState {
00050 RX_WAIT_LOWEDGE,
00051 RX_READ_STARTBIT,
00052 RX_READ_DATABIT_START,
00053 RX_READ_DATABIT_FIRST,
00054 RX_READ_DATABIT_SECOND,
00055 RX_READ_DATABIT_THIRD,
00056 } ;
00057
00058 T_RxState rxState;
00059
00060 bool sendInHex;
00061
00062 public:
00063 void SetBaudRate(SystemClockOffset baud);
00064 void SetHexOutput(bool newValue);
00065 SerialRxBasic();
00066 void Reset();
00067 virtual Pin* GetPin(const char *name) ;
00068 virtual ~SerialRxBasic(){};
00069 virtual int Step(bool &trueHwStep, SystemClockOffset *timeToNextStepIn_ns=0);
00070 };
00071
00072
00074 class SerialRxBuffered: public SerialRxBasic{
00075 protected:
00076 std::vector<unsigned char> buffer;
00077 virtual void CharReceived(unsigned char c);
00078 public:
00079 unsigned char Get();
00080 long Size();
00081 };
00082
00083
00085 class SerialRx: public SerialRxBasic, public ExternalType{
00086 protected:
00087 UserInterface *ui;
00088 std::string name;
00089
00090 virtual void CharReceived(unsigned char c);
00091 public:
00092 SerialRx(UserInterface *_ui, const char *_name, const char *baseWindow);
00093 virtual ~SerialRx(){};
00094 virtual void SetNewValueFromUi(const std::string &);
00095 };
00096
00097 #endif