OK, I define my BdRev variable in a huge text file that just describes all the hardware changes. Then I have a file called 'ports.inc' that defines what bits and port do whatever. There I do this:
In the code you have to be very careful and have conditional code as well in some cases. For example, a bit may move from one port to another, and there may be interactions with routines that do other things on one of the ports. In cases like that, you may be able to keep from code change with some of the bit set/reset commands, but what if multiple bits moved to multiple places? For example 2 bits that are tied to something. In one case they are on a single port, but in another case they are split between two ports. In that case, you need to have conditional code.
Remember, this is a conditional that changes the BUILD, it is not something that changes program flow in operation. (Although I do that to in some cases. To do that, just put a variable in the code that is set to the bdrev value. Hey, if you have a routine that reports the board rev on command it's gotta know it, right? )
; The location of these functions are moved from port H to port M
; starting with rev 03.
if bdrev < 3
tree3 equ PTH ; Port H for rev 1 and rev 2
tree3ddr equ ddrh
insel equ PTP ; Port P is inbus select pins
inselddr equ ddrp ; Port P is inbus select pins
sel_6 equ $0BF ; Bit 6 for high ETs
endif
if bdrev > 2
tree3 equ PTM ; Port M is the new output register rev 3 and beyond
tree3ddr equ ddrm
insel equ PORTK ; Port K is inbus select pins
inselddr equ ddrk ; Port P is inbus select pins
sel_6 equ $07F ; Bit 7 for high ETs
endif
if bdrev = 1
; This is the original first pass proto board rev 01
LStat equ $01 ; Left Lane Status light
LFault equ $04 ; Left Fault Indicator
RStat equ $08 ; Right Lane Status light
RFault equ $40 ; Right Fault Indicator
endif
if bdrev > 1
; Left and right are reversed on rev 02 and later. Here's the new equates
RStat equ $01 ; Left Lane Status light
RFault equ $04 ; Left Fault Indicator
LStat equ $08 ; Right Lane Status light
LFault equ $40 ; Right Fault Indicator
endif
--
Alban Edit: updated code to be what user wanted.Message Edited by Alban on
2007-09-17 01:09 PM