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 HWAD
00027 #define HWAD
00028
00029 #include "hardware.h"
00030 #include "avrdevice.h"
00031 #include "pinatport.h"
00032 #include "rwmem.h"
00033 #include "traceval.h"
00034
00036 class HWAdmux: public Hardware, public TraceValueRegister {
00037 protected:
00038 unsigned char admux;
00039 Pin* ad[8];
00040 AvrDevice *core;
00041
00042 public:
00043 HWAdmux(
00044 AvrDevice* c,
00045 Pin* _ad0,
00046 Pin* _ad1,
00047 Pin* _ad2,
00048 Pin* _ad3,
00049 Pin* _ad4,
00050 Pin* _ad5,
00051 Pin* _ad6,
00052 Pin* _ad7
00053 );
00054 unsigned char GetAdmux();
00055 void SetAdmux(unsigned char);
00056
00057 void Reset();
00059 int GetMuxOutput();
00060 IOReg<HWAdmux> admux_reg;
00061 };
00062
00064 class HWAd: public Hardware, public TraceValueRegister {
00065 protected:
00066 unsigned char adch;
00067 bool adchLocked;
00068 unsigned char adcl;
00069 int adSample;
00070 unsigned char adcsr;
00071 AvrDevice *core;
00072 HWAdmux *admux;
00073 HWIrqSystem *irqSystem;
00074 Pin& aref;
00075 unsigned int irqVec;
00076
00077 bool usedBefore;
00078 unsigned char prescaler;
00079 unsigned char clk;
00080
00081 enum T_State {
00082 IDLE,
00083 INIT,
00084 RUNNING,
00085 } state;
00086
00087
00088
00089
00090
00091 public:
00092 HWAd(AvrDevice *core, HWAdmux *m, HWIrqSystem *, Pin& aref, unsigned int irqVec) ;
00093 unsigned int CpuCycle();
00094
00095 unsigned char GetAdch();
00096 unsigned char GetAdcl();
00097 unsigned char GetAdcsr();
00098 void Reset();
00099 void SetAdcsr(unsigned char);
00100
00101 void ClearIrqFlag(unsigned int vec);
00102 IOReg<HWAd>
00103 adch_reg,
00104 adcl_reg,
00105 adcsr_reg;
00106 };
00107 #endif
00108