' Hardware Definitions:  Port und Pin for FlashCard

' Data Port (D0-D7)
CF_Data_Out alias PortA
CF_Data_In alias PinA
CF_Data_DDR alias DDRA

' CF - Register - addressing (A0-A2)
' addresses uses 3 LSB Bit x x x x x A2 A1 A0

' Control - Port (CE1, OE, WE)
CF_Control_Out alias PortC
'CF_Control_DDR alias DDRC               ' not on Mega103

' Pins at Control-Port
Const CF_CE1 = 5 : CF_CE1 alias 5       ' Card enable
Const CF_OE = 3 : CF_OE alias 3         ' Output enable
Const CF_WE = 4 : CF_WE alias 4         ' Write enable

' Mask for setting direction for Control-pins
Const CF_Control_Direction =(2 ^ CF_CE1) +(2 ^ CF_OE) +(2 ^ CF_WE)       ' CE1, OE, WE to output = 1
' Mask for setting init levels for control-pins
Const CF_Control_Init =(2 ^ CF_OE) +(2 ^ CF_WE)
' Mask for clear control pins and left other unchanged
Const CF_Control_Mask = 255 - CF_Control_Direction       ' CE1, OW, WE to 0, unused to 1


' Address - Port ( A2. A1, A0) at pin 2 - 0 for eaysier handling
CF_Addr_Out alias PortC
'CF_Addr_DDR alias DDRC              ' not on Meag103

' Mask for setting direction for address-pins
Const CF_Addr_Direction = &B00000111    ' A2 , A1, A0 to Output = 1
' Mask for setting init levels for address-pins
Const CF_Addr_Init = 0
' Mask for clear address pins and left other unchanged
Const CF_Addr_Mask = 255 - CF_Addr_Direction



' Declare here used Error-Constants from Driver (use 224 to 255)
Const cpErrDriveNotPresent = 225
Const cpErrDriveError = 229
Const cpErrDriveTimeOut = 226
const cpErrDriveTimeOutCommand = 227
Const cpErrDriveTimeOutData = 228
Const cpErrDriveTimeOutBusy = 229



$LIB "FlashCardDrive_EL_PIN.LBX"

' Init the Drive
' use a r24 to scratch
_temp1 = DriveInit()
waitms 1                                ' force compiler to link _waitms routine
                                          ' can't be linked with 'EXTERNAL in LIB