Imported Upstream version 2.9.0
[debian/cc1111] / device / include / mcs51 / P89LPC925.h
1 /*-------------------------------------------------------------------------
2    Register Declarations for NXP  P89LPC924 and P89LPC925
3    (Based on datasheet Rev. 03 \97 15 December 2004)
4
5    Written By -  Jesus Calvino-Fraga / jesusc at ece.ubc.ca (February 2007)
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 of the License, or (at your option); any later version
11
12    This library 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 GNU
15    Lesser General Public License for more details
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this library; if not, write to the Free Software
19    Foundation, Inc., 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 REG_P89LPC925_H
27 #define REG_P89LPC925_H
28
29 #include <compiler.h>
30
31 SFR(ACC, 0xE0); // Accumulator
32    SBIT(ACC_7, 0xE0, 7);
33    SBIT(ACC_6, 0xE0, 6);
34    SBIT(ACC_5, 0xE0, 5);
35    SBIT(ACC_4, 0xE0, 4);
36    SBIT(ACC_3, 0xE0, 3);
37    SBIT(ACC_2, 0xE0, 2);
38    SBIT(ACC_1, 0xE0, 1);
39    SBIT(ACC_0, 0xE0, 0);
40
41 SFR(ADCON1, 0x97); // A/D control register 1
42    #define ENBI1   0x80
43    #define ENADCI1 0x40
44    #define TMM1    0x20
45    #define EDGE1   0x10
46    #define ADCI1   0x08
47    #define ENADC1  0x04
48    #define ADCS11  0x02
49    #define ADCS10  0x01
50
51 SFR(ADINS, 0xA3); // A/D input select
52    #define ADI13 0x80
53    #define ADI12 0x40
54    #define ADI11 0x20
55    #define ADI10 0x10
56
57 SFR(ADMODA, 0xC0); // A/D mode register A
58    #define BNDI1  0x80
59    #define BURST1 0x40
60    #define SCC1   0x20
61    #define SCAN1  0x10
62
63 SFR(ADMODB, 0xA1); // A/D mode register B
64    #define CLK2   0x80
65    #define CLK1   0x40
66    #define CLK0   0x20
67    #define ENDAC1 0x08
68    #define BSA1   0x02
69
70 SFR(AD1BH, 0xC4); // A/D_1 boundary high register
71
72 SFR(AD1BL, 0xBC); // A/D_1 boundary low register
73
74 SFR(AD1DAT0, 0xD5); // A/D_1 data register 0
75
76 SFR(AD1DAT1, 0xD6); // A/D_1 data register 1
77
78 SFR(AD1DAT2, 0xD7); // A/D_1 data register 2
79
80 SFR(AD1DAT3, 0xF5); // A/D_1 data register 3
81
82 SFR(AUXR1, 0xA2); // Auxiliary function register
83    #define CLKLP 0x80
84    #define EBRR  0x40
85    #define ENT1  0x20
86    #define ENT0  0x10
87    #define SRST  0x08
88    #define DPS   0x01
89
90 SFR(B, 0xF0); // B register
91    SBIT(B_7, 0xF0, 7);
92    SBIT(B_6, 0xF0, 6);
93    SBIT(B_5, 0xF0, 5);
94    SBIT(B_4, 0xF0, 4);
95    SBIT(B_3, 0xF0, 3);
96    SBIT(B_2, 0xF0, 2);
97    SBIT(B_1, 0xF0, 1);
98    SBIT(B_0, 0xF0, 0);
99
100 SFR(BRGR0, 0xBE); // Baud rate generator rate LOW
101
102 SFR(BRGR1, 0xBF); // Baud rate generator rate HIGH
103
104 SFR(BRGCON, 0xBD); // Baud rate generator control
105    #define SBRGS 0x02
106    #define BRGEN 0x01
107
108 SFR(CMP1, 0xAC); // Comparator1 control register
109    #define CE1  0x20
110    #define CP1  0x10
111    #define CN1  0x08
112    #define OE1  0x04
113    #define CO1  0x02
114    #define CMF1 0x01
115
116 SFR(CMP2, 0xAD); // Comparator2 control register
117    #define CE2  0x20
118    #define CP2  0x10
119    #define CN2  0x08
120    #define OE2  0x04
121    #define CO2  0x02
122    #define CMF2 0x01
123
124 SFR(DIVM, 0x95); // CPU clock divide-by-M control
125
126 SFR(DPH, 0x83); // Data pointer HIGH
127
128 SFR(DPL, 0x82); // Data pointer LOW
129
130 SFR(FMADRH, 0xE7); // Program Flash address HIGH
131
132 SFR(FMADRL, 0xE6); // Program Flash address LOW
133
134 SFR(FMCON, 0xE4); // Program Flash control (Read)
135    #define BUSY 0x80
136    #define HVA  0x08
137    #define HVE  0x04
138    #define SV  0x02
139    #define OI  0x01
140
141 SFR(FMCON, 0xE4); // Program Flash control (Write)
142    #define FMCMD_7 0x80
143    #define FMCMD_6 0x40
144    #define FMCMD_5 0x20
145    #define FMCMD_4 0x10
146    #define FMCMD_3 0x08
147    #define FMCMD_2 0x04
148    #define FMCMD_1 0x02
149    #define FMCMD_0 0x01
150
151 SFR(FMDATA, 0xE5); // Program Flash data
152
153 SFR(I2ADR, 0xDB); // I2C slave address register
154    #define I2ADR_6 0x80
155    #define I2ADR_5 0x40
156    #define I2ADR_4 0x20
157    #define I2ADR_3 0x10
158    #define I2ADR_2 0x08
159    #define I2ADR_1 0x04
160    #define I2ADR_0 0x02
161    #define GC      0x01
162
163 SFR(I2CON, 0xD8); // I2C control register
164    SBIT(I2EN,  0xD8, 6);
165    SBIT(STA,   0xD8, 5);
166    SBIT(STO,   0xD8, 4);
167    SBIT(SI,    0xD8, 3);
168    SBIT(AA,    0xD8, 2);
169    SBIT(CRSEL, 0xD8, 0);
170
171 SFR(I2DAT, 0xDA); // I2C data register
172
173 SFR(I2SCLH, 0xDD); // Serial clock generator/SCL duty cycle register HIGH
174
175 SFR(I2SCLL, 0xDC); // Serial clock generator/SCL duty cycle register LOW
176
177 SFR(I2STAT, 0xD9); // I2C status register
178    #define STA_4 0x80
179    #define STA_3 0x40
180    #define STA_2 0x20
181    #define STA_1 0x10
182    #define STA_0 0x08
183
184 SFR(IEN0, 0xA8); // Interrupt enable 0
185    SBIT(EA,    0xA8, 7);
186    SBIT(EWDRT, 0xA8, 6);
187    SBIT(EBO,   0xA8, 5);
188    SBIT(ES,    0xA8, 4);
189    SBIT(ESR,   0xA8, 4);
190    SBIT(ET1,   0xA8, 3);
191    SBIT(EX1,   0xA8, 2);
192    SBIT(ET0,   0xA8, 1);
193    SBIT(EX0,   0xA8, 0);
194
195 SFR(IEN1, 0xE8); // Interrupt enable 1
196    SBIT(EAD,  0xE8, 7);
197    SBIT(EST,  0xE8, 6);
198    SBIT(EC,   0xE8, 2);
199    SBIT(EKBI, 0xE8, 1);
200    SBIT(EI2C, 0xE8, 0);
201
202 SFR(IP0, 0xB8); // Interrupt priority 0
203    SBIT(PWDRT, 0xB8, 6);
204    SBIT(PBO,   0xB8, 5);
205    SBIT(PS,    0xB8, 4);
206    SBIT(PSR,   0xB8, 4);
207    SBIT(PT1,   0xB8, 3);
208    SBIT(PX1,   0xB8, 2);
209    SBIT(PT0,   0xB8, 1);
210    SBIT(PX0,   0xB8, 0);
211
212 SFR(IP0H, 0xB7); // Interrupt priority 0 HIGH
213    #define PWDRTH 0x40
214    #define PBOH   0x20
215    #define PSH    0x10
216    #define PSRH   0x10
217    #define PT1H   0x08
218    #define PX1H   0x04
219    #define PT0H   0x02
220    #define PX0H   0x01
221
222 SFR(IP1, 0xF8); // Interrupt priority 1
223    SBIT(PAD,  0xF8, 7);
224    SBIT(PST,  0xF8, 6);
225    SBIT(PC,   0xF8, 2);
226    SBIT(PKBI, 0xF8, 1);
227    SBIT(PI2C, 0xF8, 0);
228
229 SFR(IP1H, 0xF7); // Interrupt priority 1 HIGH
230    #define PADH  0x80
231    #define PSTH  0x40
232    #define PCH   0x04
233    #define PKBIH 0x02
234    #define PI2CH 0x01
235
236 SFR(KBCON, 0x94); // Keypad control register
237    #define PATN_SEL 0x02 //Pattern Matching Polarity selection
238    #define KBIF     0x01 // Keypad Interrupt Flag
239
240 SFR(KBMASK, 0x86); // Keypad interrupt register mask
241
242 SFR(KBPATN, 0x93); // Keypad pattern register
243
244 SFR(P0, 0x80); // Port 0
245    SBIT(P0_7, 0x80, 7);
246    SBIT(P0_6, 0x80, 6);
247    SBIT(P0_5, 0x80, 5);
248    SBIT(P0_4, 0x80, 4);
249    SBIT(P0_3, 0x80, 3);
250    SBIT(P0_2, 0x80, 2);
251    SBIT(P0_1, 0x80, 1);
252    SBIT(P0_0, 0x80, 0);
253    //P0 alternate pin functions
254    SBIT(T1,     0x80, 7);
255    SBIT(CMP1b,  0x80, 6); //Should be CMP1 but there is SFR with that name
256    SBIT(CMPREF, 0x80, 5);
257    SBIT(CIN1A,  0x80, 4);
258    SBIT(CIN1B,  0x80, 3);
259    SBIT(CIN2A,  0x80, 2);
260    SBIT(CIN2B,  0x80, 1);
261    SBIT(CMP2b,  0x80, 0); //Should be CMP2 but there is SFR with that name
262    //More P0 alternate pin functions
263    SBIT(KB7, 0x80, 7);
264    SBIT(KB6, 0x80, 6);
265    SBIT(KB5, 0x80, 5);
266    SBIT(KB4, 0x80, 4);
267    SBIT(KB3, 0x80, 3);
268    SBIT(KB2, 0x80, 2);
269    SBIT(KB1, 0x80, 1);
270    SBIT(KB0, 0x80, 0);
271
272 SFR(P1, 0x90); // Port 1
273    SBIT(P1_7, 0x90, 7);
274    SBIT(P1_6, 0x90, 6);
275    SBIT(P1_5, 0x90, 5);
276    SBIT(P1_4, 0x90, 4);
277    SBIT(P1_3, 0x90, 3);
278    SBIT(P1_2, 0x90, 2);
279    SBIT(P1_1, 0x90, 1);
280    SBIT(P1_0, 0x90, 0);
281    //P1 alternate pin functions
282    SBIT(RST,  0x90, 5);
283    SBIT(INT1, 0x90, 4);
284    SBIT(INT0, 0x90, 3);
285    SBIT(SDA,  0x90, 3);
286    SBIT(T0,   0x90, 2);
287    SBIT(SCL,  0x90, 2);
288    SBIT(RXD,  0x90, 1);
289    SBIT(TXD,  0x90, 0);
290
291 SFR(P3, 0xB0); // Port 3
292    SBIT(P3_1, 0xB0, 1);
293    SBIT(P3_0, 0xB0, 0);
294    SBIT(XTAL1, 0xB0, 1);
295    SBIT(XTAL2, 0xB0, 0);
296
297 SFR(P0M1, 0x84); // Port0 output mode1
298    #define P0M1_7 0x80
299    #define P0M1_6 0x40
300    #define P0M1_5 0x20
301    #define P0M1_4 0x10
302    #define P0M1_3 0x08
303    #define P0M1_2 0x04
304    #define P0M1_1 0x02
305    #define P0M1_0 0x01
306
307 SFR(P0M2, 0x85); // Port0 output mode2
308    #define P0M2_7 0x80
309    #define P0M2_6 0x40
310    #define P0M2_5 0x20
311    #define P0M2_4 0x10
312    #define P0M2_3 0x08
313    #define P0M2_2 0x04
314    #define P0M2_1 0x02
315    #define P0M2_0 0x01
316
317 SFR(P1M1, 0x91); // Port1 output mode1
318    #define P1M1_7 0x80
319    #define P1M1_6 0x40
320    #define P1M1_4 0x10
321    #define P1M1_3 0x08
322    #define P1M1_2 0x04
323    #define P1M1_1 0x02
324    #define P1M1_0 0x01
325
326 SFR(P1M2, 0x92); // Port1 output mode2
327    #define P1M2_7 0x80
328    #define P1M2_6 0x40
329    #define P1M2_4 0x10
330    #define P1M2_3 0x08
331    #define P1M2_2 0x04
332    #define P1M2_1 0x02
333    #define P1M2_0 0x01
334
335 SFR(P3M1, 0xB1); // Port3 output mode1
336    #define P3M1_1 0x02
337    #define P3M1_0 0x01
338
339 SFR(P3M2, 0xB2); // Port3 output mode2
340    #define P3M2_1 0x02
341    #define P3M2_0 0x01
342
343 SFR(PCON, 0x87); // Power control register
344    #define SMOD1 0x80
345    #define SMOD0 0x40
346    #define BOPD  0x20
347    #define BOI   0x10
348    #define GF1   0x08
349    #define GF0   0x04
350    #define PMOD1 0x02
351    #define PMOD0 0x01
352
353 SFR(PCONA, 0xB5); // Power control register A
354    #define RTCPD 0x80
355    #define VCPD  0x20
356    #define ADPD  0x10
357    #define I2PD  0x08
358    #define SPD   0x02
359
360 SFR(PSW, 0xD0); // Program status word
361    SBIT(CY,  0xD0, 7);
362    SBIT(AC,  0xD0, 6);
363    SBIT(F0,  0xD0, 5);
364    SBIT(RS1, 0xD0, 4);
365    SBIT(RS0, 0xD0, 3);
366    SBIT(OV,  0xD0, 2);
367    SBIT(F1,  0xD0, 1);
368    SBIT(P,   0xD0, 0);
369
370 SFR(PT0AD, 0xF6); // Port0 digital input disable
371    #define PT0AD_5 0x20
372    #define PT0AD_4 0x10
373    #define PT0AD_3 0x08
374    #define PT0AD_2 0x04
375    #define PT0AD_1 0x02
376
377 SFR(RSTSRC, 0xDF); // Reset source register
378    #define BOF 0x20
379    #define POF 0x10
380    #define R_BK 0x08
381    #define R_WD 0x04
382    #define R_SF 0x02
383    #define R_EX 0x01
384
385 SFR(RTCCON, 0xD1); // Real-time clock control
386    #define RTCF  0x80
387    #define RTCS1 0x40
388    #define RTCS0 0x20
389    #define ERTC  0x02
390    #define RTCEN 0x01
391
392 SFR(RTCH, 0xD2); // Real-time clock register HIGH
393
394 SFR(RTCL, 0xD3); // Real-time clock register LOW
395
396 SFR(SADDR, 0xA9); // Serial port address register
397
398 SFR(SADEN, 0xB9); // Serial port address enable
399
400 SFR(SBUF, 0x99); // Serial Port data buffer register
401
402 SFR(SCON, 0x98); // Serial port control
403    SBIT(FE,  0x98, 7);
404    SBIT(SM0, 0x98, 7);
405    SBIT(SM1, 0x98, 6);
406    SBIT(SM2, 0x98, 5);
407    SBIT(REN, 0x98, 4);
408    SBIT(TB8, 0x98, 3);
409    SBIT(RB8, 0x98, 2);
410    SBIT(TI,  0x98, 1);
411    SBIT(RI,  0x98, 0);
412
413 SFR(SSTAT, 0xBA); // Serial port extended status register
414    #define DBMOD  0x80
415    #define INTLO  0x40
416    #define CIDIS  0x20
417    #define DBISEL 0x10
418    #define FE     0x08
419    #define BR     0x04
420    #define OE     0x02
421    #define STINT  0x01
422
423 SFR(SP, 0x81); // Stack pointer
424
425 SFR(TAMOD, 0x8F); // Timer0 and 1 auxiliary mode
426    #define T1M2 0x10
427    #define T0M2 0x01
428
429 SFR(TCON, 0x88); // Timer0 and 1 control
430    SBIT(TF1, 0x88, 7);
431    SBIT(TR1, 0x88, 6);
432    SBIT(TF0, 0x88, 5);
433    SBIT(TR0, 0x88, 4);
434    SBIT(IE1, 0x88, 3);
435    SBIT(IT1, 0x88, 2);
436    SBIT(IE0, 0x88, 1);
437    SBIT(IT0, 0x88, 0);
438
439 SFR(TH0, 0x8C); // Timer0 HIGH
440
441 SFR(TH1, 0x8D); // Timer 1 HIGH
442
443 SFR(TL0, 0x8A); // Timer 0 LOW
444
445 SFR(TL1, 0x8B); // Timer 1 LOW
446
447 SFR(TMOD, 0x89); // Timer0 and 1 mode
448    #define T1GATE 0x80
449    #define T1C_T  0x40
450    #define T1M1   0x20
451    #define T1M0   0x10
452    #define T0GATE 0x08
453    #define T0C_T  0x04
454    #define T0M1   0x02
455    #define T0M0   0x01
456
457 SFR(TRIM, 0x96); // Internal oscillator trim register
458    #define RCCLK  0x80
459    #define ENCLK  0x40
460    #define TRIM_5 0x20
461    #define TRIM_4 0x10
462    #define TRIM_3 0x08
463    #define TRIM_2 0x04
464    #define TRIM_1 0x02
465    #define TRIM_0 0x01
466
467 SFR(WDCON, 0xA7); // Watchdog control register
468    #define PRE2  0x80 //Watchdog Prescaler Tap Select bit 2
469    #define PRE1  0x40 //Watchdog Prescaler Tap Select bit 1
470    #define PRE0  0x20 //Watchdog Prescaler Tap Select bit 0
471    #define WDRUN 0x04 //Watchdog Run Control
472    #define WDTOF 0x02 //Watchdog Timer Time-Out Flag
473    #define WDCLK 0x01 //Watchdog input clock select
474
475 SFR(WDL, 0xC1); // Watchdog load
476
477 SFR(WFEED1, 0xC2); // Watchdog feed 1
478
479 SFR(WFEED2, 0xC3); // Watchdog feed 2
480
481 #endif /*REG_P89LPC925_H*/