'#Uses "include.inc"
'#Uses "..\include\Port.inc"


Option Explicit
'*****************************************************************************
' Module:
'        EBC
'-----------------------------------------------------------------------------
' Description:
'        This file contains the 'Update' functions for the module.
'
'-----------------------------------------------------------------------------
' History:
'                 
'        Rev. Author         Date        Description
'        ----------------------------------------------------------------------
'        1.0   ahe         27.04.00     final version  for C165UTAH
'
'        ----------------------------------------------------------------------
'        2.0   ahe         14.06.00     final version for C167CS
'
'        ----------------------------------------------------------------------
'        2.1   ahe         02.08.00     final version for C167CS and C161CS/JC/JI
'                                       - check if XPERCON exist
'
'              ahe         05.10.00     - set WRCFG = 0 and BYTDIS = 1
'
'        ----------------------------------------------------------------------
'        7.0   ahe         27.03.01     final version for Pegasus
'
'        7.1   ahe         02.07.02     no changes
'        ----------------------------------------------------------------------
'              ste         24.11.03     register EBCMOD1 initialized
'
'
'*****************************************************************************


'*****************************************************************************
'Description:
'        This function is called by the main module in order to reset or update
'        the project variables and register contents of this peripheral
'-----------------------------------------------------------------------------
'Parameters:
'        r                      reference to the project data variables
'        vIndex                 a parameter
'        lngUpdateDescriptor    identification of the update context
'                  0          = initialization for a new project
'                  1, 2, 3... = value that identifies which project settings have
'                               been changed (e.g. CPU-Type, CPU-Clock etc.)
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function UpdateProjectData(r As ProjectData, vIndex As Variant, lngUpdateDescriptor As Long) As Boolean
    On Error GoTo UpdateProjectDataError

    UpdateProjectData = False

    Dim sRegPre As String
    Dim sVarPre As String

    sVarPre = "EBC"
    sRegPre = ""

    Select Case lngUpdateDescriptor
        Case 0 
            r.v(sVarPre & "_Notes")                 = "" 
            r.v(sVarPre & "_MS_SL") = 0

            Call RequestAlternateOutputPin(r, "ALE_O")
            
            If (r.Exist("MuxFor_READY_I") = True) Then
                Call RequestAlternateInputPin(r, "READY_I")
            Else
                r.v("EBCMOD0_RDYDIS") = 1
            End If
            
            r.sfr("TCONCS0") = &H6243
            r.v("FCONCS0_ENCS0") = 1
            r.sfr("EBCMOD1") = &H007f    ' will be overritten from the next functions
            Call SelectPinInterfaceP0L(r)
            Call SelectPinInterfaceP0H(r)
            r.v("FCONCS0_BTYP0") = 1
            Call Select_Pin_Interface_For_EBC(r, 0, 3)
            r.v("FCONCS0_BTYP0") = 3
            
             r.v("EA_EA") = 1
             r.v("RSTCFG_BUSTYP") = 3

        Case 1
            '...
       'Case...
    End Select

    UpdateProjectData = True
    Exit Function

UpdateProjectDataError:
    ErrorBox "Error in function UpdateProjectData", Err.Description
    Exit Function
End Function

