1 /*
2  * This declarations of the PIC18F2331 MCU.
3  *
4  * This file is part of the GNU PIC library for SDCC, originally
5  * created by Molnar Karoly <molnarkaroly@users.sf.net> 2016.
6  *
7  * This file is generated automatically by the cinc2h.pl, 2016-04-13 17:23:43 UTC.
8  *
9  * SDCC is licensed under the GNU Public license (GPL) v2. Note that
10  * this license covers the code to the compiler and other executables,
11  * but explicitly does not cover any code or objects generated by sdcc.
12  *
13  * For pic device libraries and header files which are derived from
14  * Microchip header (.inc) and linker script (.lkr) files Microchip
15  * requires that "The header files should state that they are only to be
16  * used with authentic Microchip devices" which makes them incompatible
17  * with the GPL. Pic device libraries and header files are located at
18  * non-free/lib and non-free/include directories respectively.
19  * Sdcc should be run with the --use-non-free command line option in
20  * order to include non-free header files and libraries.
21  *
22  * See http://sdcc.sourceforge.net/ for the latest information on sdcc.
23  */
24 
25 #ifndef __PIC18F2331_H__
26 #define __PIC18F2331_H__
27 
28 //==============================================================================
29 
30 //==============================================================================
31 //
32 //	Register Definitions
33 //
34 //==============================================================================
35 
36 
37 //==============================================================================
38 //        DFLTCON Bits
39 
40 extern __at(0x0F60) __sfr DFLTCON;
41 
42 typedef union
43   {
44   struct
45     {
46     unsigned FLTCK0             : 1;
47     unsigned FLTCK1             : 1;
48     unsigned FLTCK2             : 1;
49     unsigned FLT1EN             : 1;
50     unsigned FLT2EN             : 1;
51     unsigned FLT3EN             : 1;
52     unsigned FLT4EN             : 1;
53     unsigned                    : 1;
54     };
55 
56   struct
57     {
58     unsigned FLTCK              : 3;
59     unsigned                    : 5;
60     };
61   } __DFLTCONbits_t;
62 
63 extern __at(0x0F60) volatile __DFLTCONbits_t DFLTCONbits;
64 
65 #define _FLTCK0                 0x01
66 #define _FLTCK1                 0x02
67 #define _FLTCK2                 0x04
68 #define _FLT1EN                 0x08
69 #define _FLT2EN                 0x10
70 #define _FLT3EN                 0x20
71 #define _FLT4EN                 0x40
72 
73 //==============================================================================
74 
75 
76 //==============================================================================
77 //        CAP3CON Bits
78 
79 extern __at(0x0F61) __sfr CAP3CON;
80 
81 typedef union
82   {
83   struct
84     {
85     unsigned CAP3M0             : 1;
86     unsigned CAP3M1             : 1;
87     unsigned CAP3M2             : 1;
88     unsigned CAP3M3             : 1;
89     unsigned                    : 1;
90     unsigned CAP3TMR            : 1;
91     unsigned CAP3REN            : 1;
92     unsigned                    : 1;
93     };
94 
95   struct
96     {
97     unsigned CAP3M              : 4;
98     unsigned                    : 4;
99     };
100   } __CAP3CONbits_t;
101 
102 extern __at(0x0F61) volatile __CAP3CONbits_t CAP3CONbits;
103 
104 #define _CAP3M0                 0x01
105 #define _CAP3M1                 0x02
106 #define _CAP3M2                 0x04
107 #define _CAP3M3                 0x08
108 #define _CAP3TMR                0x20
109 #define _CAP3REN                0x40
110 
111 //==============================================================================
112 
113 
114 //==============================================================================
115 //        CAP2CON Bits
116 
117 extern __at(0x0F62) __sfr CAP2CON;
118 
119 typedef union
120   {
121   struct
122     {
123     unsigned CAP2M0             : 1;
124     unsigned CAP2M1             : 1;
125     unsigned CAP2M2             : 1;
126     unsigned CAP2M3             : 1;
127     unsigned                    : 1;
128     unsigned CAP2TMR            : 1;
129     unsigned CAP2REN            : 1;
130     unsigned                    : 1;
131     };
132 
133   struct
134     {
135     unsigned CAP2M              : 4;
136     unsigned                    : 4;
137     };
138   } __CAP2CONbits_t;
139 
140 extern __at(0x0F62) volatile __CAP2CONbits_t CAP2CONbits;
141 
142 #define _CAP2M0                 0x01
143 #define _CAP2M1                 0x02
144 #define _CAP2M2                 0x04
145 #define _CAP2M3                 0x08
146 #define _CAP2TMR                0x20
147 #define _CAP2REN                0x40
148 
149 //==============================================================================
150 
151 
152 //==============================================================================
153 //        CAP1CON Bits
154 
155 extern __at(0x0F63) __sfr CAP1CON;
156 
157 typedef union
158   {
159   struct
160     {
161     unsigned CAP1M0             : 1;
162     unsigned CAP1M1             : 1;
163     unsigned CAP1M2             : 1;
164     unsigned CAP1M3             : 1;
165     unsigned                    : 1;
166     unsigned CAP1TMR            : 1;
167     unsigned CAP1REN            : 1;
168     unsigned                    : 1;
169     };
170 
171   struct
172     {
173     unsigned CAP1M              : 4;
174     unsigned                    : 4;
175     };
176   } __CAP1CONbits_t;
177 
178 extern __at(0x0F63) volatile __CAP1CONbits_t CAP1CONbits;
179 
180 #define _CAP1M0                 0x01
181 #define _CAP1M1                 0x02
182 #define _CAP1M2                 0x04
183 #define _CAP1M3                 0x08
184 #define _CAP1TMR                0x20
185 #define _CAP1REN                0x40
186 
187 //==============================================================================
188 
189 extern __at(0x0F64) __sfr CAP3BUFL;
190 extern __at(0x0F64) __sfr MAXCNTL;
191 extern __at(0x0F65) __sfr CAP3BUFH;
192 extern __at(0x0F65) __sfr MAXCNTH;
193 extern __at(0x0F66) __sfr CAP2BUFL;
194 extern __at(0x0F66) __sfr POSCNTL;
195 extern __at(0x0F67) __sfr CAP2BUFH;
196 extern __at(0x0F67) __sfr POSCNTH;
197 extern __at(0x0F68) __sfr CAP1BUFL;
198 extern __at(0x0F68) __sfr VELRL;
199 extern __at(0x0F69) __sfr CAP1BUFH;
200 extern __at(0x0F69) __sfr VELRH;
201 
202 //==============================================================================
203 //        OVDCONS Bits
204 
205 extern __at(0x0F6A) __sfr OVDCONS;
206 
207 typedef struct
208   {
209   unsigned POUT0                : 1;
210   unsigned POUT1                : 1;
211   unsigned POUT2                : 1;
212   unsigned POUT3                : 1;
213   unsigned POUT4                : 1;
214   unsigned POUT5                : 1;
215   unsigned POUT6                : 1;
216   unsigned POUT7                : 1;
217   } __OVDCONSbits_t;
218 
219 extern __at(0x0F6A) volatile __OVDCONSbits_t OVDCONSbits;
220 
221 #define _POUT0                  0x01
222 #define _POUT1                  0x02
223 #define _POUT2                  0x04
224 #define _POUT3                  0x08
225 #define _POUT4                  0x10
226 #define _POUT5                  0x20
227 #define _POUT6                  0x40
228 #define _POUT7                  0x80
229 
230 //==============================================================================
231 
232 
233 //==============================================================================
234 //        OVDCOND Bits
235 
236 extern __at(0x0F6B) __sfr OVDCOND;
237 
238 typedef struct
239   {
240   unsigned POVD0                : 1;
241   unsigned POVD1                : 1;
242   unsigned POVD2                : 1;
243   unsigned POVD3                : 1;
244   unsigned POVD4                : 1;
245   unsigned POVD5                : 1;
246   unsigned POVD6                : 1;
247   unsigned POVD7                : 1;
248   } __OVDCONDbits_t;
249 
250 extern __at(0x0F6B) volatile __OVDCONDbits_t OVDCONDbits;
251 
252 #define _POVD0                  0x01
253 #define _POVD1                  0x02
254 #define _POVD2                  0x04
255 #define _POVD3                  0x08
256 #define _POVD4                  0x10
257 #define _POVD5                  0x20
258 #define _POVD6                  0x40
259 #define _POVD7                  0x80
260 
261 //==============================================================================
262 
263 
264 //==============================================================================
265 //        FLTCONFIG Bits
266 
267 extern __at(0x0F6C) __sfr FLTCONFIG;
268 
269 typedef struct
270   {
271   unsigned FLTAEN               : 1;
272   unsigned FLTAMOD              : 1;
273   unsigned FLTAS                : 1;
274   unsigned FLTCON               : 1;
275   unsigned FLTBEN               : 1;
276   unsigned FLTBMOD              : 1;
277   unsigned FLTBS                : 1;
278   unsigned BRFEN                : 1;
279   } __FLTCONFIGbits_t;
280 
281 extern __at(0x0F6C) volatile __FLTCONFIGbits_t FLTCONFIGbits;
282 
283 #define _FLTAEN                 0x01
284 #define _FLTAMOD                0x02
285 #define _FLTAS                  0x04
286 #define _FLTCON                 0x08
287 #define _FLTBEN                 0x10
288 #define _FLTBMOD                0x20
289 #define _FLTBS                  0x40
290 #define _BRFEN                  0x80
291 
292 //==============================================================================
293 
294 
295 //==============================================================================
296 //        DTCON Bits
297 
298 extern __at(0x0F6D) __sfr DTCON;
299 
300 typedef union
301   {
302   struct
303     {
304     unsigned DT0                : 1;
305     unsigned DT1                : 1;
306     unsigned DT2                : 1;
307     unsigned DT3                : 1;
308     unsigned DT4                : 1;
309     unsigned DT5                : 1;
310     unsigned DTPS0              : 1;
311     unsigned DTPS1              : 1;
312     };
313 
314   struct
315     {
316     unsigned DTA0               : 1;
317     unsigned DTA1               : 1;
318     unsigned DTA2               : 1;
319     unsigned DTA3               : 1;
320     unsigned DTA4               : 1;
321     unsigned DTA5               : 1;
322     unsigned DTAPS0             : 1;
323     unsigned DTAPS1             : 1;
324     };
325 
326   struct
327     {
328     unsigned DTA                : 6;
329     unsigned                    : 2;
330     };
331 
332   struct
333     {
334     unsigned DT                 : 6;
335     unsigned                    : 2;
336     };
337 
338   struct
339     {
340     unsigned                    : 6;
341     unsigned DTPS               : 2;
342     };
343 
344   struct
345     {
346     unsigned                    : 6;
347     unsigned DTAPS              : 2;
348     };
349   } __DTCONbits_t;
350 
351 extern __at(0x0F6D) volatile __DTCONbits_t DTCONbits;
352 
353 #define _DT0                    0x01
354 #define _DTA0                   0x01
355 #define _DT1                    0x02
356 #define _DTA1                   0x02
357 #define _DT2                    0x04
358 #define _DTA2                   0x04
359 #define _DT3                    0x08
360 #define _DTA3                   0x08
361 #define _DT4                    0x10
362 #define _DTA4                   0x10
363 #define _DT5                    0x20
364 #define _DTA5                   0x20
365 #define _DTPS0                  0x40
366 #define _DTAPS0                 0x40
367 #define _DTPS1                  0x80
368 #define _DTAPS1                 0x80
369 
370 //==============================================================================
371 
372 
373 //==============================================================================
374 //        PWMCON1 Bits
375 
376 extern __at(0x0F6E) __sfr PWMCON1;
377 
378 typedef union
379   {
380   struct
381     {
382     unsigned OSYNC              : 1;
383     unsigned UDIS               : 1;
384     unsigned                    : 1;
385     unsigned SEVTDIR            : 1;
386     unsigned SEVOPS0            : 1;
387     unsigned SEVOPS1            : 1;
388     unsigned SEVOPS2            : 1;
389     unsigned SEVOPS3            : 1;
390     };
391 
392   struct
393     {
394     unsigned                    : 4;
395     unsigned SEVOPS             : 4;
396     };
397   } __PWMCON1bits_t;
398 
399 extern __at(0x0F6E) volatile __PWMCON1bits_t PWMCON1bits;
400 
401 #define _OSYNC                  0x01
402 #define _UDIS                   0x02
403 #define _SEVTDIR                0x08
404 #define _SEVOPS0                0x10
405 #define _SEVOPS1                0x20
406 #define _SEVOPS2                0x40
407 #define _SEVOPS3                0x80
408 
409 //==============================================================================
410 
411 
412 //==============================================================================
413 //        PWMCON0 Bits
414 
415 extern __at(0x0F6F) __sfr PWMCON0;
416 
417 typedef union
418   {
419   struct
420     {
421     unsigned PMOD0              : 1;
422     unsigned PMOD1              : 1;
423     unsigned PMOD2              : 1;
424     unsigned PMOD3              : 1;
425     unsigned PWMEN0             : 1;
426     unsigned PWMEN1             : 1;
427     unsigned PWMEN2             : 1;
428     unsigned                    : 1;
429     };
430 
431   struct
432     {
433     unsigned PMOD               : 4;
434     unsigned                    : 4;
435     };
436 
437   struct
438     {
439     unsigned                    : 4;
440     unsigned PWMEN              : 3;
441     unsigned                    : 1;
442     };
443   } __PWMCON0bits_t;
444 
445 extern __at(0x0F6F) volatile __PWMCON0bits_t PWMCON0bits;
446 
447 #define _PMOD0                  0x01
448 #define _PMOD1                  0x02
449 #define _PMOD2                  0x04
450 #define _PMOD3                  0x08
451 #define _PWMEN0                 0x10
452 #define _PWMEN1                 0x20
453 #define _PWMEN2                 0x40
454 
455 //==============================================================================
456 
457 extern __at(0x0F70) __sfr SEVTCMPH;
458 extern __at(0x0F71) __sfr SEVTCMPL;
459 extern __at(0x0F74) __sfr PDC2H;
460 extern __at(0x0F75) __sfr PDC2L;
461 extern __at(0x0F76) __sfr PDC1H;
462 extern __at(0x0F77) __sfr PDC1L;
463 extern __at(0x0F78) __sfr PDC0H;
464 extern __at(0x0F79) __sfr PDC0L;
465 extern __at(0x0F7A) __sfr PTPERH;
466 extern __at(0x0F7B) __sfr PTPERL;
467 extern __at(0x0F7C) __sfr PTMRH;
468 extern __at(0x0F7D) __sfr PTMRL;
469 
470 //==============================================================================
471 //        PTCON1 Bits
472 
473 extern __at(0x0F7E) __sfr PTCON1;
474 
475 typedef struct
476   {
477   unsigned                      : 1;
478   unsigned                      : 1;
479   unsigned                      : 1;
480   unsigned                      : 1;
481   unsigned                      : 1;
482   unsigned                      : 1;
483   unsigned PTDIR                : 1;
484   unsigned PTEN                 : 1;
485   } __PTCON1bits_t;
486 
487 extern __at(0x0F7E) volatile __PTCON1bits_t PTCON1bits;
488 
489 #define _PTDIR                  0x40
490 #define _PTEN                   0x80
491 
492 //==============================================================================
493 
494 
495 //==============================================================================
496 //        PTCON0 Bits
497 
498 extern __at(0x0F7F) __sfr PTCON0;
499 
500 typedef union
501   {
502   struct
503     {
504     unsigned PTMOD0             : 1;
505     unsigned PTMOD1             : 1;
506     unsigned PTCKPS0            : 1;
507     unsigned PTCKPS1            : 1;
508     unsigned PTOPS0             : 1;
509     unsigned PTOPS1             : 1;
510     unsigned PTOPS2             : 1;
511     unsigned PTOPS3             : 1;
512     };
513 
514   struct
515     {
516     unsigned PTMOD              : 2;
517     unsigned                    : 6;
518     };
519 
520   struct
521     {
522     unsigned                    : 2;
523     unsigned PTCKPS             : 2;
524     unsigned                    : 4;
525     };
526 
527   struct
528     {
529     unsigned                    : 4;
530     unsigned PTOPS              : 4;
531     };
532   } __PTCON0bits_t;
533 
534 extern __at(0x0F7F) volatile __PTCON0bits_t PTCON0bits;
535 
536 #define _PTMOD0                 0x01
537 #define _PTMOD1                 0x02
538 #define _PTCKPS0                0x04
539 #define _PTCKPS1                0x08
540 #define _PTOPS0                 0x10
541 #define _PTOPS1                 0x20
542 #define _PTOPS2                 0x40
543 #define _PTOPS3                 0x80
544 
545 //==============================================================================
546 
547 
548 //==============================================================================
549 //        PORTA Bits
550 
551 extern __at(0x0F80) __sfr PORTA;
552 
553 typedef union
554   {
555   struct
556     {
557     unsigned RA0                : 1;
558     unsigned RA1                : 1;
559     unsigned RA2                : 1;
560     unsigned RA3                : 1;
561     unsigned RA4                : 1;
562     unsigned                    : 1;
563     unsigned RA6                : 1;
564     unsigned RA7                : 1;
565     };
566 
567   struct
568     {
569     unsigned AN0                : 1;
570     unsigned AN1                : 1;
571     unsigned AN2                : 1;
572     unsigned AN3                : 1;
573     unsigned AN4                : 1;
574     unsigned                    : 1;
575     unsigned OSC2               : 1;
576     unsigned OSC1               : 1;
577     };
578 
579   struct
580     {
581     unsigned                    : 1;
582     unsigned                    : 1;
583     unsigned VREFM              : 1;
584     unsigned VREFP              : 1;
585     unsigned                    : 1;
586     unsigned                    : 1;
587     unsigned CLKO               : 1;
588     unsigned CLKI               : 1;
589     };
590 
591   struct
592     {
593     unsigned AN                 : 5;
594     unsigned                    : 3;
595     };
596   } __PORTAbits_t;
597 
598 extern __at(0x0F80) volatile __PORTAbits_t PORTAbits;
599 
600 #define _PORTA_RA0              0x01
601 #define _PORTA_AN0              0x01
602 #define _PORTA_RA1              0x02
603 #define _PORTA_AN1              0x02
604 #define _PORTA_RA2              0x04
605 #define _PORTA_AN2              0x04
606 #define _PORTA_VREFM            0x04
607 #define _PORTA_RA3              0x08
608 #define _PORTA_AN3              0x08
609 #define _PORTA_VREFP            0x08
610 #define _PORTA_RA4              0x10
611 #define _PORTA_AN4              0x10
612 #define _PORTA_RA6              0x40
613 #define _PORTA_OSC2             0x40
614 #define _PORTA_CLKO             0x40
615 #define _PORTA_RA7              0x80
616 #define _PORTA_OSC1             0x80
617 #define _PORTA_CLKI             0x80
618 
619 //==============================================================================
620 
621 
622 //==============================================================================
623 //        PORTB Bits
624 
625 extern __at(0x0F81) __sfr PORTB;
626 
627 typedef struct
628   {
629   unsigned RB0                  : 1;
630   unsigned RB1                  : 1;
631   unsigned RB2                  : 1;
632   unsigned RB3                  : 1;
633   unsigned RB4                  : 1;
634   unsigned RB5                  : 1;
635   unsigned RB6                  : 1;
636   unsigned RB7                  : 1;
637   } __PORTBbits_t;
638 
639 extern __at(0x0F81) volatile __PORTBbits_t PORTBbits;
640 
641 #define _PORTB_RB0              0x01
642 #define _PORTB_RB1              0x02
643 #define _PORTB_RB2              0x04
644 #define _PORTB_RB3              0x08
645 #define _PORTB_RB4              0x10
646 #define _PORTB_RB5              0x20
647 #define _PORTB_RB6              0x40
648 #define _PORTB_RB7              0x80
649 
650 //==============================================================================
651 
652 
653 //==============================================================================
654 //        PORTC Bits
655 
656 extern __at(0x0F82) __sfr PORTC;
657 
658 typedef union
659   {
660   struct
661     {
662     unsigned RC0                : 1;
663     unsigned RC1                : 1;
664     unsigned RC2                : 1;
665     unsigned RC3                : 1;
666     unsigned RC4                : 1;
667     unsigned RC5                : 1;
668     unsigned RC6                : 1;
669     unsigned RC7                : 1;
670     };
671 
672   struct
673     {
674     unsigned T1OSO              : 1;
675     unsigned T1OSI              : 1;
676     unsigned CCP1               : 1;
677     unsigned INT0               : 1;
678     unsigned INT1               : 1;
679     unsigned INT2               : 1;
680     unsigned TX                 : 1;
681     unsigned RX                 : 1;
682     };
683 
684   struct
685     {
686     unsigned T13CKI             : 1;
687     unsigned CCP2               : 1;
688     unsigned NOT_FLTB           : 1;
689     unsigned T0CKI              : 1;
690     unsigned SDA                : 1;
691     unsigned SCK                : 1;
692     unsigned CK                 : 1;
693     unsigned SDO                : 1;
694     };
695 
696   struct
697     {
698     unsigned                    : 1;
699     unsigned NOT_FLTA           : 1;
700     unsigned FLTB               : 1;
701     unsigned T5CKI              : 1;
702     unsigned SDI                : 1;
703     unsigned SCL                : 1;
704     unsigned NOT_SS             : 1;
705     unsigned                    : 1;
706     };
707 
708   struct
709     {
710     unsigned                    : 1;
711     unsigned FLTA               : 1;
712     unsigned                    : 1;
713     unsigned                    : 1;
714     unsigned                    : 1;
715     unsigned                    : 1;
716     unsigned SS                 : 1;
717     unsigned                    : 1;
718     };
719 
720   struct
721     {
722     unsigned                    : 3;
723     unsigned INT                : 3;
724     unsigned                    : 2;
725     };
726   } __PORTCbits_t;
727 
728 extern __at(0x0F82) volatile __PORTCbits_t PORTCbits;
729 
730 #define _PORTC_RC0              0x01
731 #define _PORTC_T1OSO            0x01
732 #define _PORTC_T13CKI           0x01
733 #define _PORTC_RC1              0x02
734 #define _PORTC_T1OSI            0x02
735 #define _PORTC_CCP2             0x02
736 #define _PORTC_NOT_FLTA         0x02
737 #define _PORTC_FLTA             0x02
738 #define _PORTC_RC2              0x04
739 #define _PORTC_CCP1             0x04
740 #define _PORTC_NOT_FLTB         0x04
741 #define _PORTC_FLTB             0x04
742 #define _PORTC_RC3              0x08
743 #define _PORTC_INT0             0x08
744 #define _PORTC_T0CKI            0x08
745 #define _PORTC_T5CKI            0x08
746 #define _PORTC_RC4              0x10
747 #define _PORTC_INT1             0x10
748 #define _PORTC_SDA              0x10
749 #define _PORTC_SDI              0x10
750 #define _PORTC_RC5              0x20
751 #define _PORTC_INT2             0x20
752 #define _PORTC_SCK              0x20
753 #define _PORTC_SCL              0x20
754 #define _PORTC_RC6              0x40
755 #define _PORTC_TX               0x40
756 #define _PORTC_CK               0x40
757 #define _PORTC_NOT_SS           0x40
758 #define _PORTC_SS               0x40
759 #define _PORTC_RC7              0x80
760 #define _PORTC_RX               0x80
761 #define _PORTC_SDO              0x80
762 
763 //==============================================================================
764 
765 
766 //==============================================================================
767 //        PORTE Bits
768 
769 extern __at(0x0F84) __sfr PORTE;
770 
771 typedef union
772   {
773   struct
774     {
775     unsigned                    : 1;
776     unsigned                    : 1;
777     unsigned                    : 1;
778     unsigned RE3                : 1;
779     unsigned                    : 1;
780     unsigned                    : 1;
781     unsigned                    : 1;
782     unsigned                    : 1;
783     };
784 
785   struct
786     {
787     unsigned                    : 1;
788     unsigned                    : 1;
789     unsigned                    : 1;
790     unsigned NOT_MCLR           : 1;
791     unsigned                    : 1;
792     unsigned                    : 1;
793     unsigned                    : 1;
794     unsigned                    : 1;
795     };
796 
797   struct
798     {
799     unsigned                    : 1;
800     unsigned                    : 1;
801     unsigned                    : 1;
802     unsigned MCLR               : 1;
803     unsigned                    : 1;
804     unsigned                    : 1;
805     unsigned                    : 1;
806     unsigned                    : 1;
807     };
808   } __PORTEbits_t;
809 
810 extern __at(0x0F84) volatile __PORTEbits_t PORTEbits;
811 
812 #define _RE3                    0x08
813 #define _NOT_MCLR               0x08
814 #define _MCLR                   0x08
815 
816 //==============================================================================
817 
818 extern __at(0x0F87) __sfr TMR5;
819 extern __at(0x0F87) __sfr TMR5L;
820 extern __at(0x0F88) __sfr TMR5H;
821 
822 //==============================================================================
823 //        LATA Bits
824 
825 extern __at(0x0F89) __sfr LATA;
826 
827 typedef struct
828   {
829   unsigned LATA0                : 1;
830   unsigned LATA1                : 1;
831   unsigned LATA2                : 1;
832   unsigned LATA3                : 1;
833   unsigned LATA4                : 1;
834   unsigned                      : 1;
835   unsigned LATA6                : 1;
836   unsigned LATA7                : 1;
837   } __LATAbits_t;
838 
839 extern __at(0x0F89) volatile __LATAbits_t LATAbits;
840 
841 #define _LATA0                  0x01
842 #define _LATA1                  0x02
843 #define _LATA2                  0x04
844 #define _LATA3                  0x08
845 #define _LATA4                  0x10
846 #define _LATA6                  0x40
847 #define _LATA7                  0x80
848 
849 //==============================================================================
850 
851 
852 //==============================================================================
853 //        LATB Bits
854 
855 extern __at(0x0F8A) __sfr LATB;
856 
857 typedef struct
858   {
859   unsigned LATB0                : 1;
860   unsigned LATB1                : 1;
861   unsigned LATB2                : 1;
862   unsigned LATB3                : 1;
863   unsigned LATB4                : 1;
864   unsigned LATB5                : 1;
865   unsigned LATB6                : 1;
866   unsigned LATB7                : 1;
867   } __LATBbits_t;
868 
869 extern __at(0x0F8A) volatile __LATBbits_t LATBbits;
870 
871 #define _LATB0                  0x01
872 #define _LATB1                  0x02
873 #define _LATB2                  0x04
874 #define _LATB3                  0x08
875 #define _LATB4                  0x10
876 #define _LATB5                  0x20
877 #define _LATB6                  0x40
878 #define _LATB7                  0x80
879 
880 //==============================================================================
881 
882 
883 //==============================================================================
884 //        LATC Bits
885 
886 extern __at(0x0F8B) __sfr LATC;
887 
888 typedef struct
889   {
890   unsigned LATC0                : 1;
891   unsigned LATC1                : 1;
892   unsigned LATC2                : 1;
893   unsigned LATC3                : 1;
894   unsigned LATC4                : 1;
895   unsigned LATC5                : 1;
896   unsigned LATC6                : 1;
897   unsigned LATC7                : 1;
898   } __LATCbits_t;
899 
900 extern __at(0x0F8B) volatile __LATCbits_t LATCbits;
901 
902 #define _LATC0                  0x01
903 #define _LATC1                  0x02
904 #define _LATC2                  0x04
905 #define _LATC3                  0x08
906 #define _LATC4                  0x10
907 #define _LATC5                  0x20
908 #define _LATC6                  0x40
909 #define _LATC7                  0x80
910 
911 //==============================================================================
912 
913 extern __at(0x0F90) __sfr PR5;
914 extern __at(0x0F90) __sfr PR5L;
915 extern __at(0x0F91) __sfr PR5H;
916 
917 //==============================================================================
918 //        DDRA Bits
919 
920 extern __at(0x0F92) __sfr DDRA;
921 
922 typedef union
923   {
924   struct
925     {
926     unsigned TRISA0             : 1;
927     unsigned TRISA1             : 1;
928     unsigned TRISA2             : 1;
929     unsigned TRISA3             : 1;
930     unsigned TRISA4             : 1;
931     unsigned                    : 1;
932     unsigned TRISA6             : 1;
933     unsigned TRISA7             : 1;
934     };
935 
936   struct
937     {
938     unsigned RA0                : 1;
939     unsigned RA1                : 1;
940     unsigned RA2                : 1;
941     unsigned RA3                : 1;
942     unsigned RA4                : 1;
943     unsigned                    : 1;
944     unsigned RA6                : 1;
945     unsigned RA7                : 1;
946     };
947   } __DDRAbits_t;
948 
949 extern __at(0x0F92) volatile __DDRAbits_t DDRAbits;
950 
951 #define _TRISA0                 0x01
952 #define _RA0                    0x01
953 #define _TRISA1                 0x02
954 #define _RA1                    0x02
955 #define _TRISA2                 0x04
956 #define _RA2                    0x04
957 #define _TRISA3                 0x08
958 #define _RA3                    0x08
959 #define _TRISA4                 0x10
960 #define _RA4                    0x10
961 #define _TRISA6                 0x40
962 #define _RA6                    0x40
963 #define _TRISA7                 0x80
964 #define _RA7                    0x80
965 
966 //==============================================================================
967 
968 
969 //==============================================================================
970 //        TRISA Bits
971 
972 extern __at(0x0F92) __sfr TRISA;
973 
974 typedef union
975   {
976   struct
977     {
978     unsigned TRISA0             : 1;
979     unsigned TRISA1             : 1;
980     unsigned TRISA2             : 1;
981     unsigned TRISA3             : 1;
982     unsigned TRISA4             : 1;
983     unsigned                    : 1;
984     unsigned TRISA6             : 1;
985     unsigned TRISA7             : 1;
986     };
987 
988   struct
989     {
990     unsigned RA0                : 1;
991     unsigned RA1                : 1;
992     unsigned RA2                : 1;
993     unsigned RA3                : 1;
994     unsigned RA4                : 1;
995     unsigned                    : 1;
996     unsigned RA6                : 1;
997     unsigned RA7                : 1;
998     };
999   } __TRISAbits_t;
1000 
1001 extern __at(0x0F92) volatile __TRISAbits_t TRISAbits;
1002 
1003 #define _TRISA_TRISA0           0x01
1004 #define _TRISA_RA0              0x01
1005 #define _TRISA_TRISA1           0x02
1006 #define _TRISA_RA1              0x02
1007 #define _TRISA_TRISA2           0x04
1008 #define _TRISA_RA2              0x04
1009 #define _TRISA_TRISA3           0x08
1010 #define _TRISA_RA3              0x08
1011 #define _TRISA_TRISA4           0x10
1012 #define _TRISA_RA4              0x10
1013 #define _TRISA_TRISA6           0x40
1014 #define _TRISA_RA6              0x40
1015 #define _TRISA_TRISA7           0x80
1016 #define _TRISA_RA7              0x80
1017 
1018 //==============================================================================
1019 
1020 
1021 //==============================================================================
1022 //        DDRB Bits
1023 
1024 extern __at(0x0F93) __sfr DDRB;
1025 
1026 typedef union
1027   {
1028   struct
1029     {
1030     unsigned TRISB0             : 1;
1031     unsigned TRISB1             : 1;
1032     unsigned TRISB2             : 1;
1033     unsigned TRISB3             : 1;
1034     unsigned TRISB4             : 1;
1035     unsigned TRISB5             : 1;
1036     unsigned TRISB6             : 1;
1037     unsigned TRISB7             : 1;
1038     };
1039 
1040   struct
1041     {
1042     unsigned RB0                : 1;
1043     unsigned RB1                : 1;
1044     unsigned RB2                : 1;
1045     unsigned RB3                : 1;
1046     unsigned RB4                : 1;
1047     unsigned RB5                : 1;
1048     unsigned RB6                : 1;
1049     unsigned RB7                : 1;
1050     };
1051   } __DDRBbits_t;
1052 
1053 extern __at(0x0F93) volatile __DDRBbits_t DDRBbits;
1054 
1055 #define _TRISB0                 0x01
1056 #define _RB0                    0x01
1057 #define _TRISB1                 0x02
1058 #define _RB1                    0x02
1059 #define _TRISB2                 0x04
1060 #define _RB2                    0x04
1061 #define _TRISB3                 0x08
1062 #define _RB3                    0x08
1063 #define _TRISB4                 0x10
1064 #define _RB4                    0x10
1065 #define _TRISB5                 0x20
1066 #define _RB5                    0x20
1067 #define _TRISB6                 0x40
1068 #define _RB6                    0x40
1069 #define _TRISB7                 0x80
1070 #define _RB7                    0x80
1071 
1072 //==============================================================================
1073 
1074 
1075 //==============================================================================
1076 //        TRISB Bits
1077 
1078 extern __at(0x0F93) __sfr TRISB;
1079 
1080 typedef union
1081   {
1082   struct
1083     {
1084     unsigned TRISB0             : 1;
1085     unsigned TRISB1             : 1;
1086     unsigned TRISB2             : 1;
1087     unsigned TRISB3             : 1;
1088     unsigned TRISB4             : 1;
1089     unsigned TRISB5             : 1;
1090     unsigned TRISB6             : 1;
1091     unsigned TRISB7             : 1;
1092     };
1093 
1094   struct
1095     {
1096     unsigned RB0                : 1;
1097     unsigned RB1                : 1;
1098     unsigned RB2                : 1;
1099     unsigned RB3                : 1;
1100     unsigned RB4                : 1;
1101     unsigned RB5                : 1;
1102     unsigned RB6                : 1;
1103     unsigned RB7                : 1;
1104     };
1105   } __TRISBbits_t;
1106 
1107 extern __at(0x0F93) volatile __TRISBbits_t TRISBbits;
1108 
1109 #define _TRISB_TRISB0           0x01
1110 #define _TRISB_RB0              0x01
1111 #define _TRISB_TRISB1           0x02
1112 #define _TRISB_RB1              0x02
1113 #define _TRISB_TRISB2           0x04
1114 #define _TRISB_RB2              0x04
1115 #define _TRISB_TRISB3           0x08
1116 #define _TRISB_RB3              0x08
1117 #define _TRISB_TRISB4           0x10
1118 #define _TRISB_RB4              0x10
1119 #define _TRISB_TRISB5           0x20
1120 #define _TRISB_RB5              0x20
1121 #define _TRISB_TRISB6           0x40
1122 #define _TRISB_RB6              0x40
1123 #define _TRISB_TRISB7           0x80
1124 #define _TRISB_RB7              0x80
1125 
1126 //==============================================================================
1127 
1128 
1129 //==============================================================================
1130 //        DDRC Bits
1131 
1132 extern __at(0x0F94) __sfr DDRC;
1133 
1134 typedef union
1135   {
1136   struct
1137     {
1138     unsigned TRISC0             : 1;
1139     unsigned TRISC1             : 1;
1140     unsigned TRISC2             : 1;
1141     unsigned TRISC3             : 1;
1142     unsigned TRISC4             : 1;
1143     unsigned TRISC5             : 1;
1144     unsigned TRISC6             : 1;
1145     unsigned TRISC7             : 1;
1146     };
1147 
1148   struct
1149     {
1150     unsigned RC0                : 1;
1151     unsigned RC1                : 1;
1152     unsigned RC2                : 1;
1153     unsigned RC3                : 1;
1154     unsigned RC4                : 1;
1155     unsigned RC5                : 1;
1156     unsigned RC6                : 1;
1157     unsigned RC7                : 1;
1158     };
1159   } __DDRCbits_t;
1160 
1161 extern __at(0x0F94) volatile __DDRCbits_t DDRCbits;
1162 
1163 #define _TRISC0                 0x01
1164 #define _RC0                    0x01
1165 #define _TRISC1                 0x02
1166 #define _RC1                    0x02
1167 #define _TRISC2                 0x04
1168 #define _RC2                    0x04
1169 #define _TRISC3                 0x08
1170 #define _RC3                    0x08
1171 #define _TRISC4                 0x10
1172 #define _RC4                    0x10
1173 #define _TRISC5                 0x20
1174 #define _RC5                    0x20
1175 #define _TRISC6                 0x40
1176 #define _RC6                    0x40
1177 #define _TRISC7                 0x80
1178 #define _RC7                    0x80
1179 
1180 //==============================================================================
1181 
1182 
1183 //==============================================================================
1184 //        TRISC Bits
1185 
1186 extern __at(0x0F94) __sfr TRISC;
1187 
1188 typedef union
1189   {
1190   struct
1191     {
1192     unsigned TRISC0             : 1;
1193     unsigned TRISC1             : 1;
1194     unsigned TRISC2             : 1;
1195     unsigned TRISC3             : 1;
1196     unsigned TRISC4             : 1;
1197     unsigned TRISC5             : 1;
1198     unsigned TRISC6             : 1;
1199     unsigned TRISC7             : 1;
1200     };
1201 
1202   struct
1203     {
1204     unsigned RC0                : 1;
1205     unsigned RC1                : 1;
1206     unsigned RC2                : 1;
1207     unsigned RC3                : 1;
1208     unsigned RC4                : 1;
1209     unsigned RC5                : 1;
1210     unsigned RC6                : 1;
1211     unsigned RC7                : 1;
1212     };
1213   } __TRISCbits_t;
1214 
1215 extern __at(0x0F94) volatile __TRISCbits_t TRISCbits;
1216 
1217 #define _TRISC_TRISC0           0x01
1218 #define _TRISC_RC0              0x01
1219 #define _TRISC_TRISC1           0x02
1220 #define _TRISC_RC1              0x02
1221 #define _TRISC_TRISC2           0x04
1222 #define _TRISC_RC2              0x04
1223 #define _TRISC_TRISC3           0x08
1224 #define _TRISC_RC3              0x08
1225 #define _TRISC_TRISC4           0x10
1226 #define _TRISC_RC4              0x10
1227 #define _TRISC_TRISC5           0x20
1228 #define _TRISC_RC5              0x20
1229 #define _TRISC_TRISC6           0x40
1230 #define _TRISC_RC6              0x40
1231 #define _TRISC_TRISC7           0x80
1232 #define _TRISC_RC7              0x80
1233 
1234 //==============================================================================
1235 
1236 
1237 //==============================================================================
1238 //        ADCHS Bits
1239 
1240 extern __at(0x0F99) __sfr ADCHS;
1241 
1242 typedef union
1243   {
1244   struct
1245     {
1246     unsigned GASEL0             : 1;
1247     unsigned GASEL1             : 1;
1248     unsigned GCSEL0             : 1;
1249     unsigned GCSEL1             : 1;
1250     unsigned GBSEL0             : 1;
1251     unsigned GBSEL1             : 1;
1252     unsigned GDSEL0             : 1;
1253     unsigned GDSEL1             : 1;
1254     };
1255 
1256   struct
1257     {
1258     unsigned SASEL0             : 1;
1259     unsigned SASEL1             : 1;
1260     unsigned SCSEL0             : 1;
1261     unsigned SCSEL1             : 1;
1262     unsigned SBSEL0             : 1;
1263     unsigned SBSEL1             : 1;
1264     unsigned SDSEL0             : 1;
1265     unsigned SDSEL1             : 1;
1266     };
1267 
1268   struct
1269     {
1270     unsigned GASEL              : 2;
1271     unsigned                    : 6;
1272     };
1273 
1274   struct
1275     {
1276     unsigned SASEL              : 2;
1277     unsigned                    : 6;
1278     };
1279 
1280   struct
1281     {
1282     unsigned                    : 2;
1283     unsigned SCSEL              : 2;
1284     unsigned                    : 4;
1285     };
1286 
1287   struct
1288     {
1289     unsigned                    : 2;
1290     unsigned GCSEL              : 2;
1291     unsigned                    : 4;
1292     };
1293 
1294   struct
1295     {
1296     unsigned                    : 4;
1297     unsigned GBSEL              : 2;
1298     unsigned                    : 2;
1299     };
1300 
1301   struct
1302     {
1303     unsigned                    : 4;
1304     unsigned SBSEL              : 2;
1305     unsigned                    : 2;
1306     };
1307 
1308   struct
1309     {
1310     unsigned                    : 6;
1311     unsigned SDSEL              : 2;
1312     };
1313 
1314   struct
1315     {
1316     unsigned                    : 6;
1317     unsigned GDSEL              : 2;
1318     };
1319   } __ADCHSbits_t;
1320 
1321 extern __at(0x0F99) volatile __ADCHSbits_t ADCHSbits;
1322 
1323 #define _GASEL0                 0x01
1324 #define _SASEL0                 0x01
1325 #define _GASEL1                 0x02
1326 #define _SASEL1                 0x02
1327 #define _GCSEL0                 0x04
1328 #define _SCSEL0                 0x04
1329 #define _GCSEL1                 0x08
1330 #define _SCSEL1                 0x08
1331 #define _GBSEL0                 0x10
1332 #define _SBSEL0                 0x10
1333 #define _GBSEL1                 0x20
1334 #define _SBSEL1                 0x20
1335 #define _GDSEL0                 0x40
1336 #define _SDSEL0                 0x40
1337 #define _GDSEL1                 0x80
1338 #define _SDSEL1                 0x80
1339 
1340 //==============================================================================
1341 
1342 
1343 //==============================================================================
1344 //        ADCON3 Bits
1345 
1346 extern __at(0x0F9A) __sfr ADCON3;
1347 
1348 typedef union
1349   {
1350   struct
1351     {
1352     unsigned SSRC0              : 1;
1353     unsigned SSRC1              : 1;
1354     unsigned SSRC2              : 1;
1355     unsigned SSRC3              : 1;
1356     unsigned SSRC4              : 1;
1357     unsigned                    : 1;
1358     unsigned ADRS0              : 1;
1359     unsigned ADRS1              : 1;
1360     };
1361 
1362   struct
1363     {
1364     unsigned SSRC               : 5;
1365     unsigned                    : 3;
1366     };
1367 
1368   struct
1369     {
1370     unsigned                    : 6;
1371     unsigned ADRS               : 2;
1372     };
1373   } __ADCON3bits_t;
1374 
1375 extern __at(0x0F9A) volatile __ADCON3bits_t ADCON3bits;
1376 
1377 #define _SSRC0                  0x01
1378 #define _SSRC1                  0x02
1379 #define _SSRC2                  0x04
1380 #define _SSRC3                  0x08
1381 #define _SSRC4                  0x10
1382 #define _ADRS0                  0x40
1383 #define _ADRS1                  0x80
1384 
1385 //==============================================================================
1386 
1387 
1388 //==============================================================================
1389 //        OSCTUNE Bits
1390 
1391 extern __at(0x0F9B) __sfr OSCTUNE;
1392 
1393 typedef union
1394   {
1395   struct
1396     {
1397     unsigned TUN0               : 1;
1398     unsigned TUN1               : 1;
1399     unsigned TUN2               : 1;
1400     unsigned TUN3               : 1;
1401     unsigned TUN4               : 1;
1402     unsigned TUN5               : 1;
1403     unsigned                    : 1;
1404     unsigned                    : 1;
1405     };
1406 
1407   struct
1408     {
1409     unsigned TUN                : 6;
1410     unsigned                    : 2;
1411     };
1412   } __OSCTUNEbits_t;
1413 
1414 extern __at(0x0F9B) volatile __OSCTUNEbits_t OSCTUNEbits;
1415 
1416 #define _TUN0                   0x01
1417 #define _TUN1                   0x02
1418 #define _TUN2                   0x04
1419 #define _TUN3                   0x08
1420 #define _TUN4                   0x10
1421 #define _TUN5                   0x20
1422 
1423 //==============================================================================
1424 
1425 
1426 //==============================================================================
1427 //        PIE1 Bits
1428 
1429 extern __at(0x0F9D) __sfr PIE1;
1430 
1431 typedef union
1432   {
1433   struct
1434     {
1435     unsigned TMR1IE             : 1;
1436     unsigned TMR2IE             : 1;
1437     unsigned CCP1IE             : 1;
1438     unsigned SSPIE              : 1;
1439     unsigned TXIE               : 1;
1440     unsigned RCIE               : 1;
1441     unsigned ADIE               : 1;
1442     unsigned                    : 1;
1443     };
1444 
1445   struct
1446     {
1447     unsigned                    : 1;
1448     unsigned                    : 1;
1449     unsigned                    : 1;
1450     unsigned                    : 1;
1451     unsigned TBIE               : 1;
1452     unsigned                    : 1;
1453     unsigned                    : 1;
1454     unsigned                    : 1;
1455     };
1456   } __PIE1bits_t;
1457 
1458 extern __at(0x0F9D) volatile __PIE1bits_t PIE1bits;
1459 
1460 #define _TMR1IE                 0x01
1461 #define _TMR2IE                 0x02
1462 #define _CCP1IE                 0x04
1463 #define _SSPIE                  0x08
1464 #define _TXIE                   0x10
1465 #define _TBIE                   0x10
1466 #define _RCIE                   0x20
1467 #define _ADIE                   0x40
1468 
1469 //==============================================================================
1470 
1471 
1472 //==============================================================================
1473 //        PIR1 Bits
1474 
1475 extern __at(0x0F9E) __sfr PIR1;
1476 
1477 typedef union
1478   {
1479   struct
1480     {
1481     unsigned TMR1IF             : 1;
1482     unsigned TMR2IF             : 1;
1483     unsigned CCP1IF             : 1;
1484     unsigned SSPIF              : 1;
1485     unsigned TXIF               : 1;
1486     unsigned RCIF               : 1;
1487     unsigned ADIF               : 1;
1488     unsigned                    : 1;
1489     };
1490 
1491   struct
1492     {
1493     unsigned                    : 1;
1494     unsigned                    : 1;
1495     unsigned                    : 1;
1496     unsigned                    : 1;
1497     unsigned TBIF               : 1;
1498     unsigned                    : 1;
1499     unsigned                    : 1;
1500     unsigned                    : 1;
1501     };
1502   } __PIR1bits_t;
1503 
1504 extern __at(0x0F9E) volatile __PIR1bits_t PIR1bits;
1505 
1506 #define _TMR1IF                 0x01
1507 #define _TMR2IF                 0x02
1508 #define _CCP1IF                 0x04
1509 #define _SSPIF                  0x08
1510 #define _TXIF                   0x10
1511 #define _TBIF                   0x10
1512 #define _RCIF                   0x20
1513 #define _ADIF                   0x40
1514 
1515 //==============================================================================
1516 
1517 
1518 //==============================================================================
1519 //        IPR1 Bits
1520 
1521 extern __at(0x0F9F) __sfr IPR1;
1522 
1523 typedef union
1524   {
1525   struct
1526     {
1527     unsigned TMR1IP             : 1;
1528     unsigned TMR2IP             : 1;
1529     unsigned CCP1IP             : 1;
1530     unsigned SSPIP              : 1;
1531     unsigned TXIP               : 1;
1532     unsigned RCIP               : 1;
1533     unsigned ADIP               : 1;
1534     unsigned                    : 1;
1535     };
1536 
1537   struct
1538     {
1539     unsigned                    : 1;
1540     unsigned                    : 1;
1541     unsigned                    : 1;
1542     unsigned                    : 1;
1543     unsigned TBIP               : 1;
1544     unsigned                    : 1;
1545     unsigned                    : 1;
1546     unsigned                    : 1;
1547     };
1548   } __IPR1bits_t;
1549 
1550 extern __at(0x0F9F) volatile __IPR1bits_t IPR1bits;
1551 
1552 #define _TMR1IP                 0x01
1553 #define _TMR2IP                 0x02
1554 #define _CCP1IP                 0x04
1555 #define _SSPIP                  0x08
1556 #define _TXIP                   0x10
1557 #define _TBIP                   0x10
1558 #define _RCIP                   0x20
1559 #define _ADIP                   0x40
1560 
1561 //==============================================================================
1562 
1563 
1564 //==============================================================================
1565 //        PIE2 Bits
1566 
1567 extern __at(0x0FA0) __sfr PIE2;
1568 
1569 typedef struct
1570   {
1571   unsigned CCP2IE               : 1;
1572   unsigned                      : 1;
1573   unsigned LVDIE                : 1;
1574   unsigned                      : 1;
1575   unsigned EEIE                 : 1;
1576   unsigned                      : 1;
1577   unsigned                      : 1;
1578   unsigned OSFIE                : 1;
1579   } __PIE2bits_t;
1580 
1581 extern __at(0x0FA0) volatile __PIE2bits_t PIE2bits;
1582 
1583 #define _CCP2IE                 0x01
1584 #define _LVDIE                  0x04
1585 #define _EEIE                   0x10
1586 #define _OSFIE                  0x80
1587 
1588 //==============================================================================
1589 
1590 
1591 //==============================================================================
1592 //        PIR2 Bits
1593 
1594 extern __at(0x0FA1) __sfr PIR2;
1595 
1596 typedef struct
1597   {
1598   unsigned CCP2IF               : 1;
1599   unsigned                      : 1;
1600   unsigned LVDIF                : 1;
1601   unsigned                      : 1;
1602   unsigned EEIF                 : 1;
1603   unsigned                      : 1;
1604   unsigned                      : 1;
1605   unsigned OSFIF                : 1;
1606   } __PIR2bits_t;
1607 
1608 extern __at(0x0FA1) volatile __PIR2bits_t PIR2bits;
1609 
1610 #define _CCP2IF                 0x01
1611 #define _LVDIF                  0x04
1612 #define _EEIF                   0x10
1613 #define _OSFIF                  0x80
1614 
1615 //==============================================================================
1616 
1617 
1618 //==============================================================================
1619 //        IPR2 Bits
1620 
1621 extern __at(0x0FA2) __sfr IPR2;
1622 
1623 typedef struct
1624   {
1625   unsigned CCP2IP               : 1;
1626   unsigned                      : 1;
1627   unsigned LVDIP                : 1;
1628   unsigned                      : 1;
1629   unsigned EEIP                 : 1;
1630   unsigned                      : 1;
1631   unsigned                      : 1;
1632   unsigned OSFIP                : 1;
1633   } __IPR2bits_t;
1634 
1635 extern __at(0x0FA2) volatile __IPR2bits_t IPR2bits;
1636 
1637 #define _CCP2IP                 0x01
1638 #define _LVDIP                  0x04
1639 #define _EEIP                   0x10
1640 #define _OSFIP                  0x80
1641 
1642 //==============================================================================
1643 
1644 
1645 //==============================================================================
1646 //        PIE3 Bits
1647 
1648 extern __at(0x0FA3) __sfr PIE3;
1649 
1650 typedef struct
1651   {
1652   unsigned TMR5IE               : 1;
1653   unsigned IC1IE                : 1;
1654   unsigned IC2QEIE              : 1;
1655   unsigned IC3DRIE              : 1;
1656   unsigned PTIE                 : 1;
1657   unsigned                      : 1;
1658   unsigned                      : 1;
1659   unsigned                      : 1;
1660   } __PIE3bits_t;
1661 
1662 extern __at(0x0FA3) volatile __PIE3bits_t PIE3bits;
1663 
1664 #define _TMR5IE                 0x01
1665 #define _IC1IE                  0x02
1666 #define _IC2QEIE                0x04
1667 #define _IC3DRIE                0x08
1668 #define _PTIE                   0x10
1669 
1670 //==============================================================================
1671 
1672 
1673 //==============================================================================
1674 //        PIR3 Bits
1675 
1676 extern __at(0x0FA4) __sfr PIR3;
1677 
1678 typedef struct
1679   {
1680   unsigned TMR5IF               : 1;
1681   unsigned IC1IF                : 1;
1682   unsigned IC2QEIF              : 1;
1683   unsigned IC3DRIF              : 1;
1684   unsigned PTIF                 : 1;
1685   unsigned                      : 1;
1686   unsigned                      : 1;
1687   unsigned                      : 1;
1688   } __PIR3bits_t;
1689 
1690 extern __at(0x0FA4) volatile __PIR3bits_t PIR3bits;
1691 
1692 #define _TMR5IF                 0x01
1693 #define _IC1IF                  0x02
1694 #define _IC2QEIF                0x04
1695 #define _IC3DRIF                0x08
1696 #define _PTIF                   0x10
1697 
1698 //==============================================================================
1699 
1700 
1701 //==============================================================================
1702 //        IPR3 Bits
1703 
1704 extern __at(0x0FA5) __sfr IPR3;
1705 
1706 typedef struct
1707   {
1708   unsigned TMR5IP               : 1;
1709   unsigned IC1IP                : 1;
1710   unsigned IC2QEIP              : 1;
1711   unsigned IC3DRIP              : 1;
1712   unsigned PTIP                 : 1;
1713   unsigned                      : 1;
1714   unsigned                      : 1;
1715   unsigned                      : 1;
1716   } __IPR3bits_t;
1717 
1718 extern __at(0x0FA5) volatile __IPR3bits_t IPR3bits;
1719 
1720 #define _TMR5IP                 0x01
1721 #define _IC1IP                  0x02
1722 #define _IC2QEIP                0x04
1723 #define _IC3DRIP                0x08
1724 #define _PTIP                   0x10
1725 
1726 //==============================================================================
1727 
1728 
1729 //==============================================================================
1730 //        EECON1 Bits
1731 
1732 extern __at(0x0FA6) __sfr EECON1;
1733 
1734 typedef struct
1735   {
1736   unsigned RD                   : 1;
1737   unsigned WR                   : 1;
1738   unsigned WREN                 : 1;
1739   unsigned WRERR                : 1;
1740   unsigned FREE                 : 1;
1741   unsigned                      : 1;
1742   unsigned CFGS                 : 1;
1743   unsigned EEPGD                : 1;
1744   } __EECON1bits_t;
1745 
1746 extern __at(0x0FA6) volatile __EECON1bits_t EECON1bits;
1747 
1748 #define _RD                     0x01
1749 #define _WR                     0x02
1750 #define _WREN                   0x04
1751 #define _WRERR                  0x08
1752 #define _FREE                   0x10
1753 #define _CFGS                   0x40
1754 #define _EEPGD                  0x80
1755 
1756 //==============================================================================
1757 
1758 extern __at(0x0FA7) __sfr EECON2;
1759 extern __at(0x0FA8) __sfr EEDATA;
1760 extern __at(0x0FA9) __sfr EEADR;
1761 
1762 //==============================================================================
1763 //        BAUDCON Bits
1764 
1765 extern __at(0x0FAA) __sfr BAUDCON;
1766 
1767 typedef union
1768   {
1769   struct
1770     {
1771     unsigned ABDEN              : 1;
1772     unsigned WUE                : 1;
1773     unsigned                    : 1;
1774     unsigned BRG16              : 1;
1775     unsigned TXCKP              : 1;
1776     unsigned RXDTP              : 1;
1777     unsigned RCIDL              : 1;
1778     unsigned ABDOVF             : 1;
1779     };
1780 
1781   struct
1782     {
1783     unsigned                    : 1;
1784     unsigned                    : 1;
1785     unsigned                    : 1;
1786     unsigned                    : 1;
1787     unsigned SCKP               : 1;
1788     unsigned                    : 1;
1789     unsigned RCMT               : 1;
1790     unsigned                    : 1;
1791     };
1792   } __BAUDCONbits_t;
1793 
1794 extern __at(0x0FAA) volatile __BAUDCONbits_t BAUDCONbits;
1795 
1796 #define _ABDEN                  0x01
1797 #define _WUE                    0x02
1798 #define _BRG16                  0x08
1799 #define _TXCKP                  0x10
1800 #define _SCKP                   0x10
1801 #define _RXDTP                  0x20
1802 #define _RCIDL                  0x40
1803 #define _RCMT                   0x40
1804 #define _ABDOVF                 0x80
1805 
1806 //==============================================================================
1807 
1808 
1809 //==============================================================================
1810 //        BAUDCTL Bits
1811 
1812 extern __at(0x0FAA) __sfr BAUDCTL;
1813 
1814 typedef union
1815   {
1816   struct
1817     {
1818     unsigned ABDEN              : 1;
1819     unsigned WUE                : 1;
1820     unsigned                    : 1;
1821     unsigned BRG16              : 1;
1822     unsigned TXCKP              : 1;
1823     unsigned RXDTP              : 1;
1824     unsigned RCIDL              : 1;
1825     unsigned ABDOVF             : 1;
1826     };
1827 
1828   struct
1829     {
1830     unsigned                    : 1;
1831     unsigned                    : 1;
1832     unsigned                    : 1;
1833     unsigned                    : 1;
1834     unsigned SCKP               : 1;
1835     unsigned                    : 1;
1836     unsigned RCMT               : 1;
1837     unsigned                    : 1;
1838     };
1839   } __BAUDCTLbits_t;
1840 
1841 extern __at(0x0FAA) volatile __BAUDCTLbits_t BAUDCTLbits;
1842 
1843 #define _BAUDCTL_ABDEN          0x01
1844 #define _BAUDCTL_WUE            0x02
1845 #define _BAUDCTL_BRG16          0x08
1846 #define _BAUDCTL_TXCKP          0x10
1847 #define _BAUDCTL_SCKP           0x10
1848 #define _BAUDCTL_RXDTP          0x20
1849 #define _BAUDCTL_RCIDL          0x40
1850 #define _BAUDCTL_RCMT           0x40
1851 #define _BAUDCTL_ABDOVF         0x80
1852 
1853 //==============================================================================
1854 
1855 
1856 //==============================================================================
1857 //        RCSTA Bits
1858 
1859 extern __at(0x0FAB) __sfr RCSTA;
1860 
1861 typedef union
1862   {
1863   struct
1864     {
1865     unsigned RX9D               : 1;
1866     unsigned OERR               : 1;
1867     unsigned FERR               : 1;
1868     unsigned ADDEN              : 1;
1869     unsigned CREN               : 1;
1870     unsigned SREN               : 1;
1871     unsigned RX9                : 1;
1872     unsigned SPEN               : 1;
1873     };
1874 
1875   struct
1876     {
1877     unsigned                    : 1;
1878     unsigned                    : 1;
1879     unsigned                    : 1;
1880     unsigned ADEN               : 1;
1881     unsigned                    : 1;
1882     unsigned                    : 1;
1883     unsigned                    : 1;
1884     unsigned                    : 1;
1885     };
1886   } __RCSTAbits_t;
1887 
1888 extern __at(0x0FAB) volatile __RCSTAbits_t RCSTAbits;
1889 
1890 #define _RX9D                   0x01
1891 #define _OERR                   0x02
1892 #define _FERR                   0x04
1893 #define _ADDEN                  0x08
1894 #define _ADEN                   0x08
1895 #define _CREN                   0x10
1896 #define _SREN                   0x20
1897 #define _RX9                    0x40
1898 #define _SPEN                   0x80
1899 
1900 //==============================================================================
1901 
1902 
1903 //==============================================================================
1904 //        TXSTA Bits
1905 
1906 extern __at(0x0FAC) __sfr TXSTA;
1907 
1908 typedef struct
1909   {
1910   unsigned TX9D                 : 1;
1911   unsigned TRMT                 : 1;
1912   unsigned BRGH                 : 1;
1913   unsigned SENDB                : 1;
1914   unsigned SYNC                 : 1;
1915   unsigned TXEN                 : 1;
1916   unsigned TX9                  : 1;
1917   unsigned CSRC                 : 1;
1918   } __TXSTAbits_t;
1919 
1920 extern __at(0x0FAC) volatile __TXSTAbits_t TXSTAbits;
1921 
1922 #define _TX9D                   0x01
1923 #define _TRMT                   0x02
1924 #define _BRGH                   0x04
1925 #define _SENDB                  0x08
1926 #define _SYNC                   0x10
1927 #define _TXEN                   0x20
1928 #define _TX9                    0x40
1929 #define _CSRC                   0x80
1930 
1931 //==============================================================================
1932 
1933 extern __at(0x0FAD) __sfr TXREG;
1934 extern __at(0x0FAE) __sfr RCREG;
1935 extern __at(0x0FAF) __sfr SPBRG;
1936 extern __at(0x0FB0) __sfr SPBRGH;
1937 
1938 //==============================================================================
1939 //        QEICON Bits
1940 
1941 extern __at(0x0FB6) __sfr QEICON;
1942 
1943 typedef union
1944   {
1945   struct
1946     {
1947     unsigned PDEC0              : 1;
1948     unsigned PDEC1              : 1;
1949     unsigned QEIM0              : 1;
1950     unsigned QEIM1              : 1;
1951     unsigned QEIM2              : 1;
1952     unsigned UP_NOT_DOWN        : 1;
1953     unsigned                    : 1;
1954     unsigned NOT_VELM           : 1;
1955     };
1956 
1957   struct
1958     {
1959     unsigned                    : 1;
1960     unsigned                    : 1;
1961     unsigned                    : 1;
1962     unsigned                    : 1;
1963     unsigned                    : 1;
1964     unsigned UP_DOWN            : 1;
1965     unsigned                    : 1;
1966     unsigned VELM               : 1;
1967     };
1968 
1969   struct
1970     {
1971     unsigned                    : 1;
1972     unsigned                    : 1;
1973     unsigned                    : 1;
1974     unsigned                    : 1;
1975     unsigned                    : 1;
1976     unsigned UP                 : 1;
1977     unsigned                    : 1;
1978     unsigned                    : 1;
1979     };
1980 
1981   struct
1982     {
1983     unsigned                    : 1;
1984     unsigned                    : 1;
1985     unsigned                    : 1;
1986     unsigned                    : 1;
1987     unsigned                    : 1;
1988     unsigned DOWN               : 1;
1989     unsigned                    : 1;
1990     unsigned                    : 1;
1991     };
1992 
1993   struct
1994     {
1995     unsigned                    : 1;
1996     unsigned                    : 1;
1997     unsigned                    : 1;
1998     unsigned                    : 1;
1999     unsigned                    : 1;
2000     unsigned NOT_DOWN           : 1;
2001     unsigned                    : 1;
2002     unsigned                    : 1;
2003     };
2004 
2005   struct
2006     {
2007     unsigned                    : 1;
2008     unsigned                    : 1;
2009     unsigned                    : 1;
2010     unsigned                    : 1;
2011     unsigned                    : 1;
2012     unsigned UPDOWN             : 1;
2013     unsigned                    : 1;
2014     unsigned                    : 1;
2015     };
2016 
2017   struct
2018     {
2019     unsigned PDEC               : 2;
2020     unsigned                    : 6;
2021     };
2022 
2023   struct
2024     {
2025     unsigned                    : 2;
2026     unsigned QEIM               : 3;
2027     unsigned                    : 3;
2028     };
2029   } __QEICONbits_t;
2030 
2031 extern __at(0x0FB6) volatile __QEICONbits_t QEICONbits;
2032 
2033 #define _PDEC0                  0x01
2034 #define _PDEC1                  0x02
2035 #define _QEIM0                  0x04
2036 #define _QEIM1                  0x08
2037 #define _QEIM2                  0x10
2038 #define _UP_NOT_DOWN            0x20
2039 #define _UP_DOWN                0x20
2040 #define _UP                     0x20
2041 #define _DOWN                   0x20
2042 #define _NOT_DOWN               0x20
2043 #define _UPDOWN                 0x20
2044 #define _NOT_VELM               0x80
2045 #define _VELM                   0x80
2046 
2047 //==============================================================================
2048 
2049 
2050 //==============================================================================
2051 //        T5CON Bits
2052 
2053 extern __at(0x0FB7) __sfr T5CON;
2054 
2055 typedef union
2056   {
2057   struct
2058     {
2059     unsigned TMR5ON             : 1;
2060     unsigned TMR5CS             : 1;
2061     unsigned NOT_T5SYNC         : 1;
2062     unsigned T5PS0              : 1;
2063     unsigned T5PS1              : 1;
2064     unsigned T5MOD              : 1;
2065     unsigned NOT_RESEN          : 1;
2066     unsigned T5SEN              : 1;
2067     };
2068 
2069   struct
2070     {
2071     unsigned                    : 1;
2072     unsigned                    : 1;
2073     unsigned T5SYNC             : 1;
2074     unsigned                    : 1;
2075     unsigned                    : 1;
2076     unsigned                    : 1;
2077     unsigned RESEN              : 1;
2078     unsigned                    : 1;
2079     };
2080 
2081   struct
2082     {
2083     unsigned                    : 3;
2084     unsigned T5PS               : 2;
2085     unsigned                    : 3;
2086     };
2087   } __T5CONbits_t;
2088 
2089 extern __at(0x0FB7) volatile __T5CONbits_t T5CONbits;
2090 
2091 #define _TMR5ON                 0x01
2092 #define _TMR5CS                 0x02
2093 #define _NOT_T5SYNC             0x04
2094 #define _T5SYNC                 0x04
2095 #define _T5PS0                  0x08
2096 #define _T5PS1                  0x10
2097 #define _T5MOD                  0x20
2098 #define _NOT_RESEN              0x40
2099 #define _RESEN                  0x40
2100 #define _T5SEN                  0x80
2101 
2102 //==============================================================================
2103 
2104 
2105 //==============================================================================
2106 //        ANSEL0 Bits
2107 
2108 extern __at(0x0FB8) __sfr ANSEL0;
2109 
2110 typedef union
2111   {
2112   struct
2113     {
2114     unsigned ANS0               : 1;
2115     unsigned ANS1               : 1;
2116     unsigned ANS2               : 1;
2117     unsigned ANS3               : 1;
2118     unsigned ANS4               : 1;
2119     unsigned                    : 1;
2120     unsigned                    : 1;
2121     unsigned                    : 1;
2122     };
2123 
2124   struct
2125     {
2126     unsigned ANS                : 5;
2127     unsigned                    : 3;
2128     };
2129   } __ANSEL0bits_t;
2130 
2131 extern __at(0x0FB8) volatile __ANSEL0bits_t ANSEL0bits;
2132 
2133 #define _ANS0                   0x01
2134 #define _ANS1                   0x02
2135 #define _ANS2                   0x04
2136 #define _ANS3                   0x08
2137 #define _ANS4                   0x10
2138 
2139 //==============================================================================
2140 
2141 
2142 //==============================================================================
2143 //        CCP2CON Bits
2144 
2145 extern __at(0x0FBA) __sfr CCP2CON;
2146 
2147 typedef union
2148   {
2149   struct
2150     {
2151     unsigned CCP2M0             : 1;
2152     unsigned CCP2M1             : 1;
2153     unsigned CCP2M2             : 1;
2154     unsigned CCP2M3             : 1;
2155     unsigned CCP2Y              : 1;
2156     unsigned CCP2X              : 1;
2157     unsigned                    : 1;
2158     unsigned                    : 1;
2159     };
2160 
2161   struct
2162     {
2163     unsigned                    : 1;
2164     unsigned                    : 1;
2165     unsigned                    : 1;
2166     unsigned                    : 1;
2167     unsigned DC2B0              : 1;
2168     unsigned DC2B1              : 1;
2169     unsigned                    : 1;
2170     unsigned                    : 1;
2171     };
2172 
2173   struct
2174     {
2175     unsigned CCP2M              : 4;
2176     unsigned                    : 4;
2177     };
2178 
2179   struct
2180     {
2181     unsigned                    : 4;
2182     unsigned DC2B               : 2;
2183     unsigned                    : 2;
2184     };
2185   } __CCP2CONbits_t;
2186 
2187 extern __at(0x0FBA) volatile __CCP2CONbits_t CCP2CONbits;
2188 
2189 #define _CCP2M0                 0x01
2190 #define _CCP2M1                 0x02
2191 #define _CCP2M2                 0x04
2192 #define _CCP2M3                 0x08
2193 #define _CCP2Y                  0x10
2194 #define _DC2B0                  0x10
2195 #define _CCP2X                  0x20
2196 #define _DC2B1                  0x20
2197 
2198 //==============================================================================
2199 
2200 extern __at(0x0FBB) __sfr CCPR2;
2201 extern __at(0x0FBB) __sfr CCPR2L;
2202 extern __at(0x0FBC) __sfr CCPR2H;
2203 
2204 //==============================================================================
2205 //        CCP1CON Bits
2206 
2207 extern __at(0x0FBD) __sfr CCP1CON;
2208 
2209 typedef union
2210   {
2211   struct
2212     {
2213     unsigned CCP1M0             : 1;
2214     unsigned CCP1M1             : 1;
2215     unsigned CCP1M2             : 1;
2216     unsigned CCP1M3             : 1;
2217     unsigned CCP1Y              : 1;
2218     unsigned CCP1X              : 1;
2219     unsigned                    : 1;
2220     unsigned                    : 1;
2221     };
2222 
2223   struct
2224     {
2225     unsigned                    : 1;
2226     unsigned                    : 1;
2227     unsigned                    : 1;
2228     unsigned                    : 1;
2229     unsigned DC1B0              : 1;
2230     unsigned DC1B1              : 1;
2231     unsigned                    : 1;
2232     unsigned                    : 1;
2233     };
2234 
2235   struct
2236     {
2237     unsigned CCP1M              : 4;
2238     unsigned                    : 4;
2239     };
2240 
2241   struct
2242     {
2243     unsigned                    : 4;
2244     unsigned DC1B               : 2;
2245     unsigned                    : 2;
2246     };
2247   } __CCP1CONbits_t;
2248 
2249 extern __at(0x0FBD) volatile __CCP1CONbits_t CCP1CONbits;
2250 
2251 #define _CCP1M0                 0x01
2252 #define _CCP1M1                 0x02
2253 #define _CCP1M2                 0x04
2254 #define _CCP1M3                 0x08
2255 #define _CCP1Y                  0x10
2256 #define _DC1B0                  0x10
2257 #define _CCP1X                  0x20
2258 #define _DC1B1                  0x20
2259 
2260 //==============================================================================
2261 
2262 extern __at(0x0FBE) __sfr CCPR1;
2263 extern __at(0x0FBE) __sfr CCPR1L;
2264 extern __at(0x0FBF) __sfr CCPR1H;
2265 
2266 //==============================================================================
2267 //        ADCON2 Bits
2268 
2269 extern __at(0x0FC0) __sfr ADCON2;
2270 
2271 typedef union
2272   {
2273   struct
2274     {
2275     unsigned ADCS0              : 1;
2276     unsigned ADCS1              : 1;
2277     unsigned ADCS2              : 1;
2278     unsigned ACQT0              : 1;
2279     unsigned ACQT1              : 1;
2280     unsigned ACQT2              : 1;
2281     unsigned ACQT3              : 1;
2282     unsigned ADFM               : 1;
2283     };
2284 
2285   struct
2286     {
2287     unsigned ADCS               : 3;
2288     unsigned                    : 5;
2289     };
2290 
2291   struct
2292     {
2293     unsigned                    : 3;
2294     unsigned ACQT               : 4;
2295     unsigned                    : 1;
2296     };
2297   } __ADCON2bits_t;
2298 
2299 extern __at(0x0FC0) volatile __ADCON2bits_t ADCON2bits;
2300 
2301 #define _ADCS0                  0x01
2302 #define _ADCS1                  0x02
2303 #define _ADCS2                  0x04
2304 #define _ACQT0                  0x08
2305 #define _ACQT1                  0x10
2306 #define _ACQT2                  0x20
2307 #define _ACQT3                  0x40
2308 #define _ADFM                   0x80
2309 
2310 //==============================================================================
2311 
2312 
2313 //==============================================================================
2314 //        ADCON1 Bits
2315 
2316 extern __at(0x0FC1) __sfr ADCON1;
2317 
2318 typedef union
2319   {
2320   struct
2321     {
2322     unsigned ADPNT0             : 1;
2323     unsigned ADPNT1             : 1;
2324     unsigned BFOVFL             : 1;
2325     unsigned BFEMT              : 1;
2326     unsigned FIFOEN             : 1;
2327     unsigned                    : 1;
2328     unsigned VCFG0              : 1;
2329     unsigned VCFG1              : 1;
2330     };
2331 
2332   struct
2333     {
2334     unsigned                    : 1;
2335     unsigned                    : 1;
2336     unsigned FFOVFL             : 1;
2337     unsigned                    : 1;
2338     unsigned                    : 1;
2339     unsigned                    : 1;
2340     unsigned                    : 1;
2341     unsigned                    : 1;
2342     };
2343 
2344   struct
2345     {
2346     unsigned ADPNT              : 2;
2347     unsigned                    : 6;
2348     };
2349 
2350   struct
2351     {
2352     unsigned                    : 6;
2353     unsigned VCFG               : 2;
2354     };
2355   } __ADCON1bits_t;
2356 
2357 extern __at(0x0FC1) volatile __ADCON1bits_t ADCON1bits;
2358 
2359 #define _ADPNT0                 0x01
2360 #define _ADPNT1                 0x02
2361 #define _BFOVFL                 0x04
2362 #define _FFOVFL                 0x04
2363 #define _BFEMT                  0x08
2364 #define _FIFOEN                 0x10
2365 #define _VCFG0                  0x40
2366 #define _VCFG1                  0x80
2367 
2368 //==============================================================================
2369 
2370 
2371 //==============================================================================
2372 //        ADCON0 Bits
2373 
2374 extern __at(0x0FC2) __sfr ADCON0;
2375 
2376 typedef union
2377   {
2378   struct
2379     {
2380     unsigned ADON               : 1;
2381     unsigned GO_NOT_DONE        : 1;
2382     unsigned ACMOD0             : 1;
2383     unsigned ACMOD1             : 1;
2384     unsigned ACSCH              : 1;
2385     unsigned ACONV              : 1;
2386     unsigned                    : 1;
2387     unsigned                    : 1;
2388     };
2389 
2390   struct
2391     {
2392     unsigned                    : 1;
2393     unsigned GO_DONE            : 1;
2394     unsigned                    : 1;
2395     unsigned                    : 1;
2396     unsigned                    : 1;
2397     unsigned                    : 1;
2398     unsigned                    : 1;
2399     unsigned                    : 1;
2400     };
2401 
2402   struct
2403     {
2404     unsigned                    : 1;
2405     unsigned DONE               : 1;
2406     unsigned                    : 1;
2407     unsigned                    : 1;
2408     unsigned                    : 1;
2409     unsigned                    : 1;
2410     unsigned                    : 1;
2411     unsigned                    : 1;
2412     };
2413 
2414   struct
2415     {
2416     unsigned                    : 1;
2417     unsigned GO                 : 1;
2418     unsigned                    : 1;
2419     unsigned                    : 1;
2420     unsigned                    : 1;
2421     unsigned                    : 1;
2422     unsigned                    : 1;
2423     unsigned                    : 1;
2424     };
2425 
2426   struct
2427     {
2428     unsigned                    : 1;
2429     unsigned NOT_DONE           : 1;
2430     unsigned                    : 1;
2431     unsigned                    : 1;
2432     unsigned                    : 1;
2433     unsigned                    : 1;
2434     unsigned                    : 1;
2435     unsigned                    : 1;
2436     };
2437 
2438   struct
2439     {
2440     unsigned                    : 1;
2441     unsigned GODONE             : 1;
2442     unsigned                    : 1;
2443     unsigned                    : 1;
2444     unsigned                    : 1;
2445     unsigned                    : 1;
2446     unsigned                    : 1;
2447     unsigned                    : 1;
2448     };
2449 
2450   struct
2451     {
2452     unsigned                    : 2;
2453     unsigned ACMOD              : 2;
2454     unsigned                    : 4;
2455     };
2456   } __ADCON0bits_t;
2457 
2458 extern __at(0x0FC2) volatile __ADCON0bits_t ADCON0bits;
2459 
2460 #define _ADON                   0x01
2461 #define _GO_NOT_DONE            0x02
2462 #define _GO_DONE                0x02
2463 #define _DONE                   0x02
2464 #define _GO                     0x02
2465 #define _NOT_DONE               0x02
2466 #define _GODONE                 0x02
2467 #define _ACMOD0                 0x04
2468 #define _ACMOD1                 0x08
2469 #define _ACSCH                  0x10
2470 #define _ACONV                  0x20
2471 
2472 //==============================================================================
2473 
2474 extern __at(0x0FC3) __sfr ADRES;
2475 extern __at(0x0FC3) __sfr ADRESL;
2476 extern __at(0x0FC4) __sfr ADRESH;
2477 
2478 //==============================================================================
2479 //        SSPCON Bits
2480 
2481 extern __at(0x0FC6) __sfr SSPCON;
2482 
2483 typedef union
2484   {
2485   struct
2486     {
2487     unsigned SSPM0              : 1;
2488     unsigned SSPM1              : 1;
2489     unsigned SSPM2              : 1;
2490     unsigned SSPM3              : 1;
2491     unsigned CKP                : 1;
2492     unsigned SSPEN              : 1;
2493     unsigned SSPOV              : 1;
2494     unsigned WCOL               : 1;
2495     };
2496 
2497   struct
2498     {
2499     unsigned SSPM               : 4;
2500     unsigned                    : 4;
2501     };
2502   } __SSPCONbits_t;
2503 
2504 extern __at(0x0FC6) volatile __SSPCONbits_t SSPCONbits;
2505 
2506 #define _SSPM0                  0x01
2507 #define _SSPM1                  0x02
2508 #define _SSPM2                  0x04
2509 #define _SSPM3                  0x08
2510 #define _CKP                    0x10
2511 #define _SSPEN                  0x20
2512 #define _SSPOV                  0x40
2513 #define _WCOL                   0x80
2514 
2515 //==============================================================================
2516 
2517 
2518 //==============================================================================
2519 //        SSPSTAT Bits
2520 
2521 extern __at(0x0FC7) __sfr SSPSTAT;
2522 
2523 typedef union
2524   {
2525   struct
2526     {
2527     unsigned BF                 : 1;
2528     unsigned UA                 : 1;
2529     unsigned R_NOT_W            : 1;
2530     unsigned S                  : 1;
2531     unsigned P                  : 1;
2532     unsigned D_NOT_A            : 1;
2533     unsigned CKE                : 1;
2534     unsigned SMP                : 1;
2535     };
2536 
2537   struct
2538     {
2539     unsigned                    : 1;
2540     unsigned                    : 1;
2541     unsigned R_W                : 1;
2542     unsigned                    : 1;
2543     unsigned                    : 1;
2544     unsigned D_A                : 1;
2545     unsigned                    : 1;
2546     unsigned                    : 1;
2547     };
2548 
2549   struct
2550     {
2551     unsigned                    : 1;
2552     unsigned                    : 1;
2553     unsigned NOT_W              : 1;
2554     unsigned                    : 1;
2555     unsigned                    : 1;
2556     unsigned NOT_A              : 1;
2557     unsigned                    : 1;
2558     unsigned                    : 1;
2559     };
2560 
2561   struct
2562     {
2563     unsigned                    : 1;
2564     unsigned                    : 1;
2565     unsigned NOT_WRITE          : 1;
2566     unsigned                    : 1;
2567     unsigned                    : 1;
2568     unsigned NOT_ADDRESS        : 1;
2569     unsigned                    : 1;
2570     unsigned                    : 1;
2571     };
2572 
2573   struct
2574     {
2575     unsigned                    : 1;
2576     unsigned                    : 1;
2577     unsigned READ_WRITE         : 1;
2578     unsigned                    : 1;
2579     unsigned                    : 1;
2580     unsigned DATA_ADDRESS       : 1;
2581     unsigned                    : 1;
2582     unsigned                    : 1;
2583     };
2584 
2585   struct
2586     {
2587     unsigned                    : 1;
2588     unsigned                    : 1;
2589     unsigned R                  : 1;
2590     unsigned                    : 1;
2591     unsigned                    : 1;
2592     unsigned D                  : 1;
2593     unsigned                    : 1;
2594     unsigned                    : 1;
2595     };
2596   } __SSPSTATbits_t;
2597 
2598 extern __at(0x0FC7) volatile __SSPSTATbits_t SSPSTATbits;
2599 
2600 #define _BF                     0x01
2601 #define _UA                     0x02
2602 #define _R_NOT_W                0x04
2603 #define _R_W                    0x04
2604 #define _NOT_W                  0x04
2605 #define _NOT_WRITE              0x04
2606 #define _READ_WRITE             0x04
2607 #define _R                      0x04
2608 #define _S                      0x08
2609 #define _P                      0x10
2610 #define _D_NOT_A                0x20
2611 #define _D_A                    0x20
2612 #define _NOT_A                  0x20
2613 #define _NOT_ADDRESS            0x20
2614 #define _DATA_ADDRESS           0x20
2615 #define _D                      0x20
2616 #define _CKE                    0x40
2617 #define _SMP                    0x80
2618 
2619 //==============================================================================
2620 
2621 extern __at(0x0FC8) __sfr SSPADD;
2622 extern __at(0x0FC9) __sfr SSPBUF;
2623 
2624 //==============================================================================
2625 //        T2CON Bits
2626 
2627 extern __at(0x0FCA) __sfr T2CON;
2628 
2629 typedef union
2630   {
2631   struct
2632     {
2633     unsigned T2CKPS0            : 1;
2634     unsigned T2CKPS1            : 1;
2635     unsigned TMR2ON             : 1;
2636     unsigned T2OUTPS0           : 1;
2637     unsigned T2OUTPS1           : 1;
2638     unsigned T2OUTPS2           : 1;
2639     unsigned T2OUTPS3           : 1;
2640     unsigned                    : 1;
2641     };
2642 
2643   struct
2644     {
2645     unsigned                    : 1;
2646     unsigned                    : 1;
2647     unsigned                    : 1;
2648     unsigned TOUTPS0            : 1;
2649     unsigned TOUTPS1            : 1;
2650     unsigned TOUTPS2            : 1;
2651     unsigned TOUTPS3            : 1;
2652     unsigned                    : 1;
2653     };
2654 
2655   struct
2656     {
2657     unsigned T2CKPS             : 2;
2658     unsigned                    : 6;
2659     };
2660 
2661   struct
2662     {
2663     unsigned                    : 3;
2664     unsigned TOUTPS             : 4;
2665     unsigned                    : 1;
2666     };
2667 
2668   struct
2669     {
2670     unsigned                    : 3;
2671     unsigned T2OUTPS            : 4;
2672     unsigned                    : 1;
2673     };
2674   } __T2CONbits_t;
2675 
2676 extern __at(0x0FCA) volatile __T2CONbits_t T2CONbits;
2677 
2678 #define _T2CKPS0                0x01
2679 #define _T2CKPS1                0x02
2680 #define _TMR2ON                 0x04
2681 #define _T2OUTPS0               0x08
2682 #define _TOUTPS0                0x08
2683 #define _T2OUTPS1               0x10
2684 #define _TOUTPS1                0x10
2685 #define _T2OUTPS2               0x20
2686 #define _TOUTPS2                0x20
2687 #define _T2OUTPS3               0x40
2688 #define _TOUTPS3                0x40
2689 
2690 //==============================================================================
2691 
2692 extern __at(0x0FCB) __sfr PR2;
2693 extern __at(0x0FCC) __sfr TMR2;
2694 
2695 //==============================================================================
2696 //        T1CON Bits
2697 
2698 extern __at(0x0FCD) __sfr T1CON;
2699 
2700 typedef union
2701   {
2702   struct
2703     {
2704     unsigned TMR1ON             : 1;
2705     unsigned TMR1CS             : 1;
2706     unsigned NOT_T1SYNC         : 1;
2707     unsigned T1OSCEN            : 1;
2708     unsigned T1CKPS0            : 1;
2709     unsigned T1CKPS1            : 1;
2710     unsigned T1RUN              : 1;
2711     unsigned RD16               : 1;
2712     };
2713 
2714   struct
2715     {
2716     unsigned                    : 1;
2717     unsigned                    : 1;
2718     unsigned T1SYNC             : 1;
2719     unsigned                    : 1;
2720     unsigned                    : 1;
2721     unsigned                    : 1;
2722     unsigned                    : 1;
2723     unsigned                    : 1;
2724     };
2725 
2726   struct
2727     {
2728     unsigned                    : 1;
2729     unsigned                    : 1;
2730     unsigned T1INSYNC           : 1;
2731     unsigned                    : 1;
2732     unsigned                    : 1;
2733     unsigned                    : 1;
2734     unsigned                    : 1;
2735     unsigned                    : 1;
2736     };
2737 
2738   struct
2739     {
2740     unsigned                    : 4;
2741     unsigned T1CKPS             : 2;
2742     unsigned                    : 2;
2743     };
2744   } __T1CONbits_t;
2745 
2746 extern __at(0x0FCD) volatile __T1CONbits_t T1CONbits;
2747 
2748 #define _TMR1ON                 0x01
2749 #define _TMR1CS                 0x02
2750 #define _NOT_T1SYNC             0x04
2751 #define _T1SYNC                 0x04
2752 #define _T1INSYNC               0x04
2753 #define _T1OSCEN                0x08
2754 #define _T1CKPS0                0x10
2755 #define _T1CKPS1                0x20
2756 #define _T1RUN                  0x40
2757 #define _RD16                   0x80
2758 
2759 //==============================================================================
2760 
2761 extern __at(0x0FCE) __sfr TMR1;
2762 extern __at(0x0FCE) __sfr TMR1L;
2763 extern __at(0x0FCF) __sfr TMR1H;
2764 
2765 //==============================================================================
2766 //        RCON Bits
2767 
2768 extern __at(0x0FD0) __sfr RCON;
2769 
2770 typedef union
2771   {
2772   struct
2773     {
2774     unsigned NOT_BOR            : 1;
2775     unsigned NOT_POR            : 1;
2776     unsigned NOT_PD             : 1;
2777     unsigned NOT_TO             : 1;
2778     unsigned NOT_RI             : 1;
2779     unsigned                    : 1;
2780     unsigned                    : 1;
2781     unsigned IPEN               : 1;
2782     };
2783 
2784   struct
2785     {
2786     unsigned BOR                : 1;
2787     unsigned POR                : 1;
2788     unsigned PD                 : 1;
2789     unsigned TO                 : 1;
2790     unsigned RI                 : 1;
2791     unsigned                    : 1;
2792     unsigned                    : 1;
2793     unsigned NOT_IPEN           : 1;
2794     };
2795   } __RCONbits_t;
2796 
2797 extern __at(0x0FD0) volatile __RCONbits_t RCONbits;
2798 
2799 #define _NOT_BOR                0x01
2800 #define _BOR                    0x01
2801 #define _NOT_POR                0x02
2802 #define _POR                    0x02
2803 #define _NOT_PD                 0x04
2804 #define _PD                     0x04
2805 #define _NOT_TO                 0x08
2806 #define _TO                     0x08
2807 #define _NOT_RI                 0x10
2808 #define _RI                     0x10
2809 #define _IPEN                   0x80
2810 #define _NOT_IPEN               0x80
2811 
2812 //==============================================================================
2813 
2814 
2815 //==============================================================================
2816 //        WDTCON Bits
2817 
2818 extern __at(0x0FD1) __sfr WDTCON;
2819 
2820 typedef struct
2821   {
2822   unsigned SWDTEN               : 1;
2823   unsigned                      : 1;
2824   unsigned                      : 1;
2825   unsigned                      : 1;
2826   unsigned                      : 1;
2827   unsigned                      : 1;
2828   unsigned                      : 1;
2829   unsigned WDTW                 : 1;
2830   } __WDTCONbits_t;
2831 
2832 extern __at(0x0FD1) volatile __WDTCONbits_t WDTCONbits;
2833 
2834 #define _SWDTEN                 0x01
2835 #define _WDTW                   0x80
2836 
2837 //==============================================================================
2838 
2839 
2840 //==============================================================================
2841 //        LVDCON Bits
2842 
2843 extern __at(0x0FD2) __sfr LVDCON;
2844 
2845 typedef union
2846   {
2847   struct
2848     {
2849     unsigned LVDL0              : 1;
2850     unsigned LVDL1              : 1;
2851     unsigned LVDL2              : 1;
2852     unsigned LVDL3              : 1;
2853     unsigned LVDEN              : 1;
2854     unsigned IRVST              : 1;
2855     unsigned                    : 1;
2856     unsigned                    : 1;
2857     };
2858 
2859   struct
2860     {
2861     unsigned                    : 1;
2862     unsigned                    : 1;
2863     unsigned                    : 1;
2864     unsigned                    : 1;
2865     unsigned                    : 1;
2866     unsigned IVRST              : 1;
2867     unsigned                    : 1;
2868     unsigned                    : 1;
2869     };
2870 
2871   struct
2872     {
2873     unsigned LVDL               : 4;
2874     unsigned                    : 4;
2875     };
2876   } __LVDCONbits_t;
2877 
2878 extern __at(0x0FD2) volatile __LVDCONbits_t LVDCONbits;
2879 
2880 #define _LVDL0                  0x01
2881 #define _LVDL1                  0x02
2882 #define _LVDL2                  0x04
2883 #define _LVDL3                  0x08
2884 #define _LVDEN                  0x10
2885 #define _IRVST                  0x20
2886 #define _IVRST                  0x20
2887 
2888 //==============================================================================
2889 
2890 
2891 //==============================================================================
2892 //        OSCCON Bits
2893 
2894 extern __at(0x0FD3) __sfr OSCCON;
2895 
2896 typedef union
2897   {
2898   struct
2899     {
2900     unsigned SCS0               : 1;
2901     unsigned SCS1               : 1;
2902     unsigned IOFS               : 1;
2903     unsigned OSTS               : 1;
2904     unsigned IRCF0              : 1;
2905     unsigned IRCF1              : 1;
2906     unsigned IRCF2              : 1;
2907     unsigned IDLEN              : 1;
2908     };
2909 
2910   struct
2911     {
2912     unsigned                    : 1;
2913     unsigned                    : 1;
2914     unsigned FLTS               : 1;
2915     unsigned                    : 1;
2916     unsigned                    : 1;
2917     unsigned                    : 1;
2918     unsigned                    : 1;
2919     unsigned                    : 1;
2920     };
2921 
2922   struct
2923     {
2924     unsigned SCS                : 2;
2925     unsigned                    : 6;
2926     };
2927 
2928   struct
2929     {
2930     unsigned                    : 4;
2931     unsigned IRCF               : 3;
2932     unsigned                    : 1;
2933     };
2934   } __OSCCONbits_t;
2935 
2936 extern __at(0x0FD3) volatile __OSCCONbits_t OSCCONbits;
2937 
2938 #define _SCS0                   0x01
2939 #define _SCS1                   0x02
2940 #define _IOFS                   0x04
2941 #define _FLTS                   0x04
2942 #define _OSTS                   0x08
2943 #define _IRCF0                  0x10
2944 #define _IRCF1                  0x20
2945 #define _IRCF2                  0x40
2946 #define _IDLEN                  0x80
2947 
2948 //==============================================================================
2949 
2950 
2951 //==============================================================================
2952 //        T0CON Bits
2953 
2954 extern __at(0x0FD5) __sfr T0CON;
2955 
2956 typedef union
2957   {
2958   struct
2959     {
2960     unsigned T0PS0              : 1;
2961     unsigned T0PS1              : 1;
2962     unsigned T0PS2              : 1;
2963     unsigned PSA                : 1;
2964     unsigned T0SE               : 1;
2965     unsigned T0CS               : 1;
2966     unsigned T016BIT            : 1;
2967     unsigned TMR0ON             : 1;
2968     };
2969 
2970   struct
2971     {
2972     unsigned                    : 1;
2973     unsigned                    : 1;
2974     unsigned                    : 1;
2975     unsigned T0PS3              : 1;
2976     unsigned                    : 1;
2977     unsigned                    : 1;
2978     unsigned                    : 1;
2979     unsigned                    : 1;
2980     };
2981 
2982   struct
2983     {
2984     unsigned T0PS               : 4;
2985     unsigned                    : 4;
2986     };
2987   } __T0CONbits_t;
2988 
2989 extern __at(0x0FD5) volatile __T0CONbits_t T0CONbits;
2990 
2991 #define _T0PS0                  0x01
2992 #define _T0PS1                  0x02
2993 #define _T0PS2                  0x04
2994 #define _PSA                    0x08
2995 #define _T0PS3                  0x08
2996 #define _T0SE                   0x10
2997 #define _T0CS                   0x20
2998 #define _T016BIT                0x40
2999 #define _TMR0ON                 0x80
3000 
3001 //==============================================================================
3002 
3003 extern __at(0x0FD6) __sfr TMR0;
3004 extern __at(0x0FD6) __sfr TMR0L;
3005 extern __at(0x0FD7) __sfr TMR0H;
3006 
3007 //==============================================================================
3008 //        STATUS Bits
3009 
3010 extern __at(0x0FD8) __sfr STATUS;
3011 
3012 typedef struct
3013   {
3014   unsigned C                    : 1;
3015   unsigned DC                   : 1;
3016   unsigned Z                    : 1;
3017   unsigned OV                   : 1;
3018   unsigned N                    : 1;
3019   unsigned                      : 1;
3020   unsigned                      : 1;
3021   unsigned                      : 1;
3022   } __STATUSbits_t;
3023 
3024 extern __at(0x0FD8) volatile __STATUSbits_t STATUSbits;
3025 
3026 #define _C                      0x01
3027 #define _DC                     0x02
3028 #define _Z                      0x04
3029 #define _OV                     0x08
3030 #define _N                      0x10
3031 
3032 //==============================================================================
3033 
3034 extern __at(0x0FD9) __sfr FSR2L;
3035 extern __at(0x0FDA) __sfr FSR2H;
3036 extern __at(0x0FDB) __sfr PLUSW2;
3037 extern __at(0x0FDC) __sfr PREINC2;
3038 extern __at(0x0FDD) __sfr POSTDEC2;
3039 extern __at(0x0FDE) __sfr POSTINC2;
3040 extern __at(0x0FDF) __sfr INDF2;
3041 extern __at(0x0FE0) __sfr BSR;
3042 extern __at(0x0FE1) __sfr FSR1L;
3043 extern __at(0x0FE2) __sfr FSR1H;
3044 extern __at(0x0FE3) __sfr PLUSW1;
3045 extern __at(0x0FE4) __sfr PREINC1;
3046 extern __at(0x0FE5) __sfr POSTDEC1;
3047 extern __at(0x0FE6) __sfr POSTINC1;
3048 extern __at(0x0FE7) __sfr INDF1;
3049 extern __at(0x0FE8) __sfr WREG;
3050 extern __at(0x0FE9) __sfr FSR0L;
3051 extern __at(0x0FEA) __sfr FSR0H;
3052 extern __at(0x0FEB) __sfr PLUSW0;
3053 extern __at(0x0FEC) __sfr PREINC0;
3054 extern __at(0x0FED) __sfr POSTDEC0;
3055 extern __at(0x0FEE) __sfr POSTINC0;
3056 extern __at(0x0FEF) __sfr INDF0;
3057 
3058 //==============================================================================
3059 //        INTCON3 Bits
3060 
3061 extern __at(0x0FF0) __sfr INTCON3;
3062 
3063 typedef union
3064   {
3065   struct
3066     {
3067     unsigned INT1IF             : 1;
3068     unsigned INT2IF             : 1;
3069     unsigned                    : 1;
3070     unsigned INT1IE             : 1;
3071     unsigned INT2IE             : 1;
3072     unsigned                    : 1;
3073     unsigned INT1IP             : 1;
3074     unsigned INT2IP             : 1;
3075     };
3076 
3077   struct
3078     {
3079     unsigned INT1F              : 1;
3080     unsigned INT2F              : 1;
3081     unsigned                    : 1;
3082     unsigned INT1E              : 1;
3083     unsigned INT2E              : 1;
3084     unsigned                    : 1;
3085     unsigned INT1P              : 1;
3086     unsigned INT2P              : 1;
3087     };
3088   } __INTCON3bits_t;
3089 
3090 extern __at(0x0FF0) volatile __INTCON3bits_t INTCON3bits;
3091 
3092 #define _INT1IF                 0x01
3093 #define _INT1F                  0x01
3094 #define _INT2IF                 0x02
3095 #define _INT2F                  0x02
3096 #define _INT1IE                 0x08
3097 #define _INT1E                  0x08
3098 #define _INT2IE                 0x10
3099 #define _INT2E                  0x10
3100 #define _INT1IP                 0x40
3101 #define _INT1P                  0x40
3102 #define _INT2IP                 0x80
3103 #define _INT2P                  0x80
3104 
3105 //==============================================================================
3106 
3107 
3108 //==============================================================================
3109 //        INTCON2 Bits
3110 
3111 extern __at(0x0FF1) __sfr INTCON2;
3112 
3113 typedef union
3114   {
3115   struct
3116     {
3117     unsigned RBIP               : 1;
3118     unsigned                    : 1;
3119     unsigned TMR0IP             : 1;
3120     unsigned                    : 1;
3121     unsigned INTEDG2            : 1;
3122     unsigned INTEDG1            : 1;
3123     unsigned INTEDG0            : 1;
3124     unsigned NOT_RBPU           : 1;
3125     };
3126 
3127   struct
3128     {
3129     unsigned                    : 1;
3130     unsigned                    : 1;
3131     unsigned T0IP               : 1;
3132     unsigned                    : 1;
3133     unsigned                    : 1;
3134     unsigned                    : 1;
3135     unsigned                    : 1;
3136     unsigned RBPU               : 1;
3137     };
3138   } __INTCON2bits_t;
3139 
3140 extern __at(0x0FF1) volatile __INTCON2bits_t INTCON2bits;
3141 
3142 #define _RBIP                   0x01
3143 #define _TMR0IP                 0x04
3144 #define _T0IP                   0x04
3145 #define _INTEDG2                0x10
3146 #define _INTEDG1                0x20
3147 #define _INTEDG0                0x40
3148 #define _NOT_RBPU               0x80
3149 #define _RBPU                   0x80
3150 
3151 //==============================================================================
3152 
3153 
3154 //==============================================================================
3155 //        INTCON Bits
3156 
3157 extern __at(0x0FF2) __sfr INTCON;
3158 
3159 typedef union
3160   {
3161   struct
3162     {
3163     unsigned RBIF               : 1;
3164     unsigned INT0IF             : 1;
3165     unsigned TMR0IF             : 1;
3166     unsigned RBIE               : 1;
3167     unsigned INT0IE             : 1;
3168     unsigned TMR0IE             : 1;
3169     unsigned PEIE_GIEL          : 1;
3170     unsigned GIE_GIEH           : 1;
3171     };
3172 
3173   struct
3174     {
3175     unsigned                    : 1;
3176     unsigned INT0F              : 1;
3177     unsigned T0IF               : 1;
3178     unsigned                    : 1;
3179     unsigned INT0E              : 1;
3180     unsigned T0IE               : 1;
3181     unsigned PEIE               : 1;
3182     unsigned GIE                : 1;
3183     };
3184 
3185   struct
3186     {
3187     unsigned                    : 1;
3188     unsigned                    : 1;
3189     unsigned                    : 1;
3190     unsigned                    : 1;
3191     unsigned                    : 1;
3192     unsigned                    : 1;
3193     unsigned GIEL               : 1;
3194     unsigned GIEH               : 1;
3195     };
3196   } __INTCONbits_t;
3197 
3198 extern __at(0x0FF2) volatile __INTCONbits_t INTCONbits;
3199 
3200 #define _RBIF                   0x01
3201 #define _INT0IF                 0x02
3202 #define _INT0F                  0x02
3203 #define _TMR0IF                 0x04
3204 #define _T0IF                   0x04
3205 #define _RBIE                   0x08
3206 #define _INT0IE                 0x10
3207 #define _INT0E                  0x10
3208 #define _TMR0IE                 0x20
3209 #define _T0IE                   0x20
3210 #define _PEIE_GIEL              0x40
3211 #define _PEIE                   0x40
3212 #define _GIEL                   0x40
3213 #define _GIE_GIEH               0x80
3214 #define _GIE                    0x80
3215 #define _GIEH                   0x80
3216 
3217 //==============================================================================
3218 
3219 extern __at(0x0FF3) __sfr PROD;
3220 extern __at(0x0FF3) __sfr PRODL;
3221 extern __at(0x0FF4) __sfr PRODH;
3222 extern __at(0x0FF5) __sfr TABLAT;
3223 extern __at(0x0FF6) __sfr TBLPTR;
3224 extern __at(0x0FF6) __sfr TBLPTRL;
3225 extern __at(0x0FF7) __sfr TBLPTRH;
3226 extern __at(0x0FF8) __sfr TBLPTRU;
3227 extern __at(0x0FF9) __sfr PC;
3228 extern __at(0x0FF9) __sfr PCL;
3229 extern __at(0x0FFA) __sfr PCLATH;
3230 extern __at(0x0FFB) __sfr PCLATU;
3231 
3232 //==============================================================================
3233 //        STKPTR Bits
3234 
3235 extern __at(0x0FFC) __sfr STKPTR;
3236 
3237 typedef union
3238   {
3239   struct
3240     {
3241     unsigned STKPTR0            : 1;
3242     unsigned STKPTR1            : 1;
3243     unsigned STKPTR2            : 1;
3244     unsigned STKPTR3            : 1;
3245     unsigned STKPTR4            : 1;
3246     unsigned                    : 1;
3247     unsigned STKUNF             : 1;
3248     unsigned STKFUL             : 1;
3249     };
3250 
3251   struct
3252     {
3253     unsigned                    : 1;
3254     unsigned                    : 1;
3255     unsigned                    : 1;
3256     unsigned                    : 1;
3257     unsigned                    : 1;
3258     unsigned                    : 1;
3259     unsigned                    : 1;
3260     unsigned STKOVF             : 1;
3261     };
3262 
3263   struct
3264     {
3265     unsigned STKPTR             : 5;
3266     unsigned                    : 3;
3267     };
3268   } __STKPTRbits_t;
3269 
3270 extern __at(0x0FFC) volatile __STKPTRbits_t STKPTRbits;
3271 
3272 #define _STKPTR0                0x01
3273 #define _STKPTR1                0x02
3274 #define _STKPTR2                0x04
3275 #define _STKPTR3                0x08
3276 #define _STKPTR4                0x10
3277 #define _STKUNF                 0x40
3278 #define _STKFUL                 0x80
3279 #define _STKOVF                 0x80
3280 
3281 //==============================================================================
3282 
3283 extern __at(0x0FFD) __sfr TOS;
3284 extern __at(0x0FFD) __sfr TOSL;
3285 extern __at(0x0FFE) __sfr TOSH;
3286 extern __at(0x0FFF) __sfr TOSU;
3287 
3288 //==============================================================================
3289 //
3290 //        Configuration Bits
3291 //
3292 //==============================================================================
3293 
3294 #define __CONFIG1H              0x300001
3295 #define __CONFIG2L              0x300002
3296 #define __CONFIG2H              0x300003
3297 #define __CONFIG3L              0x300004
3298 #define __CONFIG3H              0x300005
3299 #define __CONFIG4L              0x300006
3300 #define __CONFIG5L              0x300008
3301 #define __CONFIG5H              0x300009
3302 #define __CONFIG6L              0x30000A
3303 #define __CONFIG6H              0x30000B
3304 #define __CONFIG7L              0x30000C
3305 #define __CONFIG7H              0x30000D
3306 
3307 //----------------------------- CONFIG1H Options -------------------------------
3308 
3309 #define _OSC_LP_1H              0xF0    // LP oscillator.
3310 #define _OSC_XT_1H              0xF1    // XT oscillator.
3311 #define _OSC_HS_1H              0xF2    // HS oscillator.
3312 #define _OSC_RC2_1H             0xF3    // External RC oscillator, CLKO function on RA6.
3313 #define _OSC_EC_1H              0xF4    // EC oscillator, CLKO function on RA6.
3314 #define _OSC_ECIO_1H            0xF5    // EC oscillator, port function on RA6.
3315 #define _OSC_HSPLL_1H           0xF6    // HS oscillator, PLL enabled (clock frequency = 4 x FOSC1).
3316 #define _OSC_RCIO_1H            0xF7    // External RC oscillator, port function on RA6.
3317 #define _OSC_IRCIO_1H           0xF8    // Internal oscillator block, port function on RA6 and port function on RA7.
3318 #define _OSC_IRC_1H             0xF9    // Internal oscillator block, CLKO function on RA6 and port function on RA7.
3319 #define _OSC_RC1_1H             0xFA    // 101X External RC oscillator, CLKO function on RA6.
3320 #define _OSC_RC_1H              0xFC    // 11XX External RC oscillator, CLKO function on RA6.
3321 #define _FCMEN_OFF_1H           0xBF    // Fail-Safe Clock Monitor disabled.
3322 #define _FCMEN_ON_1H            0xFF    // Fail-Safe Clock Monitor enabled.
3323 #define _IESO_OFF_1H            0x7F    // Internal External Switchover mode disabled.
3324 #define _IESO_ON_1H             0xFF    // Internal External Switchover mode enabled.
3325 
3326 //----------------------------- CONFIG2L Options -------------------------------
3327 
3328 #define _PWRTEN_ON_2L           0xFE    // PWRT enabled.
3329 #define _PWRTEN_OFF_2L          0xFF    // PWRT disabled.
3330 #define _BOREN_OFF_2L           0xFD    // Brown-out Reset disabled.
3331 #define _BOREN_ON_2L            0xFF    // Brown-out Reset enabled.
3332 #define _BORV_45_2L             0xF3    // VBOR set to 4.5V.
3333 #define _BORV_42_2L             0xF7    // VBOR set to 4.2V.
3334 #define _BORV_27_2L             0xFB    // VBOR set to 2.7V.
3335 #define _BORV_20_2L             0xFF    // Reserved.
3336 
3337 //----------------------------- CONFIG2H Options -------------------------------
3338 
3339 #define _WDTEN_OFF_2H           0xFE    // WDT disabled (control is placed on the SWDTEN bit).
3340 #define _WDTEN_ON_2H            0xFF    // WDT enabled.
3341 #define _WDPS_1_2H              0xE1    // 1:1.
3342 #define _WDPS_2_2H              0xE3    // 1:2.
3343 #define _WDPS_4_2H              0xE5    // 1:4.
3344 #define _WDPS_8_2H              0xE7    // 1:8.
3345 #define _WDPS_16_2H             0xE9    // 1:16.
3346 #define _WDPS_32_2H             0xEB    // 1:32.
3347 #define _WDPS_64_2H             0xED    // 1:64.
3348 #define _WDPS_128_2H            0xEF    // 1:128.
3349 #define _WDPS_256_2H            0xF1    // 1:256.
3350 #define _WDPS_512_2H            0xF3    // 1:512.
3351 #define _WDPS_1024_2H           0xF5    // 1:1024.
3352 #define _WDPS_2048_2H           0xF7    // 1:2048.
3353 #define _WDPS_4096_2H           0xF9    // 1:4096.
3354 #define _WDPS_8192_2H           0xFB    // 1:8192.
3355 #define _WDPS_16384_2H          0xFD    // 1:16384.
3356 #define _WDPS_32768_2H          0xFF    // 1:32768.
3357 #define _WINEN_ON_2H            0xDF    // WDT window enabledbled.
3358 #define _WINEN_OFF_2H           0xFF    // WDT window disabled.
3359 
3360 //----------------------------- CONFIG3L Options -------------------------------
3361 
3362 #define _PWMPIN_ON_3L           0xFB    // PWM outputs drive active states upon Reset.
3363 #define _PWMPIN_OFF_3L          0xFF    // PWM outputs disabled upon Reset (default).
3364 #define _LPOL_LOW_3L            0xF7    // PWM0, 2, 4 and 6 are active-low.
3365 #define _LPOL_HIGH_3L           0xFF    // PWM0, 2, 4 and 6 are active-high.
3366 #define _HPOL_LOW_3L            0xEF    // PWM1, 3, 5 and 7 are active-low.
3367 #define _HPOL_HIGH_3L           0xFF    // PWM1, 3, 5 and 7 are active-high.
3368 #define _T1OSCMX_OFF_3L         0xDF    // Standard (legacy) Timer1 oscillator operation.
3369 #define _T1OSCMX_ON_3L          0xFF    // Low-power Timer1 operation when microcontroller is in Sleep mode.
3370 
3371 //----------------------------- CONFIG3H Options -------------------------------
3372 
3373 #define _MCLRE_OFF_3H           0x7F    // Disabled.
3374 #define _MCLRE_ON_3H            0xFF    // Enabled.
3375 
3376 //----------------------------- CONFIG4L Options -------------------------------
3377 
3378 #define _STVREN_OFF_4L          0xFE    // Stack full/underflow will not cause Reset.
3379 #define _STVREN_ON_4L           0xFF    // Stack full/underflow will cause Reset.
3380 #define _LVP_OFF_4L             0xFB    // Low-voltage ICSP disabled.
3381 #define _LVP_ON_4L              0xFF    // Low-voltage ICSP enabled.
3382 #define _DEBUG_ON_4L            0x7F    // Background debugger enabled; RB6 and RB7 are dedicated to In-Circuit Debug.
3383 #define _DEBUG_OFF_4L           0xFF    // Background debugger disabled; RB6 and RB7 configured as general purpose I/O pins.
3384 
3385 //----------------------------- CONFIG5L Options -------------------------------
3386 
3387 #define _CP0_ON_5L              0xFE    // Block 0 (000200-000FFFh) code-protected.
3388 #define _CP0_OFF_5L             0xFF    // Block 0 (000200-000FFFh) not code-protected.
3389 #define _CP1_ON_5L              0xFD    // Block 1 (001000-001FFF) code-protected.
3390 #define _CP1_OFF_5L             0xFF    // Block 1 (001000-001FFF) not code-protected.
3391 
3392 //----------------------------- CONFIG5H Options -------------------------------
3393 
3394 #define _CPB_ON_5H              0xBF    // Boot Block (000000-0001FFh) code-protected.
3395 #define _CPB_OFF_5H             0xFF    // Boot Block (000000-0001FFh) not code-protected.
3396 #define _CPD_ON_5H              0x7F    // Data EEPROM code-protected.
3397 #define _CPD_OFF_5H             0xFF    // Data EEPROM not code-protected.
3398 
3399 //----------------------------- CONFIG6L Options -------------------------------
3400 
3401 #define _WRT0_ON_6L             0xFE    // Block 0 (000200-000FFFh) write-protected.
3402 #define _WRT0_OFF_6L            0xFF    // Block 0 (000200-000FFFh) not write-protected.
3403 #define _WRT1_ON_6L             0xFD    // Block 1 (001000-001FFF) write-protected.
3404 #define _WRT1_OFF_6L            0xFF    // Block 1 (001000-001FFF) not write-protected.
3405 
3406 //----------------------------- CONFIG6H Options -------------------------------
3407 
3408 #define _WRTC_ON_6H             0xDF    // Configuration registers (300000-3000FFh) write-protected.
3409 #define _WRTC_OFF_6H            0xFF    // Configuration registers (300000-3000FFh) not write-protected.
3410 #define _WRTB_ON_6H             0xBF    // Boot Block (000000-0001FFh) write-protected.
3411 #define _WRTB_OFF_6H            0xFF    // Boot Block (000000-0001FFh) not write-protected.
3412 #define _WRTD_ON_6H             0x7F    // Data EEPROM write-protected.
3413 #define _WRTD_OFF_6H            0xFF    // Data EEPROM not write-protected.
3414 
3415 //----------------------------- CONFIG7L Options -------------------------------
3416 
3417 #define _EBTR0_ON_7L            0xFE    // Block 0 (000200-000FFFh) protected from table reads executed in other blocks.
3418 #define _EBTR0_OFF_7L           0xFF    // Block 0 (000200-000FFFh) not protected from table reads executed in other blocks.
3419 #define _EBTR1_ON_7L            0xFD    // Block 1 (001000-001FFF) protected from table reads executed in other blocks.
3420 #define _EBTR1_OFF_7L           0xFF    // Block 1 (001000-001FFF) not protected from table reads executed in other blocks.
3421 
3422 //----------------------------- CONFIG7H Options -------------------------------
3423 
3424 #define _EBTRB_ON_7H            0xBF    // Boot Block (000000-0001FFh) not protected from table reads executed in other blocks.
3425 #define _EBTRB_OFF_7H           0xFF    // Boot Block (000000-0001FFh) not protected from table reads executed in other blocks.
3426 
3427 //==============================================================================
3428 
3429 #define __DEVID1                0x3FFFFE
3430 #define __DEVID2                0x3FFFFF
3431 
3432 #define __IDLOC0                0x200000
3433 #define __IDLOC1                0x200001
3434 #define __IDLOC2                0x200002
3435 #define __IDLOC3                0x200003
3436 #define __IDLOC4                0x200004
3437 #define __IDLOC5                0x200005
3438 #define __IDLOC6                0x200006
3439 #define __IDLOC7                0x200007
3440 
3441 #endif // #ifndef __PIC18F2331_H__
3442