Initial import
[fw/sdcc] / device / include / mc68hc908qy.h
1 /*-------------------------------------------------------------------------
2   Register Declarations for Motorola MC68HC908QY & MC68HC908QT
3   
4    Written By - Erik Petrich
5     epetrich@users.sourceforge.net (2003)
6     
7    This program is free software; you can redistribute it and/or modify it
8    under the terms of the GNU General Public License as published by the
9    Free Software Foundation; either version 2, or (at your option) any
10    later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20    
21    In other words, you are welcome to use, share and improve this program.
22    You are forbidden to forbid anyone else to use, share and improve
23    what you give them.   Help stamp out software-hoarding!  
24 -------------------------------------------------------------------------*/
25
26 #ifndef MC68HC908QY_H
27 #define MC68HC908QY_H
28
29 #ifndef UINT8
30  #define UINT8 unsigned char
31 #endif
32 #ifndef UINT16
33  #define UINT16 unsigned int
34 #endif
35 #ifndef VOLDATA
36  #define VOLDATA volatile data
37 #endif
38 #ifndef VOLXDATA
39  #define VOLXDATA volatile xdata
40 #endif
41
42 struct _hc08_bits
43 {
44   unsigned int bit0:1;
45   unsigned int bit1:1;
46   unsigned int bit2:1;
47   unsigned int bit3:1;
48   unsigned int bit4:1;
49   unsigned int bit5:1;
50   unsigned int bit6:1;
51   unsigned int bit7:1;
52 };
53   
54
55 VOLDATA UINT8 at 0x00 PTA;     /* Port A Data Register */
56   #define PTA0 ((struct _hc08_bits *)(&PTA))->bit0
57   #define PTA1 ((struct _hc08_bits *)(&PTA))->bit1
58   #define PTA2 ((struct _hc08_bits *)(&PTA))->bit2
59   #define PTA3 ((struct _hc08_bits *)(&PTA))->bit3
60   #define PTA4 ((struct _hc08_bits *)(&PTA))->bit4
61   #define PTA5 ((struct _hc08_bits *)(&PTA))->bit5
62   #define AWUL ((struct _hc08_bits *)(&PTA))->bit6
63   
64 VOLDATA UINT8 at 0x01 PTB;     /* Port B Data Register */
65   #define PTB0 ((struct _hc08_bits *)(&PTB))->bit0
66   #define PTB1 ((struct _hc08_bits *)(&PTB))->bit1
67   #define PTB2 ((struct _hc08_bits *)(&PTB))->bit2
68   #define PTB3 ((struct _hc08_bits *)(&PTB))->bit3
69   #define PTB4 ((struct _hc08_bits *)(&PTB))->bit4
70   #define PTB5 ((struct _hc08_bits *)(&PTB))->bit5
71   #define PTB6 ((struct _hc08_bits *)(&PTB))->bit6
72   #define PTB7 ((struct _hc08_bits *)(&PTB))->bit7
73
74 VOLDATA UINT8 at 0x04 DDRA;    /* Data Direction Register A */
75   #define DDRA0 ((struct _hc08_bits *)(&DDRA))->bit0
76   #define DDRA1 ((struct _hc08_bits *)(&DDRA))->bit1
77   #define DDRA3 ((struct _hc08_bits *)(&DDRA))->bit3
78   #define DDRA4 ((struct _hc08_bits *)(&DDRA))->bit4
79   #define DDRA5 ((struct _hc08_bits *)(&DDRA))->bit5
80
81 VOLDATA UINT8 at 0x05 DDRB;    /* Data Direction Register B */
82   #define DDRB0 ((struct _hc08_bits *)(&DDRB))->bit0
83   #define DDRB1 ((struct _hc08_bits *)(&DDRB))->bit1
84   #define DDRB2 ((struct _hc08_bits *)(&DDRB))->bit2
85   #define DDRB3 ((struct _hc08_bits *)(&DDRB))->bit3
86   #define DDRB4 ((struct _hc08_bits *)(&DDRB))->bit4
87   #define DDRB5 ((struct _hc08_bits *)(&DDRB))->bit5
88   #define DDRB6 ((struct _hc08_bits *)(&DDRB))->bit6
89   #define DDRB7 ((struct _hc08_bits *)(&DDRB))->bit7
90
91 VOLDATA UINT8 at 0x0b PTAPUE;  /* Port A Input Pullup Enable Register */
92   #define PTAPUE0 ((struct _hc08_bits *)(&PTAPUE))->bit0
93   #define PTAPUE1 ((struct _hc08_bits *)(&PTAPUE))->bit1
94   #define PTAPUE2 ((struct _hc08_bits *)(&PTAPUE))->bit2
95   #define PTAPUE3 ((struct _hc08_bits *)(&PTAPUE))->bit3
96   #define PTAPUE4 ((struct _hc08_bits *)(&PTAPUE))->bit4
97   #define PTAPUE5 ((struct _hc08_bits *)(&PTAPUE))->bit5
98   #define OSC2EN ((struct _hc08_bits *)(&PTAPUE))->bit7
99
100 VOLDATA UINT8 at 0x0c PTBPUE;  /* Port B Input Pullup Enable Register */
101   #define PTBPUE0 ((struct _hc08_bits *)(&PTBPUE))->bit0
102   #define PTBPUE1 ((struct _hc08_bits *)(&PTBPUE))->bit1
103   #define PTBPUE2 ((struct _hc08_bits *)(&PTBPUE))->bit2
104   #define PTBPUE3 ((struct _hc08_bits *)(&PTBPUE))->bit3
105   #define PTBPUE4 ((struct _hc08_bits *)(&PTBPUE))->bit4
106   #define PTBPUE5 ((struct _hc08_bits *)(&PTBPUE))->bit5
107   #define PTBPUE6 ((struct _hc08_bits *)(&PTBPUE))->bit6
108   #define PTBPUE7 ((struct _hc08_bits *)(&PTBPUE))->bit7
109
110 VOLDATA UINT8 at 0x1a KBSCR;   /* Keyboard Status and Control Register */
111   #define MODEK ((struct _hc08_bits *)(&KBSCR))->bit0
112   #define IMASKK ((struct _hc08_bits *)(&KBSCR))->bit1
113   #define ACKK ((struct _hc08_bits *)(&KBSCR))->bit2
114   #define KEYF ((struct _hc08_bits *)(&KBSCR))->bit3
115
116 VOLDATA UINT8 at 0x1b KBIER;   /* Keyboard Interrupt Enable Register */
117   #define KBIE0 ((struct _hc08_bits *)(&KBIER))->bit0
118   #define KBIE1 ((struct _hc08_bits *)(&KBIER))->bit1
119   #define KBIE2 ((struct _hc08_bits *)(&KBIER))->bit2
120   #define KBIE3 ((struct _hc08_bits *)(&KBIER))->bit3
121   #define KBIE4 ((struct _hc08_bits *)(&KBIER))->bit4
122   #define KBIE5 ((struct _hc08_bits *)(&KBIER))->bit5
123   #define AWUIE ((struct _hc08_bits *)(&KBIER))->bit6
124
125 VOLDATA UINT8 at 0x1d INTSCR;  /* IRQ Status and Control Register */
126   #define MODE1 ((struct _hc08_bits *)(&INTSCR))->bit0
127   #define IMASK1 ((struct _hc08_bits *)(&INTSCR))->bit1
128   #define ACK1 ((struct _hc08_bits *)(&INTSCR))->bit2
129   #define IRQF1 ((struct _hc08_bits *)(&INTSCR))->bit3
130
131 VOLDATA UINT8 at 0x1e CONFIG2; /* Configuration Register 2 */
132 /* CONFIG2 is one-time writeable, so can't use bitfields */
133
134 VOLDATA UINT8 at 0x1f CONFIG1; /* Configuration Register 1 */
135 /* CONFIG1 is one-time writeable, so can't use bitfields */
136
137 VOLDATA UINT8 at 0x20 TSC;     /* TIM Status and Control */
138   #define PS0 ((struct _hc08_bits *)(&TSC))->bit0
139   #define PS1 ((struct _hc08_bits *)(&TSC))->bit1
140   #define PS2 ((struct _hc08_bits *)(&TSC))->bit2
141   #define TRST ((struct _hc08_bits *)(&TSC))->bit4
142   #define TSTOP ((struct _hc08_bits *)(&TSC))->bit5
143   #define TOIE ((struct _hc08_bits *)(&TSC))->bit6
144   #define TOF ((struct _hc08_bits *)(&TSC))->bit7
145
146 VOLDATA UINT8 at 0x21 TCNTH;   /* TIM Counter Register High */
147 VOLDATA UINT8 at 0x22 TCNTL;   /* TIM Counter Register Low */
148 VOLDATA UINT16 at 0x21 TCNT;   /* TIM Counter High & Low Registers */
149
150 VOLDATA UINT8 at 0x23 TMODH;   /* TIM Counter Modulo Register High */
151 VOLDATA UINT8 at 0x24 TMODL;   /* TIM Counter Modulo Register Low */
152 VOLDATA UINT16 at 0x23 TMOD;   /* TIM Counter Modulo High & Low Registers */
153
154 VOLDATA UINT8 at 0x25 TSC0;    /* TIM Channel 0 Status and Control Register */
155   #define CH0MAX ((struct _hc08_bits *)(&TSC0))->bit0
156   #define TOV0 ((struct _hc08_bits *)(&TSC0))->bit1
157   #define ELS0A ((struct _hc08_bits *)(&TSC0))->bit2
158   #define ELS0B ((struct _hc08_bits *)(&TSC0))->bit3
159   #define MS0A ((struct _hc08_bits *)(&TSC0))->bit4
160   #define MS0B ((struct _hc08_bits *)(&TSC0))->bit5
161   #define CH0IE ((struct _hc08_bits *)(&TSC0))->bit6
162   #define CH0F ((struct _hc08_bits *)(&TSC0))->bit7
163
164 VOLDATA UINT8 at 0x26 TCH0H;   /* TIM Channel 0 Register High */
165 VOLDATA UINT8 at 0x27 TCH0L;   /* TIM Channel 0 Register Low */
166 VOLDATA UINT16 at 0x26 TCH0;   /* TIM Channel 0 High & Low Registers */
167
168 VOLDATA UINT8 at 0x28 TSC1;    /* TIM Channel 1 Status and Control Register */
169   #define CH1MAX ((struct _hc08_bits *)(&TSC1))->bit0
170   #define TOV1 ((struct _hc08_bits *)(&TSC1))->bit1
171   #define ELS1A ((struct _hc08_bits *)(&TSC1))->bit2
172   #define ELS1B ((struct _hc08_bits *)(&TSC1))->bit3
173   #define MS1A ((struct _hc08_bits *)(&TSC1))->bit4
174   #define MS1B ((struct _hc08_bits *)(&TSC1))->bit5
175   #define CH1IE ((struct _hc08_bits *)(&TSC1))->bit6
176   #define CH1F ((struct _hc08_bits *)(&TSC1))->bit7
177
178 VOLDATA UINT8 at 0x29 TCH1H;   /* TIM Channel 1 Register High */
179 VOLDATA UINT8 at 0x2a TCH1L;   /* TIM Channel 1 Register Low */
180 VOLDATA UINT16 at 0x29 TCH1;   /* TIM Channel 1 High & Low Registers */
181
182 VOLDATA UINT8 at 0x36 OSCSTAT; /* Oscillator Status Register */
183   #define ECGST ((struct _hc08_bits *)(&OSCSTAT))->bit0
184   #define ECGON ((struct _hc08_bits *)(&OSCSTAT))->bit1
185
186 VOLDATA UINT8 at 0x38 OSCTRIM; /* Oscillator Trim Register */
187
188 VOLDATA UINT8 at 0x3c ADSCR;   /* ADC Status and Control Register */
189   #define CH0 ((struct _hc08_bits *)(&ADSCR))->bit0
190   #define CH1 ((struct _hc08_bits *)(&ADSCR))->bit1
191   #define CH2 ((struct _hc08_bits *)(&ADSCR))->bit2
192   #define CH3 ((struct _hc08_bits *)(&ADSCR))->bit3
193   #define CH4 ((struct _hc08_bits *)(&ADSCR))->bit4
194   #define ADC0 ((struct _hc08_bits *)(&ADSCR))->bit5
195   #define AIEN ((struct _hc08_bits *)(&ADSCR))->bit6
196   #define COCO ((struct _hc08_bits *)(&ADSCR))->bit7
197
198 VOLDATA UINT8 at 0x3e ADR;     /* ADC Data Register */
199
200 VOLDATA UINT8 at 0x3f ADICLK;  /* ADS Input Clock Register */
201   #define ADIV0 ((struct _hc08_bits *)(&ADICLK))->bit5
202   #define ADIV1 ((struct _hc08_bits *)(&ADICLK))->bit6
203   #define ADIV2 ((struct _hc08_bits *)(&ADICLK))->bit7
204
205 VOLXDATA UINT8 at 0xfe00 BSR;     /* Break Status Register */
206   #define SBSW ((struct _hc08_bits *)(&BSR))->bit1
207   
208 VOLXDATA UINT8 at 0xfe01 SRSR;    /* SIM Reset Status Register */
209   #define LVI ((struct _hc08_bits *)(&SRSR))->bit1
210   #define MODRST ((struct _hc08_bits *)(&SRSR))->bit2
211   #define ILAD ((struct _hc08_bits *)(&SRSR))->bit3
212   #define ILOP ((struct _hc08_bits *)(&SRSR))->bit4
213   #define COP ((struct _hc08_bits *)(&SRSR))->bit5
214   #define PIN ((struct _hc08_bits *)(&SRSR))->bit6
215   #define POR ((struct _hc08_bits *)(&SRSR))->bit7
216   
217 VOLXDATA UINT8 at 0xfe02 BRKAR;   /* Break Auxilliary Register */
218   #define BDCOP ((struct _hc08_bits *)(&BRKAR))->bit0
219
220 VOLXDATA UINT8 at 0xfe03 BFCF;    /* Break Flag Control Register */
221   #define BFCF ((struct _hc08_bits *)(&BFCF))->bit7
222
223 VOLXDATA UINT8 at 0xfe04 INT1;    /* Interrupt Status Register 1 */
224   #define IF1 ((struct _hc08_bits *)(&INT1))->bit2
225   #define IF3 ((struct _hc08_bits *)(&INT1))->bit4
226   #define IF4 ((struct _hc08_bits *)(&INT1))->bit5
227   #define IF5 ((struct _hc08_bits *)(&INT1))->bit6
228
229 VOLXDATA UINT8 at 0xfe05 INT2;    /* Interrupt Status Register 2 */
230   #define IF14 ((struct _hc08_bits *)(&INT2))->bit7
231
232 VOLXDATA UINT8 at 0xfe06 INT3;    /* Interrupt Status Register 3 */
233   #define IF15 ((struct _hc08_bits *)(&INT3))->bit0
234
235 VOLXDATA UINT8 at 0xfe08 FLCR;    /* FLASH Control Register */
236   #define PGM ((struct _hc08_bits *)(&FLCR))->bit0
237   #define ERASE ((struct _hc08_bits *)(&FLCR))->bit1
238   #define MASS ((struct _hc08_bits *)(&FLCR))->bit2
239   #define HVEN ((struct _hc08_bits *)(&FLCR))->bit3
240
241 VOLXDATA UINT8 at 0xfe09 BRKH;    /* Break Address High Register */
242 VOLXDATA UINT8 at 0xfe0a BRKL;    /* Break Address Low Register */
243 VOLXDATA UINT16 at 0xfe09 BRK;    /* Break Address High & Low Registers */
244
245 VOLXDATA UINT8 at 0xfe0b BRKSCR;  /* Break Status and Control Register */
246   #define BRKA ((struct _hc08_bits *)(&BRKSCR))->bit6
247   #define BRKE ((struct _hc08_bits *)(&BRKSCR))->bit7
248
249 VOLXDATA UINT8 at 0xfe0c LVISR;   /* LVI Status Register */
250   #define LVIOUT ((struct _hc08_bits *)(&LVISR))->bit7
251
252 VOLXDATA UINT8 at 0xfebe FLBPR;   /* FLASH Block Protect Register */
253 VOLXDATA UINT8 at 0xfec0 OSCTRIMVAL; /* Oscillator Trim Value */
254 VOLXDATA UINT8 at 0xffff COPCTL;  /* COP Control Register */
255
256
257 #endif
258