; ***************************************************************
; * Copyright (C) 2005, Embed Inc (http://www.embedinc.com) *
; * *
; * Permission to copy this file is granted as long as this *
; * copyright notice is included in its entirety at the *
; * beginning of the file, whether the file is copied in whole *
; * or in part and regardless of whether other information is *
; * added to the copy. *
; * *
; * The contents of this file may be used in any way, *
; * commercial or otherwise. This file is provided "as is", *
; * and Embed Inc makes no claims of suitability for a *
; * particular purpose nor assumes any liability resulting from *
; * its use. *
; ***************************************************************
;
; Manage the I/O ports at a low level.
;
/include "qq1.ins.dspic"
;
;***********************************************************************
;
; Configuration constants.
;
;
; Derived constants.
;
;
;***********************************************************************
;
; Variables.
;
;*******************
;
; Global state.
;
;
;*******************
;
; Local state.
;
.text
;
;***********************************************************************
;
; Subroutine PORT_INIT
;
; Initialize the hardware and software state managed by this module.
;
glbsub port_init, regf0
;
; Disable the A/D inputs so that they become digital I/O lines if this
; processor has an A/D. If the A/D is used, it will be set up by a
; module for that purpose later.
;
.ifdef Adpcfg
mov #0xFFFF, w0 ;set all ANx pins to digital I/O
mov w0, Adpcfg
.endif
;
; Initialize port A if it exists.
;
.ifdef Porta
mov #val_porta, w0
mov w0, LatA
mov #val_trisa, w0
mov w0, TrisA
.endif
;
; Initialize port B if it exists.
;
.ifdef Portb
mov #val_portb, w0
mov w0, LatB
mov #val_trisb, w0
mov w0, TrisB
.endif
;
; Initialize port C if it exists.
;
.ifdef Portc
mov #val_portc, w0
mov w0, LatC
mov #val_trisc, w0
mov w0, TrisC
.endif
;
; Initialize port D if it exists.
;
.ifdef Portd
mov #val_portd, w0
mov w0, LatD
mov #val_trisd, w0
mov w0, TrisD
.endif
;
; Initialize port E if it exists.
;
.ifdef Porte
mov #val_porte, w0
mov w0, LatE
mov #val_trise, w0
mov w0, TrisE
.endif
;
; Initialize port F if it exists.
;
.ifdef Portf
mov #val_portf, w0
mov w0, LatF
mov #val_trisf, w0
mov w0, TrisF
.endif
;
; Initialize port G if it exists.
;
.ifdef Portg
mov #val_portg, w0
mov w0, LatG
mov #val_trisg, w0
mov w0, TrisG
.endif
;
; Initialize port H if it exists.
;
.ifdef Porth
mov #val_porth, w0
mov w0, LatH
mov #val_trish, w0
mov w0, TrisH
.endif
;
; Initialize port I if it exists.
;
.ifdef Porti
mov #val_porti, w0
mov w0, LatI
mov #val_trisi, w0
mov w0, TrisI
.endif
;
; Initialize port J if it exists.
;
.ifdef Portj
mov #val_portj, w0
mov w0, LatJ
mov #val_trisj, w0
mov w0, TrisJ
.endif
;
; Initialize port K if it exists.
;
.ifdef Portk
mov #val_portk, w0
mov w0, LatK
mov #val_trisk, w0
mov w0, TrisK
.endif
;
; Initialize port L if it exists.
;
.ifdef Portl
mov #val_portl, w0
mov w0, LatL
mov #val_trisl, w0
mov w0, TrisL
.endif
;
; Initialize port M if it exists.
;
.ifdef Portm
mov #val_portm, w0
mov w0, LatM
mov #val_trism, w0
mov w0, TrisM
.endif
;
; Initialize port N if it exists.
;
.ifdef Portn
mov #val_portn, w0
mov w0, LatN
mov #val_trisn, w0
mov w0, TrisN
.endif
;
; Initialize port O if it exists.
;
.ifdef Porto
mov #val_porto, w0
mov w0, LatO
mov #val_triso, w0
mov w0, TrisO
.endif
;
; Initialize port P if it exists.
;
.ifdef Portp
mov #val_portp, w0
mov w0, LatP
mov #val_trisp, w0
mov w0, TrisP
.endif
;
; Initialize port Q if it exists.
;
.ifdef Portq
mov #val_portq, w0
mov w0, LatQ
mov #val_trisq, w0
mov w0, TrisQ
.endif
;
; Initialize port R if it exists.
;
.ifdef Portr
mov #val_portr, w0
mov w0, LatR
mov #val_trisr, w0
mov w0, TrisR
.endif
;
; Initialize port S if it exists.
;
.ifdef Ports
mov #val_ports, w0
mov w0, LatS
mov #val_triss, w0
mov w0, TrisS
.endif
;
; Initialize port T if it exists.
;
.ifdef Portt
mov #val_portt, w0
mov w0, LatT
mov #val_trist, w0
mov w0, TrisT
.endif
;
; Initialize port U if it exists.
;
.ifdef Portu
mov #val_portu, w0
mov w0, LatU
mov #val_trisu, w0
mov w0, TrisU
.endif
;
; Initialize port V if it exists.
;
.ifdef Portv
mov #val_portv, w0
mov w0, LatV
mov #val_trisv, w0
mov w0, TrisV
.endif
;
; Initialize port W if it exists.
;
.ifdef Portw
mov #val_portw, w0
mov w0, LatW
mov #val_trisw, w0
mov w0, TrisW
.endif
;
; Initialize port X if it exists.
;
.ifdef Portx
mov #val_portx, w0
mov w0, LatX
mov #val_trisx, w0
mov w0, TrisX
.endif
;
; Initialize port Y if it exists.
;
.ifdef Porty
mov #val_porty, w0
mov w0, LatY
mov #val_trisy, w0
mov w0, TrisY
.endif
;
; Initialize port Z if it exists.
;
.ifdef Portz
mov #val_portz, w0
mov w0, LatZ
mov #val_trisz, w0
mov w0, TrisZ
.endif
leaverest
.end