 
format=0.1

#device=PIC16F785
# DOS: DOS-00482
# PS:  DS-41237
# DS:  DS-41249

vpp (range=10.000-12.000  dflt=11.000)
vdd (range=2.000-5.500  dfltrange=2.000-5.500  nominal=5.000)

pgming (memtech=ee tries=1 boundary=4)
     wait (pgm=2500 eedata=6000 cfg=6000 userid=6000 erase=6000)
     latches(pgm=4 eedata=1 userid=4 cfg=1 rowerase=16)   

#Added by Akram to add the boundary
pgmmem (region=0x00-0x7FF)
cfgmem (region=0x2007-0x2007)
# calmem (region=0x3FF-0x3FF) cal mem is at 2008, but does not need to be touched by the user
userid (region=0x2000-0x2003)
devid (region=0x2006-0x2006 idmask=0x3FE0 id=0x1200)
eedata (region=0x0-0xff)
testmem (region=0x2000-0x20FF)
bkbgvectmem (region=0x2004-0x2004)

NumBanks=4

MirrorRegs (0x0-0x0 0x80-0x80 0x100-0x100 0x180-0x180) # Indirrect addr.
MirrorRegs (0x1-0x1 0x101-0x101) # TMR0
MirrorRegs (0x81-0x81 0x181-0x181) # OPTION_REG
MirrorRegs (0x2-0x4 0x82-0x84 0x102-0x104 0x182-0x184) # PCL, STATUS, FSR
MirrorRegs (0x5-0x7 0x105-0x107) # PORT*
MirrorRegs (0x85-0x87 0x185-0x187) # TRIS*
MirrorRegs (0xA-0xB 0x8A-0x8B 0x10A-0x10B 0x18A-0x18B) # PCLATH, INTCON
MirrorRegs (0x70-0x7F 0xF0-0xFF 0x170-0x17F 0x1F0-0x1FF) # accesses Bank 0

UnusedRegs (0x08-0x09)
UnusedRegs (0x0d-0x0d)
UnusedRegs (0x16-0x17)
UnusedRegs (0x19-0x1d)
UnusedRegs (0x88-0x89)
UnusedRegs (0x8d-0x8d)
UnusedRegs (0x94-0x94)
UnusedRegs (0x97-0x97)
UnusedRegs (0xc0-0xef)
UnusedRegs (0x108-0x109)
UnusedRegs (0x10c-0x10f)
UnusedRegs (0x115-0x118)
UnusedRegs (0x11e-0x16f)
UnusedRegs (0x188-0x189)
UnusedRegs (0x18c-0x18d)
UnusedRegs (0x18e-0x18f) # ICD Hidden Registers
UnusedRegs (0x190-0x1ef)

# Q: What's going on in locations 0xC0-0xEF, 0x120-0x16F, and
# 0x1A0-0x1EF?  The diagram in the DOS isn't perfectly clear here.

sfr (key=INDF addr=0x0 size=1 flags=i access='u u u u u u u u')
    reset (por='--------' mclr='--------')
    bit (names='INDF' width='8')
sfr (key=TMR0 addr=0x1 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='TMR0' width='8')
    stimulus (scl=rwb type=int regfiles=w pcfiles=w)
sfr (key=PCL addr=0x2 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='PCL' width='8')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=STATUS addr=0x3 size=1 access='rw rw rw r r rw rw rw')
    reset (por='00011xxx' mclr='000qquuu')
    bit (names='IRP RP nTO nPD Z DC C' width='1 2 1 1 1 1 1')
sfr (key=FSR addr=0x4 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='FSR' width='8')
    stimulus (scl=rwb type=int regfiles=w pcfiles=rw)
sfr (key=PORTA addr=0x5 size=1 access='u u rw rw rw rw rw rw')
    reset (por='--xxxxxx' mclr='--uuuuuu')
    bit (names='- - RA5 RA4 RA3 RA2 RA1 RA0')
    bit (tag=scl names='RA' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)
sfr (key=PORTB addr=0x6 size=1 access='rw rw rw rw u u u u')
    reset (por='xxxx----' mclr='uuuu----')
    bit (names='RB7 RB6 RB5 RB4 - - - -')
    bit (tag=scl names='RB' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)
sfr (key=PORTC addr=0x7 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0')
    bit (tag=scl names='RC' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)
sfr (key=PCLATH addr=0xA size=1 access='u u u rw rw rw rw rw')
    reset (por='---00000' mclr='---00000')
    bit (names='- - - PCLATH' width='1 1 1 5')
    stimulus (scl=rwb type=int regfiles=w pcfiles=rw)
sfr (key=INTCON addr=0xB size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='0000000u')
    bit (names='GIE PEIE TMR0IE INTE RAIE TMR0IF INTF RAIF')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=PIR1 addr=0xC size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='EEIF ADIF CCP1IF C2IF C1IF OSFIF TMR2IF TMR1IF')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=TMR1 addr=0xE size=2 flags=j)
# The j flag means all these registers together form one larger register
    bit (names='TMR1' width='16')
    stimulus (scl=rwb type=int regfiles=w)
sfr (key=TMR1L addr=0xE size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='TMR1L' width='8')
    stimulus (scl=rwb type=int regfiles=w pcfiles=w)
sfr (key=TMR1H addr=0xF size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='TMR1H' width='8')
    stimulus (scl=rwb type=int regfiles=w pcfiles=w)
sfr (key=T1CON addr=0x10 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='uuuuuuuu')
    bit (names='T1GINV TMR1GE T1CKPS T1OSCEN nT1SYNC TMR1CS TMR1ON' width='1 1 2 1 1 1 1')
    stimulus (scl=rwb regfiles=w)

# Q: DOS B says the all-other-reset value is '00000000'.  DOS 0.2 for
# the 685 (a similar part) says the same thing.
sfr (key=TMR2 addr=0x11 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='uuuuuuuu')
    bit (names='TMR2' width='8')
    stimulus (scl=rwb type=int regfiles=w pcfiles=w)

sfr (key=T2CON addr=0x12 size=1 access='u rw rw rw rw rw rw rw')
    reset (por='-0000000' mclr='-0000000')
    bit (names='- TOUTPS TMR2ON T2CKPS' width='1 4 1 2')
    stimulus (scl=rwb regfiles=w)
sfr (key=CCPR addr=0x13 size=2 flags=j)
# The j flag means all these registers together form one larger register
    bit (names='CCPR' width='16')
    stimulus (scl=rwb type=int regfiles=w)
sfr (key=CCPR1L addr=0x13 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='CCPRL' width='8')
    stimulus (scl=rwb type=int regfiles=w)
sfr (key=CCPR1H addr=0x14 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='CCPRH' width='8')
    stimulus (scl=rwb type=int regfiles=w)
sfr (key=CCP1CON addr=0x15 size=1 access='u u rw rw rw rw rw rw')
    reset (por='--000000' mclr='--000000')
    bit (names='- - DCB CCP1M' width='1 1 2 4')
    stimulus (scl=rwb regfiles=w)
sfr (key=WDTCON addr=0x18 size=1 access='u u u rw rw rw rw rw')
    reset (por='---01000' mclr='---01000')
    bit (names='- - - WDTPS SWDTEN' width='1 1 1 4 1')
    stimulus (scl=rwb regfiles=w)
    
sfr (key=ADRESH addr=0x1E size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='ADRESH' width='8')
    stimulus (scl=rwb type=int)
sfr (key=ADCON0 addr=0x1F size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='ADFM VCFG CHS GO/nDONE ADON' width='1 1 4 1 1')
    bit (tag=scl names='ADFM VCFG CHS GO_nDONE ADON' width='1 1 4 1 1')
    stimulus (scl=rwb regfiles=w)

sfr (key=OPTION_REG addr=0x81 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='nRAPU INTEDG T0CS T0SE PSA PS' width='1 1 1 1 1 3')
    stimulus (scl=rwb regfiles=w)
sfr (key=TRISA addr=0x85 size=1 access='u u rw rw rw rw rw rw')
    reset (por='--111111' mclr='--111111')
    bit (names='- - TRISA5 TRISA4 TRISA3 TRISA2 TRISA1 TRISA0')
    bit (tag=scl names='TRISA' width='8')
    stimulus (scl=rwb regfiles=w)    

# Q: DOS B says that the reset values for TRISB are '1111xxxx', but
# also states that the low four bits are unimplemented.  There is
# probably an error here.
sfr (key=TRISB addr=0x86 size=1 access='rw rw rw rw u u u u')
    reset (por='1111----' mclr='1111----')
    bit (names='TRISB7 TRISB6 TRISB5 TRISB4 - - - -')
    bit (tag=scl names='TRISB' width='8')
    stimulus (scl=rwb regfiles=w)

sfr (key=TRISC addr=0x87 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='TRISC7 TRISC6 TRISC5 TRISC4 TRISC3 TRISC2 TRISC1 TRISC0')
    bit (tag=scl names='TRISC' width='8')
    stimulus (scl=rwb regfiles=w)

sfr (key=PIE1 addr=0x8C size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='EEIE ADIE CCP1IE C2IE C1IE OSFIE TMR2IE TMR1IE')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=PCON addr=0x8E size=1 access='u u u rw u u rw rw')
    reset (por='---1--qq' mclr='---u--uu')
    bit (names='- - - SBOREN - - nPOR nBOR')
    stimulus (scl=rwb regfiles=w)
sfr (key=OSCCON addr=0x8F size=1 access='u rw rw rw r r r rw')
    reset (por='-110x000' mclr='-110x000')
    bit (names='- IRCF OSTS HTS LTS SCS' width='1 3 1 1 1 1')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=OSCTUNE addr=0x90 size=1 access='u u u rw rw rw rw rw')
    reset (por='---00000' mclr='---uuuuu')
    bit (names='- - - TUN' width='1 1 1 5')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=ANSEL0 addr=0x91 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='ANS7 ANS6 ANS5 ANS4 ANS3 ANS2 ANS1 ANS0')
    stimulus (scl=rwb regfiles=r)
sfr (key=PR2 addr=0x92 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='11111111' mclr='11111111')
    bit (names='PR2' width='8')
    stimulus (scl=rwb type=int regfiles=w)
sfr (key=ANSEL1 addr=0x93 size=1 access='u u u u rw rw rw rw')
    reset (por='----1111' mclr='----1111')
    bit (names='- - - - ANS11 ANS10 ANS9 ANS8')
    stimulus (scl=rwb regfiles=r)

# Q: Bit 3 on this register is a little strange.  I'll need to do a
# little research before I can be confidient in this definition.
sfr (key=WPUA addr=0x95 size=1 access='u u rw rw rw rw rw rw')
    reset (por='--11-111' mclr='--11-111')
    bit (names='- - WPUA5 WPUA4 - WPUA2 WPUA1 WPUA0')
    stimulus (scl=rwb regfiles=w)

sfr (key=IOCA addr=0x96 size=1 access='u u rw rw rw rw rw rw')
    reset (por='--000000' mclr='--000000')
    bit (names='- - IOCA5 IOCA4 IOCA3 IOCA2 IOCA1 IOCA0')
    stimulus (scl=rwb regfiles=w)

sfr (key=REFCON addr=0x98 size=1 access='u u rw rw rw rw rw u')
    reset (por='--00000-' mclr='--00000-')
    bit (names='- - BGST VRBB VREN VROE CVROE -')

sfr (key=VRCON addr=0x99 size=1 access='rw rw rw u rw rw rw rw')
    reset (por='000-0000' mclr='000-0000')
    bit (names='C1VREN C2VREN VRR - VR3 VR2 VR1 VR0')
    stimulus (scl=rwb regfiles=w)

sfr (key=EEDATA addr=0x9A size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='EEDATA' width='8')
    stimulus (scl=rwb regfiles=rw pcfiles=rw)
sfr (key=EEADR addr=0x9B size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='EEADR' width='8')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=EECON1 addr=0x9C size=1 access='u u u u rw rw rs rs')
    reset (por='----x000' mclr='----q000')
    bit (names='- - - - WRERR WREN WR RD')
    stimulus (scl=rwb regfiles=w pcfiles=rw)
sfr (key=EECON2 addr=0x9D size=1 flags=w access='w w w w w w w w')
    reset (por='--------' mclr='--------')
    bit (names='EECON2' width='8')
sfr (key=ADRESL addr=0x9E size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='xxxxxxxx' mclr='uuuuuuuu')
    bit (names='ADRESL' width='8')
    stimulus (scl=rwb type=int regfiles=r)
sfr (key=ADCON1 addr=0x9F size=1 access='u rw rw rw u u u u')
    reset (por='-000----' mclr='-000----')
    bit (names='- ADCS - - - -' width='1 3 1 1 1 1')
    stimulus (scl=rwb regfiles=w)

sfr (key=PWMCON1 addr=0x110 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='OVRLP COMOD CMDLY' width='1 2 5')
    stimulus (scl=rwb regfiles=w)
sfr (key=PWMCON0 addr=0x111 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='PRSEN PASEN BLANK2 BLANK1 SYNC PH2EN PH1EN' width='1 1 1 1 2 1 1')
    stimulus (scl=rwb regfiles=w)
sfr (key=PWMCLK addr=0x112 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='PWMASE PS PER' width='1 2 5')
sfr (key=PWMPH1 addr=0x113 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='POL C2EN C1EN PH' width='1 1 1 5')
sfr (key=PWMPH2 addr=0x114 size=1 access='rw rw rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='POL C2EN C1EN PH' width='1 1 1 5')

sfr (key=CM1CON0 addr=0x119 size=1 access='rw r rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='C1ON C1OUT C1OE C1POL C1SP C1R C1CH' width='1 1 1 1 1 1 2')
    stimulus (scl=rwb regfiles=w)
sfr (key=CM2CON0 addr=0x11A size=1 access='rw r rw rw rw rw rw rw')
    reset (por='00000000' mclr='00000000')
    bit (names='C2ON C2OUT C2OE C2POL C2SP C2R C2CH' width='1 1 1 1 1 1 2')
    stimulus (scl=rwb regfiles=w)
sfr (key=CM2CON1 addr=0x11B size=1 access='r r u u u u rw rw')
    reset (por='00----10' mclr='00----10')
    bit (names='MC1OUT MC2OUT - - - - T1GSS C2SYNC')
    stimulus (scl=rwb regfiles=w)
sfr (key=OPA1CON addr=0x11C size=1 access='rw u u u u u u u')
    reset (por='0-------' mclr='0-------')
    bit (names='OPAON - - - - - - -')
sfr (key=OPA2CON addr=0x11D size=1 access='rw u u u u u u u')
    reset (por='0-------' mclr='0-------')
    bit (names='OPAON - - - - - - -')

                               # -------------------#
#------------------------------# Configuration Bits #------------------------------------#
                               # -------------------#

cfgbits (key=CONFIG addr=0x2007 unused=0x3000)
#    illegal (mask=0x48 value=0x48 msg="Current settings of PWRT and BOD are in conflict")
    field (key=OSC mask=0x7 desc="Oscillator")
        setting (req=0x7 value=0x7 desc="EXTRC: CLKOUT on RA4, RC on RA5")
        setting (req=0x7 value=0x6 desc="EXTRCIO: I/O on RA4, RC on RA5")
        setting (req=0x7 value=0x5 desc="INTOSC: CLKOUT on RA4, I/O on RA5")
        setting (req=0x7 value=0x4 desc="INTOSCIO: I/O on RA4/RA5")
        setting (req=0x7 value=0x3 desc="EC")
        setting (req=0x7 value=0x2 desc="HS")
        setting (req=0x7 value=0x1 desc="XT")
        setting (req=0x7 value=0x0 desc="LP")
    field (key=WDT mask=0x8 desc="Watchdog Timer" min=1)
        setting (req=0x8 value=0x8 desc="On")
        setting (req=0x8 value=0x0 desc="Off")
    field (key=PUT mask=0x10 desc="Power Up Timer")
        setting (req=0x10 value=0x10 desc="Off")
        setting (req=0x10 value=0x0 desc="On")
    field (key=MCLRE mask=0x20 desc="Master Clear Enable")
        setting (req=0x20 value=0x20 desc="External")
        setting (req=0x20 value=0x00 desc="Internal")
    field (key=CP mask=0x40 desc="Code Protect")
        setting (req=0x40 value=0x40 desc="Off")
            checksum (type=0x0 protregion=0x00-0x00)
        setting (req=0x40 value=0x00 desc="On")
            checksum (type=0x20 protregion=0x000-0x7FF)
    field (key=CPD mask=0x80 desc="Data EE Read Protect")
        setting (req=0x80 value=0x80 desc="Off")
        setting (req=0x80 value=0x0 desc="On")
   field (key=BODEN mask=0x300 desc="Brown Out Detect")
        setting (req=0x300 value=0x000 desc="BOD and SBOREN disabled")
        setting (req=0x300 value=0x100 desc="SBOREN controls BOR function")
        setting (req=0x300 value=0x200 desc="BOD enabled in run, disabled in sleep, SBOREN disabled")
        setting (req=0x300 value=0x300 desc="BOD Enabled, SBOREN Disabled")
    field (key=IESO mask=0x400 desc="Internal External Switch Over Mode")
        setting (req=0x400 value=0x400 desc="Enabled")
        setting (req=0x400 value=0x0 desc="Disabled")
   field (key=FCMEN mask=0x800 desc="Monitor Clock Fail-safe")
        setting (req=0x800 value=0x800 desc="Enabled")
        setting (req=0x800 value=0x0 desc="Disabled")
                               #-------------#
#------------------------------# Peripherals #------------------------------------#
                               #-------------#
#--------------------------------------------------------------------------------
# 				PORTA
#--------------------------------------------------------------------------------
peripheral (key=PORTA sfrs='TRISA PORTA IOCA' type=port)
    iopin (key=RA0 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x00 cnkey=IOCPIN0)
        cnpin (key=C1INP notify=CMMUL)
    iopin (key=RA1 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x00 cnkey=IOCPIN1)
        cnpin (key=C1INN0 notify=CMMUL)
        cnpin (key=C2INN0 notify=CMMUL)
    iopin (key=RA2 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x00 cnkey=IOCPIN2)
        extint (key=INT0 enreg=INTCON enmask=0x10 flgreg=INTCON flgmask=0x02 prireg=NONE primask=0x00)
        cnpin (key=PWMFLTA notify=PWM2PH)
    iopin (key=RA3 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x00 cnkey=IOCPIN3)
    iopin (key=RA4 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x00 cnkey=IOCPIN4)
    iopin (key=RA5 dir=inout)
        cnint (key=PORTIRQ enreg=INTCON enmask=0x08 flgreg=INTCON flgmask=0x01 prireg=NONE primask=0x00 cnkey=IOCPIN5)
#--------------------------------------------------------------------------------
# 				PORTB
#--------------------------------------------------------------------------------
peripheral (key=PORTB sfrs='TRISB PORTB' type=port)
    iopin (key=RB4 dir=inout)
    iopin (key=RB5 dir=inout)
    iopin (key=RB6 dir=inout)
    iopin (key=RB7 dir=inout)
    #PWM Synch pin is polled in peripheral so does not need to be tied to a port
    #    cnpin (key=PWMSYNCH notify=PWM2PH)

#--------------------------------------------------------------------------------
# 				PORTC
#--------------------------------------------------------------------------------

peripheral (key=PORTC sfrs='TRISC PORTC' type=port)
    iopin (key=RC0 dir=inout)
        cnpin (key=C2INP notify=CMMUL)
    iopin (key=RC1 dir=inout)
        cnpin (key=C1INN1 notify=CMMUL)
        cnpin (key=C2INN1 notify=CMMUL)
    iopin (key=RC2 dir=inout)
        cnpin (key=C1INN2 notify=CMMUL)
        cnpin (key=C2INN2 notify=CMMUL)
    iopin (key=RC3 dir=inout)
        cnpin (key=C1INN3 notify=CMMUL)
        cnpin (key=C2INN3 notify=CMMUL)
    iopin (key=RC4 dir=inout)
    iopin (key=RC5 dir=inout)
        cnpin (key=CCP1CN notify=CCP1)
    iopin (key=RC6 dir=inout)
    iopin (key=RC7 dir=inout)


#--------------------------------------------------------------------------------
# 				ADC
#--------------------------------------------------------------------------------

peripheral (key=ADC10 sfrs='ADCON0 ADCON1 ANSEL0 ANSEL1 ADRESL ADRESH')
    pinfunc (key=AN0 port=RA0 dir=in)
        nextp (nextperiph=CM nextpin=C1INP)
    pinfunc (key=AN1 port=RA1 dir=in)
    pinfunc (key=AN2 port=RA2 dir=in)
        nextp (nextperiph=TMR0 nextpin=T0CKI)
    pinfunc (key=AN3 port=RA4 dir=in)
        nextp (nextperiph=TMR1 nextpin=T1G)
    pinfunc (key=AN4 port=RC0 dir=in)
        nextp (nextperiph=CM nextpin=C2INP)
    pinfunc (key=AN5 port=RC1 dir=in)
    pinfunc (key=AN6 port=RC2 dir=in)
        nextp (nextperiph=CM nextpin=C2OUT)
    pinfunc (key=AN7 port=RC3 dir=in)
    pinfunc (key=AN8 port=RC6 dir=in)
    pinfunc (key=AN9 port=RC7 dir=in)
    pinfunc (key=AN10 port=RB4 dir=in)
    pinfunc (key=AN11 port=RB5 dir=in)
    access (key=ADCON0 mode=AD_ADCON0_NO_ADCS)
    access (key=ADCON1 mode=AD_ADCS_ONLY)
    adgodone (key=ADCON0 mask=0x02)
    interrupt (name=ADC enreg=PIE1 enmask=0x40 flgreg=PIR1 flgmask=0x40 prireg=NONE primask=0x00)


#--------------------------------------------------------------------------------
# 				TIMERs
#--------------------------------------------------------------------------------
peripheral (key=TMR0 sfrs='TMR0')
    pinfunc (key=T0CKI port=RA2 dir=in)
        nextp (nextperiph=CM nextpin=C1OUT)
    interrupt (name=TMR0INT enreg=INTCON enmask=0x20 flgreg=INTCON flgmask=0x04 prireg=NONE primask=0x00)

peripheral (key=TMR1 sfrs='TMR1H TMR1L T1CON')
    pinfunc (key=T1CKI port=RA5 dir=in)
    pinfunc (key=T1G port=RA4 dir=in)
    interrupt (name=TMR1INT enreg=PIE1 enmask=0x01 flgreg=PIR1 flgmask=0x01 prireg=NONE primask=0x00)

peripheral (key=TMR2 sfrs='TMR2 PR2 T2CON')
    interrupt (name=TMR2INT enreg=PIE1 enmask=0x02 flgreg=PIR1 flgmask=0x02 prireg=NONE primask=0x00)
 
#--------------------------------------------------------------------------------
# 				CCP
#--------------------------------------------------------------------------------

peripheral (key=CCP1 sfrs='CCP1CON CCPR1L CCPR1H')
    pinfunc (key=CCP1 port=RC5 dir=inout)
    interrupt (name=CCP1INT enreg=PIE1 enmask=0x20 flgreg=PIR1 flgmask=0x20 prireg=NONE primask=0x00)
    specialevent (key=ADC)
    timers (addr=0x0 mask=0x00)
        setting (val=0x00 cc=TMR1 pwm=TMR2)
        setting (val=0x00 cc=TMR1 pwm=TMR2)
        setting (val=0x00 cc=TMR1 pwm=TMR2)
        setting (val=0x00 cc=TMR1 pwm=TMR2)

#--------------------------------------------------------------------------------
# 				CMMUL
#--------------------------------------------------------------------------------

peripheral (key=CMMUL sfrs='CM1CON0 CM2CON0 CM2CON1 VRCON')
    pinfunc (key=C1OUT port=RA2 dir=inout)
    pinfunc (key=C1INP port=RA0 dir=in)
    pinfunc (key=C1INN port=multi dir=inout)
        portpins (muxaddr=0x119 muxmask=0x03)
            setting (muxval=0x0 port=RA1 dir=in)
            setting (muxval=0x1 port=RC1 dir=in)
            setting (muxval=0x2 port=RC2 dir=in)
            setting (muxval=0x3 port=RC3 dir=in)
    pinfunc (key=C2OUT port=RC4 dir=inout)
    pinfunc (key=C2INP port=RC0 dir=inout)
    pinfunc (key=C2INN port=multi dir=inout)
        portpins (muxaddr=0x11A muxmask=0x03)
            setting (muxval=0x0 port=RA1 dir=inout)
            setting (muxval=0x1 port=RC1 dir=inout)
            setting (muxval=0x2 port=RC2 dir=inout)
            setting (muxval=0x3 port=RC3 dir=inout)
    interrupt (name=CMINT enreg=PIE1 enmask=0x08 flgreg=PIR1 flgmask=0x08 prireg=NONE primask=0x00)
    interrupt (name=CM2INT enreg=PIE1 enmask=0x10 flgreg=PIR1 flgmask=0x10 prireg=NONE primask=0x00)

#--------------------------------------------------------------------------------
# 				PWM
#--------------------------------------------------------------------------------

peripheral (key=PWM2PH sfrs='PWMCON0 PWMCON1 PWMCLK PWMPH1 PWMPH2')
    pinfunc (key=PWM0 port=RC1 dir=out)
    pinfunc (key=PWM1 port=RC4 dir=out)
    #Synch pin is polled in peripheral so does not need to be tied to a port
    pinfunc (key=PWMSYNCH port=RB7 dir=inout)
    pinfunc (key=PWMFLTA port=RA2 dir=in)

#--------------------------------------------------------------------------------
# 				OSC
#--------------------------------------------------------------------------------

peripheral (key=OSC sfrs='OSCCON')
    pinfunc (key=OSC2 port=RA4 dir=out)
        nextp (nextperiph=TMR1 nextpin=T1G)
    pinfunc (key=OSC1 port=RA5 dir=in)
        nextp (nextperiph=TMR1 nextpin=T1CKI)

#--------------------------------------------------------------------------------
# 				MCLR
#--------------------------------------------------------------------------------
peripheral (key=MCLR)
    pinfunc (key=MCLR port=RA3 dir=in)


peripheral (key=OPA) # op-amp

#--------------------------------------------------------------------------------
# 				CORE
#--------------------------------------------------------------------------------
peripheral (key=CORE sfrs='EEDATA EEADR EECON1 EECON2 PCON WDTCON')
    interrupt (name=EEINT enreg=PIE1 enmask=0x80 flgreg=PIR1 flgmask=0x80 prireg=NONE primask=0x00)


