////////////////////////////////////////////////////////////////////////////
//                                                                      ////
//            DEFINICE REGISTRU PROCESORU PIC16F877                     ////
//                                                                      ////
////////////////////////////////////////////////////////////////////////////
//                                                                      ////
// PEFI S.ICZ a.s  2002                                                 ////
//                                                                      ////
// Verze 1.0                                                            ////
//                                                                      ////
////////////////////////////////////////////////////////////////////////////



// registry v bance 0
#define  INDF                         0x00
#define  TMR0                         0x01
#define  PCL                          0x02
#define  STATUS                       0x03
#define  FSR                          0x04
#define  PORTA                        0x05
#define  PORTB                        0x06
#define  PORTC                        0x07
#define  PORTD                        0x08
#define  PORTE                        0x09
#define  PCLATH                       0x0A
#define  INTCON                       0x0B
#define  PIR1                         0x0C
#define  PIR2                         0x0D
#define  TMR1L                        0x0E
#define  TMR1H                        0x0F
#define  T1CON                        0x10
#define  TMR2                         0x11
#define  T2CON                        0x12
#define  SSPBUF                       0x13
#define  SSPCON                       0x14
#define  CCPR1L                       0x15
#define  CCPR1H                       0x16
#define  CCP1CON                      0x17
#define  RCSTA                        0x18
#define  TXREG                        0x19
#define  RCREG                        0x1A
#define  CCPR2L                       0x1B
#define  CCPR2H                       0x1C
#define  CCP2CON                      0x1D
#define  ADRESH                       0x1E
#define  ADCON0                       0x1F

// registry v bance 1
#define  OPTION                       0x81
#define  TRISA                        0x85
#define  TRISB                        0x86
#define  TRISC                        0x87
#define  TRISD                        0x88
#define  TRISE                        0x89
#define  PIE1                         0x8C
#define  PIE2                         0x8D
#define  PCON                         0x8E
#define  SSPCON2                      0x91
#define  PR2                          0x92
#define  SSPADD                       0x93
#define  SSPSTAT                      0x94
#define  TXSTA                        0x98
#define  SPBRG                        0x99
#define  ADRESL                       0x9E
#define  ADCON1                       0x9F

// registry v bance 2
#define  EEDATA                       0x10C
#define  EEADR                        0x10D
#define  EEDATH                       0x10E
#define  EEADRH                       0x10F

// registry v bance 3
#define  EECON1                       0x18C
#define  EECON2                       0x18D

// bity v registru STATUS
#define  _IRP                          7
#define  _RP1                          6
#define  _RP0                          5
#define  _NOT_TO                       4
#define  _NOT_PD                       3
#define  _Z                            2
#define  _DC                           1
#define  _C                            0

// bity v registru INTCON
#define  _GIE                          7
#define  _PEIE                         6
#define  _T0IE                         5
#define  _INTE                         4
#define  _RBIE                         3
#define  _T0IF                         2
#define  _INTF                         1
#define  _RBIF                         0

// bity v registru PIR1
#define  _PSPIF                        7
#define  _ADIF                         6
#define  _RCIF                         5
#define  _TXIF                         4
#define  _SSPIF                        3
#define  _CCP1IF                       2
#define  _TMR2IF                       1
#define  _TMR1IF                       0

// bity v registru PIR2
#define  _EEIF                         4
#define  _BCLIF                        3
#define  _CCP2IF                       0

// bity v registru T1CON
#define  _T1CKPS1                      5
#define  _T1CKPS0                      4
#define  _T1OSCEN                      3
#define  _NOT_T1SYNC                   2
#define  _T1SYNC                       2
#define  _TMR1CS                       1
#define  _TMR1ON                       0

// bity v registru T2CON
#define  _TOUTPS3                      6
#define  _TOUTPS2                      5
#define  _TOUTPS1                      4
#define  _TOUTPS0                      3
#define  _TMR2ON                       2
#define  _T2CKPS1                      1
#define  _T2CKPS0                      0

// bity v registru SSPCON
#define  _WCOL                         7
#define  _SSPOV                        6
#define  _SSPEN                        5
#define  _CKP                          4
#define  _SSPM3                        3
#define  _SSPM2                        2
#define  _SSPM1                        1
#define  _SSPM0                        0

// bity v registru CCP1CON
#define  _CCP1X                        5
#define  _CCP1Y                        4
#define  _CCP1M3                       3
#define  _CCP1M2                       2
#define  _CCP1M1                       1
#define  _CCP1M0                       0

// bity v registru RCSTA
#define  _SPEN                         7
#define  _RX9                          6
#define  _SREN                         5
#define  _CREN                         4
#define  _ADDEN                        3
#define  _FERR                         2
#define  _OERR                         1
#define  _RX9D                         0

// bity registru CCP2CON
#define  _CCP2X                        5
#define  _CCP2Y                        4
#define  _CCP2M3                       3
#define  _CCP2M2                       2
#define  _CCP2M1                       1
#define  _CCP2M0                       0

// bity v registru ADCON0
#define  _ADCS1                        7
#define  _ADCS0                        6
#define  _CHS2                         5
#define  _CHS1                         4
#define  _CHS0                         3
#define  _GO                           2
#define  _NOT_DONE                     2
#define  _GO_DONE                      2
#define  _ADON                         0

// bity v registru OPTION
#define  _NOT_RBPU                     7
#define  _INTEDG                       6
#define  _T0CS                         5
#define  _T0SE                         4
#define  _PSA                          3
#define  _PS2                          2
#define  _PS1                          1
#define  _PS0                          0

// bity v registru TRISE
#define  _IBF                          7
#define  _OBF                          6
#define  _IBOV                         5
#define  _PSPMODE                      4
#define  _TRISE2                       2
#define  _TRISE1                       1
#define  _TRISE0                       0

// bity v registru PIE1
#define  _PSPIE                        7
#define  _ADIE                         6
#define  _RCIE                         5
#define  _TXIE                         4
#define  _SSPIE                        3
#define  _CCP1IE                       2
#define  _TMR2IE                       1
#define  _TMR1IE                       0

// bity v registru PIE2
#define  _EEIE                         4
#define  _BCLIE                        3
#define  _CCP2IE                       0

// bity v registru PCON
#define  _NOT_POR                      1
#define  _NOT_BOR                      0

// bity v registu
#define  _GCEN                         7
#define  _ACKSTAT                      6
#define  _ACKDT                        5
#define  _ACKEN                        4
#define  _RCEN                         3
#define  _PEN                          2
#define  _RSEN                         1
#define  _SEN                          0

//bity v registru SSPSTAT
#define  _SMP                          7
#define  _CKE                          6
#define  _D                            5
#define  _I2C_DATA                     5
#define  _NOT_A                        5
#define  _NOT_ADDRESS                  5
#define  _D_A                          5
#define  _DATA_ADDRESS                 5
#define  _P                            4
#define  _I2C_STOP                     4
#define  _S                            3
#define  _I2C_START                    3
#define  _R                            2
#define  _I2C_READ                     2
#define  _NOT_W                        2
#define  _NOT_WRITE                    2
#define  _R_W                          2
#define  _READ_WRITE                   2
#define  _UA                           1
#define  _BF                           0

// bity v registru  TXSTA
#define  CSRC                         7
#define  TX9                          6
#define  TXEN                         5
#define  SYNC                         4
#define  BRGH                         2
#define  TRMT                         2
#define  TX9D                         0

// bity v registru ADCON1
#define  _ADFM                         7
#define  _PCFG3                        3
#define  _PCFG2                        2
#define  _PCFG1                        2
#define  _PCFG0                        0

// bity v registru EECON1
#define  _EEPGD                        7
#define  _WRERR                        3
#define  _WREN                         2
#define  _WR                           1
#define  _RD                           0

// masky pro nastaveni orientace I/O pinu
#define  PIN0_IN                       0x01
#define  PIN1_IN                       0x02
#define  PIN2_IN                       0x04
#define  PIN3_IN                       0x08
#define  PIN4_IN                       0x10
#define  PIN5_IN                       0x20
#define  PIN6_IN                       0x40
#define  PIN7_IN                       0x80

#define  PIN0_OUT                      ~0x01
#define  PIN1_OUT                      ~0x02
#define  PIN2_OUT                      ~0x04
#define  PIN3_OUT                      ~0x08
#define  PIN4_OUT                      ~0x10
#define  PIN5_OUT                      ~0x20
#define  PIN6_OUT                      ~0x40
#define  PIN7_OUT                      ~0x80