64/* Port Integration Module - Reordered within sections for clarity */
65/* PIM information from 5 tables the last of which is spread over three pages */
66
67/* Plain ports output switch, input state registers */
68#define PORTS_BA DVUSP(0x0001) /// @todo TODO is this address wrong? Test this... /* Both A and B combined as a 16 bit register for ignition access */
84#define DDRC DVUCP(0x0006) /* these pins are not bonded on the 112 pin package but need switching to output */
85#define DDRD DVUCP(0x0007) /* these pins are not bonded on the 112 pin package but need switching to output */
86
87
88/* 0b1//1//00 */
89/* --K//E//BA */
90/* TODO NOTE: the sixth bit controls pull up on BKGD and VREGEN pins set this to ???? */
91/* NOTE: pull up on port E is for 0-4 and 7, ports 5 and 6 are pulled down during reset and never pulled up. */
92#define PUCR DVUCP(0x000C) /* pull up enable when used as an input, 0 = no pull up, 1 = pull up on */
93
94
95/* 0b1//0//00 */
96/* --K//E//BA */
97/* NOTE: reduced drive affects all pins of all ports listed above. */
98#define RDRIV DVUCP(0x000D) /* reduced drive register when used as output, 0 = full drive, 1 = reduced drive */
99
100
101#define ECLKCTL DVUCP(0x001C) /* Comes up 0b_1100_0000 = both pins off in normal single chip mode */
102#define IRQCR DVUCP(0x001E) /* 0 in bit 7 makes it ultra sensitive, 1 makes it falling edge sensitive. 0 in bit 6 turns interrupts off, 1 in bit 6 turns them on. */
103
104
105/* Port T registers */
106#define PTT DVUCP(0x0240) /* GPIO output register, can not be read from reliably, use PTIT instead */
107#define PORTT DVUCP(0x0240) /* Duplicate definition for consistency */
108#define PTIT DVUCP(0x0241) /* read only port state bits, always return the state of the pin, can be used to detect overload on outputs */
109#define DDRT DVUCP(0x0242) /* TODO configure all IO as outputs until we need it */
110#define RDRT DVUCP(0x0243) /* reduced drive register when used as output, 0 = full drive, 1 = reduced drive */
111#define PERT DVUCP(0x0244) /* pull up/down enable when used as an input, 0 = no pull up, 1 = pull up on */
167#define PORTJ DVUCP(0x0268) /* Duplicate definition for consistency */
168#define PTIJ DVUCP(0x0269) /* read only port state bits, always return the state of the pin, can be used to detect overload on outputs */
169#define DDRJ DVUCP(0x026A) /* TODO configure all IO as outputs until we need it */
170#define RDRJ DVUCP(0x026B) /* reduced drive register when used as output, 0 = full drive, 1 = reduced drive */
171#define PERJ DVUCP(0x026C) /* pull up enable when used as an input, 0 = no pull up, 1 = pull up on */
172#define PPSJ DVUCP(0x026D) /* 0 = pull up, 1 = pull down AND when IE pull down means I on rising edge and pull up means I on falling edge */
173#define PIEJ DVUCP(0x026E) /* interrupt enable, turns on interrupts */
174#define PIFJ DVUCP(0x026F) /* interrupt flag, write a 1 to clear it */
175
176
177/* #define ATD0PT1 DVUCP(0x0271) we don't want to use valuable ATD pins as normal IO, but if we did, r/w here */
178/* #define ATD0DDR1 DVUCP(0x0273) for use as an input, ATD0DIEN has to be set to 1. for use as an output? */
179/* #define ATD0RDR1 DVUCP(0x0275) reduced drive register when used as output, 0 = full drive, 1 = reduced drive */
180#define ATD0PER1 DVUCP(0x0277) /* pull up enable when used as an input, 0 = no pull up, 1 = pull up on */
181
182/* #define ATD1PT1 DVUCP(0x0279) we don't want to use valuable ATD pins as normal IO, but if we did, r/w here */
183/* #define ATD1DDR1 DVUCP(0x027B) for use as an input, ATD1DIEN1 has to be set to 1. for use as an output? */
184/* #define ATD1RDR1 DVUCP(0x027D) reduced drive register when used as output, 0 = full drive, 1 = reduced drive */
185/* #define ATD1PER1 DVUCP(0x027F) pull up enable when used as an input, 0 = no pull up, 1 = pull up on */
186
187/* Not available on 112 pin version */
188/* #define ATD1DDR0 DVUCP(0x027A) */
189/* 0x0278 #define ATD1PT0 DVUCP() */
190/* 0x027C #define ATD1RDR0 DVUCP() */
191/* 0x027E #define ATD1PER0 DVUCP() */
192
193
194/* Memory Mapping Control registers TODO configure these to suit our application. */
195/* MMC 1/4 */
196//0x000B MODE DVUCP()
197//0x000A MMCCTL0 DVUCP()
198//0x0013 MMCCTL1 DVUCP()
199
200
201/* Page control registers */
202#define RPAGE DVUCP(0x0016) /* Used to page table data in and out of visible memory. */
203//0x0017 EPAGE DVUCP() /* /* TODO similar to above if we need another 2k of eeprom. what are advantages/disadvantages of eeprom over flash?? */
204#define PPAGE DVUCP(0x0030) /* TODO look at the best way to use the flash space in a complete system with a lot of code and data. used by compiler and maybe us to switch flash pages for loading/unloading data. */
205//0x0010 GPAGE DVUCP() /* /* Global page register for global instruction addressing. I doubt we will use this. */
206//0x0011 DIRECT DVUCP() /* /* Direct addressing mode control register. I doubt we will use this. */
207
208
209// MMC 4/4
210#define RAMWPC DVUCP(0x011C) /* RAM Write Protection register, the pdf document appears to be incorrect for this, best not to touch it. */
211#define RAMXGU DVUCP(0x011D) /* XGATE Upper region limit, this defines how much RAM we give the xgate to work with. */
212#define RAMSHL DVUCP(0x011E) /* Shared memory lower boundary register, this defines the lower limit of the overlap between XGATE RAM and CPU RAM */
213#define RAMSHU DVUCP(0x011F) /* Shared memory upper boundary register, this defines the upper limit of the overlap between XGATE RAM and CPU RAM */
214
215
216//// EBI
217//0x000E EBICTL0 DVUCP() /*
218//0x000F EBICTL1 DVUCP() /*
219
220
221//// Misc Peripheral
222//0x001A PARTIDH DVUCP() /*
223//0x001B PARTIDL DVUCP() /*
224
225
226/* Clock and Reset Generator */
227#define SYNR DVUCP(0x0034) /* Multiplier of result of division by REFDV below, output is new PLL/Bus freqency. */
228#define REFDV DVUCP(0x0035) /* Divisor of external clock frequency pre being multiplied by SYNR above. */
229//0x0036 CTFLG DVUCP() /*
230#define CRGFLG DVUCP(0x0037) /* Clock and Reset Generator flags, we use this to determine when the PLL is stable and ready to use. Also to reset the RTI flag. */
231#define CRGINT DVUCP(0x0038) /* Bit 7 is RTIE RTI enable bit. */
232#define CLKSEL DVUCP(0x0039) /* Clock select register, choose PLL or external clock with this. */
233#define PLLCTL DVUCP(0x003A) /* PLL frequency generator control register, used for setting the bus frequency. */
235#define COPCTL DVUCP(0x003C) /* COP watch dog control register */
236//0x003D FORBYP DVUCP() /*
237#define ARMCOP DVUCP(0x003F) /* Computer operating properly timer, we won't be using this at least until we have profiled the running application. it will just cause headaches otherwise. */
238
239
240/* Enhanced Capture Timer */
241/* see reference document from Huang course overview/notes : http://www.ee.nmt.edu/~rison/ee308_spr06/lectures.html */
242/* see this link for a discussion of the old 68hc12 timer http://www.seattlerobotics.org/encoder/nov97/68hc12.html */
341#define PTMCPSR DVUCP(0x006F) /* Precision prescaler for the modulus down counter */
342
343
344/* Analog To Digital converter 1 */
345/* TODO Configure these and disable the non functional 16 - 23 144 pin section! */
346#define ATD1CTL0 DVUCP(0x0080) /* 0 - 3 define which ADC channel to wrap on when doing multiple channels */
347#define ATD1CTL1 DVUCP(0x0081) /* External trigger select when enabled in other control register */
348#define ATD1CTL2 DVUCP(0x0082) /* bit 7 turns the ADC block on. */
349#define ATD1CTL3 DVUCP(0x0083) /* bit 6 means conversion length is 8, bit 2 controls how the registers are used, bits 0 - 1 define freeze mode behaviour */
350#define ATD1CTL4 DVUCP(0x0084) /* bit 7 should be zero meaning 10bit ADC, bits 6,5 are the sample period, and 4,3,2,1,0 are the sample frequency clock scaler */
351#define ATD1CTL5 DVUCP(0x0085) /* bit 7 sets right justify, bit 5 sets scan mode, bit 4 sets multiplex mode */
352//0x0086 ATD1STAT0 DVUCP() /*
353//0x0088 ATD1TEST0 DVUCP() /*
354//0x0089 ATD1TEST1 DVUCP() /*
355//0x008A ATD1STAT2 DVUCP() /*
356//0x008B ATD1STAT1 DVUCP() /*
357#define ATD1DIEN0 DVUCP(0x008C) /* Digital input enable - these pins are not bonded on the 112 pin package */
358#define ATD1DIEN1 DVUCP(0x008D) /* Digital input enable */
359//0x008E ATD1PTAD0 DVUCP() /* digital use only */
360//0x008F ATD1PTAD1 DVUCP() /* digital use only */
361// one short for each hi lo par based on hi address. label with WORD for consistency
373/* NOT bonded on the 112 pin package!! Left here in case of 144 pin FreeEMS later on. */
374//0x00A0 ATD1DR8H
375//0x00A1 ATD1DR8L
376//0x00A2 ATD1DR9H
377//0x00A3 ATD1DR9L
378//0x00A4 ATD1DR10H
379//0x00A5 ATD1DR10L
380//0x00A6 ATD1DR11H
381//0x00A7 ATD1DR11L
382//0x00A8 ATD1DR12H
383//0x00A9 ATD1DR12L
384//0x00AA ATD1DR13H
385//0x00AB ATD1DR13L
386//0x00AC ATD1DR14H
387//0x00AD ATD1DR14L
388//0x00AE ATD1DR15H
389//0x00AF ATD1DR15L
390/* NOT bonded on the 112 pin package!! Left here in case of 144 pin FreeEMS later on. */
391
392
393/* IIC1 - Inter Intergrated Circuit interface 1 TODO configure and use */
394//0x00B0 IBAD DVUCP() /*
395//0x00B1 IBFD DVUCP() /*
396//0x00B2 IBCR DVUCP() /*
397//0x00B3 IBSR DVUCP() /*
398//0x00B4 IBDR DVUCP() /*
399
400
401/* SCI2 */
402//0x00B8 SCI2BDH
403//0x00B8 SCI2ASR1
404//0x00B9 SCI2BDL
405//0x00B9 SCI2ACR1
406//0x00BA SCI2CR1
407//0x00BA SCI2ACR2
408//0x00BB SCI2CR2
409//0x00BC SCI2SR1
410//0x00BD SCI2SR2
411//0x00BE SCI2DRH
412//0x00BF SCI2DRL
413
414
415/* SCI3 */
416//0x00C0 SCI3BDH
417//0x00C0 SCI3ASR1
418//0x00C1 SCI3BDL
419//0x00C1 SCI3ACR1
420//0x00C2 SCI3CR1
421//0x00C2 SCI3ACR2
422//0x00C3 SCI3CR2
423//0x00C4 SCI3SR1
424//0x00C5 SCI3SR2
425//0x00C6 SCI3DRH
426//0x00C7 SCI3DRL
427
428
429/* SCI0 debug/comms/datalogging TODO this is our primary serial interface for flash loading, setup serial comms software to communicate with MTX or similar for testing. */
442#define SCI0DRH DVUCP(SCI0_BASE + 0x6) /* Data reg high (9th bit bit 7 receive bit 6 send) */
443#define SCI0DRL DVUCP(SCI0_BASE + 0x7) /* Data reg low (read and write for receive and send respectively)*/
444
445
446/* SCI1 debug/comms/datalogging TODO this is our secondary serial interface, setup serial comms software to communicate with MTX or similar for testing. */
789/* ATD0 TODO configure this as ATD inputs and try them out to control rate of flashing of leds etc, or even, which LED's are flashing etc */
790#define ATD0CTL0 DVUCP(0x02C0) /* 0 - 2 define which ADC channel to wrap on when doing multiple channels */
791#define ATD0CTL1 DVUCP(0x02C1) /* External trigger select when enabled in other control register */
792#define ATD0CTL2 DVUCP(0x02C2) /* bit 7 turns the ADC block on. */
793#define ATD0CTL3 DVUCP(0x02C3) /* bit 6 means conversion length is 8, bit 2 controls how the registers are used, bits 0 - 1 define freeze mode behaviour */
794#define ATD0CTL4 DVUCP(0x02C4) /* bit 7 should be zero meaning 10bit ADC, bits 6,5 are the sample period, and 4,3,2,1,0 are the sample frequency clock scaler */
795#define ATD0CTL5 DVUCP(0x02C5) /* bit 7 sets right justify, bit 5 sets scan mode, bit 4 sets multiplex mode */
796//0x02C6 ATD0STAT0
797//0x02CB ATD0STAT1
798#define ATD0DIEN DVUCP(0x02CD) /* Digital input enable */
799//0x02CF ATD0PTAD0 digital use only
800#define ATD0_BASE 0x02D0 /* Maybe use this with a loop to sample them in a compact way. */