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