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 #include "at4433.h"
00027
00028 #include "irqsystem.h"
00029 #include "hweeprom.h"
00030 #include "hwstack.h"
00031 #include "pinatport.h"
00032 #include "hwacomp.h"
00033 #include "hwwado.h"
00034 #include "avrfactory.h"
00035 #include "hwsreg.h"
00036
00037 AVR_REGISTER(at90s4433, AvrDevice_at90s4433);
00038
00039 AvrDevice_at90s4433::AvrDevice_at90s4433():
00040 AvrDevice(64, 128, 0, 4*1024)
00041 {
00042 flagJMPInstructions = false;
00043 flagMULInstructions = false;
00044 flagMOVWInstruction = false;
00045 irqSystem = new HWIrqSystem(this, 2, 14);
00046 eeprom= new HWEeprom(this, irqSystem, 256, 12);
00047 stack = new HWStackSram(this, 8);
00048
00049 portb= new HWPort(this, "B");
00050 portc= new HWPort(this, "C");
00051 portd= new HWPort(this, "D");
00052
00053 porty= new HWPort(this, "Y");
00054
00055 admux= new HWAdmux(this,
00056 &portc->GetPin(0), &portc->GetPin(1), &portc->GetPin(2),
00057 &portc->GetPin(3), &portc->GetPin(4), &portc->GetPin(5),0,0);
00058 ad= new HWAd( this, admux, irqSystem, porty->GetPin(0), 11);
00059
00060 spi= new HWSpi(this, irqSystem, PinAtPort( portb, 3), PinAtPort( portb, 4), PinAtPort( portb, 5), PinAtPort(portb, 2), 7, false);
00061
00062 uart= new HWUart( this, irqSystem, PinAtPort(portd,1), PinAtPort(portd, 0),8,9,10) ;
00063
00064 acomp= new HWAcomp(this, irqSystem, PinAtPort(portd, 6), PinAtPort(portd, 7), 13);
00065
00066 wado= new HWWado(this);
00067
00068 prescaler = new HWPrescaler(this, "01");
00069 timer01irq = new TimerIRQRegister(this, irqSystem);
00070 timer01irq->registerLine(1, new IRQLine("TOV0", 6));
00071 timer01irq->registerLine(3, new IRQLine("ICF1", 3));
00072 timer01irq->registerLine(6, new IRQLine("OCF1", 4));
00073 timer01irq->registerLine(7, new IRQLine("TOV1", 5));
00074 timer0 = new HWTimer8_0C(this,
00075 new PrescalerMultiplexerExt(prescaler, PinAtPort(portd, 4)),
00076 0,
00077 timer01irq->getLine("TOV0"));
00078 inputCapture1 = new ICaptureSource(PinAtPort(portb, 0));
00079 timer1 = new HWTimer16_1C(this,
00080 new PrescalerMultiplexerExt(prescaler, PinAtPort(portd, 5)),
00081 1,
00082 timer01irq->getLine("TOV1"),
00083 timer01irq->getLine("OCF1"),
00084 new PinAtPort(portb, 1),
00085 timer01irq->getLine("ICF1"),
00086 inputCapture1);
00087
00088 gimsk_reg = new IOSpecialReg(&coreTraceGroup, "GIMSK");
00089 gifr_reg = new IOSpecialReg(&coreTraceGroup, "GIFR");
00090 mcucr_reg = new IOSpecialReg(&coreTraceGroup, "MCUCR");
00091 extirq = new ExternalIRQHandler(this, irqSystem, gimsk_reg, gifr_reg);
00092 extirq->registerIrq(1, 6, new ExternalIRQSingle(mcucr_reg, 0, 2, GetPin("D2")));
00093 extirq->registerIrq(2, 7, new ExternalIRQSingle(mcucr_reg, 2, 2, GetPin("D3")));
00094
00095 rw[0x5f]= statusRegister;
00096 rw[0x5e]= & ((HWStackSram *)stack)->sph_reg;
00097 rw[0x5d]= & ((HWStackSram *)stack)->spl_reg;
00098
00099 rw[0x5b]= gimsk_reg;
00100 rw[0x5a]= gifr_reg;
00101 rw[0x59]= & timer01irq->timsk_reg;
00102 rw[0x58]= & timer01irq->tifr_reg;
00103
00104 rw[0x55]= mcucr_reg;
00105
00106
00107
00108 rw[0x53]= & timer0->tccr_reg;
00109 rw[0x52]= & timer0->tcnt_reg;
00110
00111 rw[0x4f]= & timer1->tccra_reg;
00112 rw[0x4e]= & timer1->tccrb_reg;
00113 rw[0x4d]= & timer1->tcnt_h_reg;
00114 rw[0x4c]= & timer1->tcnt_l_reg;
00115 rw[0x4b]= & timer1->ocra_h_reg;
00116 rw[0x4a]= & timer1->ocra_l_reg;
00117
00118 rw[0x47]= & timer1->icr_h_reg;
00119 rw[0x46]= & timer1->icr_l_reg;
00120
00121 rw[0x41]= & wado->wdtcr_reg;
00122
00123
00124 rw[0x3e] = & eeprom->eearl_reg;
00125 rw[0x3d] = & eeprom->eedr_reg;
00126 rw[0x3c] = & eeprom->eecr_reg;
00127
00128
00129
00130 rw[0x38]= & portb->port_reg;
00131 rw[0x37]= & portb->ddr_reg;
00132 rw[0x36]= & portb->pin_reg;
00133
00134 rw[0x35]= & portc->port_reg;
00135 rw[0x34]= & portc->ddr_reg;
00136 rw[0x33]= & portc->pin_reg;
00137
00138 rw[0x32]= & portd->port_reg;
00139 rw[0x31]= & portd->ddr_reg;
00140 rw[0x30]= & portd->pin_reg;
00141
00142 rw[0x2f]= & spi->spdr_reg;
00143 rw[0x2e]= & spi->spsr_reg;
00144 rw[0x2d]= & spi->spcr_reg;
00145
00146 rw[0x2c]= & uart->udr_reg;
00147 rw[0x2b]= & uart->usr_reg;
00148 rw[0x2a]= & uart->ucr_reg;
00149 rw[0x29]= & uart->ubrr_reg;
00150
00151 rw[0x28]= & acomp->acsr_reg;
00152
00153 rw[0x27]= & admux->admux_reg;
00154 rw[0x26]= & ad->adcsr_reg;
00155 rw[0x25]= & ad->adch_reg;
00156 rw[0x24]= & ad->adcl_reg;
00157
00158 rw[0x23]= & uart->ubrrhi_reg;
00159
00160 Reset();
00161 }
00162
00163 AvrDevice_at90s4433::~AvrDevice_at90s4433() {
00164 delete extirq;
00165 delete mcucr_reg;
00166 delete gifr_reg;
00167 delete gimsk_reg;
00168 delete timer1;
00169 delete inputCapture1;
00170 delete timer0;
00171 delete timer01irq;
00172 delete prescaler;
00173 delete wado;
00174 delete acomp;
00175 delete uart;
00176 delete spi;
00177 delete ad;
00178 delete admux;
00179 delete porty;
00180 delete portd;
00181 delete portc;
00182 delete portb;
00183 delete stack;
00184 delete eeprom;
00185 delete irqSystem;
00186 }
00187