'#Uses "Include.inc"

Option Explicit
'*****************************************************************************
' Module:
'        ADC
'-----------------------------------------------------------------------------
' Description:
'        This file contains the 'Update' functions for the module.
'
'-----------------------------------------------------------------------------
' History:
'                 
'        Rev. Author         Date        Description
'        ---------------------------------------------------------------------
'        1.0   ahe         14.06.00     final version
'
'        ---------------------------------------------------------------------
'        2.0   ahe         20.07.00     final version for C161PI
'                                       - reduzierung von Ch's von 24 auf 4
'
'        ---------------------------------------------------------------------
'        3.0   ahe         07.08.00     final version for C161CS/JC/JI
'                                       - only AN0..AN7 and AN12..AN15
'
'        ---------------------------------------------------------------------
'        4.0   ahe         20.02.01     final version for Pegasus
'
'        4.1   ahe         08.08.02     no changes
'        4.2   ste         09.12.02     formula for conversion time changed 
'                                       (spec. changed)
'
'*****************************************************************************


'*****************************************************************************
'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

    Dim sVarPre   As String
    Dim sRegPre   As String
    Dim i         As Integer

    UpdateProjectData = False
    sVarPre = "ADC" & vIndex
    sRegPre = sVarPre & "_"

    Select Case lngUpdateDescriptor
        Case 0 
            
            r.v(sVarPre & "_CFile")             = sVarPre & ".C"
            r.v(sVarPre & "_HFile")             = sVarPre & ".H"
            r.v(sVarPre & "_Notes")             = ""
            r.v(sVarPre & "_NAME_Init")         = sVarPre & "_vInit"

            r.v(sVarPre & "_NAME_StartConv")    = sVarPre & "_vStartConv"
            r.v(sVarPre & "_NAME_ConfConv")     = sVarPre & "_vConfConv"
            r.v(sVarPre & "_NAME_StopConv")     = sVarPre & "_vStopConv"
            r.v(sVarPre & "_NAME_ConvReady")    = sVarPre & "_ubConvReady"
            r.v(sVarPre & "_NAME_ReadConv")     = sVarPre & "_uwReadConv"
            r.v(sVarPre & "_NAME_OverWrite")    = sVarPre & "_ubOverWrite"
            r.v(sVarPre & "_NAME_Busy")         = sVarPre & "_ubBusy"
            r.v(sVarPre & "_NAME_Conv")         = sVarPre & "_viConv"
            r.v(sVarPre & "_NAME_Error")        = sVarPre & "_viError"
            r.v(sVarPre & "_NAME_InjectChan")   = sVarPre & "_ubInjectChan"
            r.v(sVarPre & "_NAME_StartInject")  = sVarPre & "_vStartInject"
            r.v(sVarPre & "_NAME_ReadInject")   = sVarPre & "_uwReadInject"
            r.v(sVarPre & "_NAME_InjectReady")  = sVarPre & "_ubInjectReady"
            r.v(sVarPre & "_Tbc_Factor") = 4

            For i = 0 To 15
              If (r.Exist(sVarPre & "_PARA_ANA_" & i)) Then
                  r.v(sVarPre & "_PARA_ANA_" & i)   = sVarPre & "_ANA_" & i
              End If
            Next i

            r.v(sRegPre & "CTR0_ADCTS") = 1  

            r.v(sVarPre & "_PARA_FIXED")        = sVarPre & "_FIXED"
            r.v(sVarPre & "_PARA_SCAN")         = sVarPre & "_SCAN"
            r.v(sVarPre & "_PARA_SCAN_CONTI")   = sVarPre & "_SCAN_CONTI"
            r.v(sVarPre & "_PARA_FIXED_CONTI")  = sVarPre & "_FIXED_CONTI"

            '...

        Case 1

            '...
       'Case...
    End Select

    UpdateProjectData = True
    Exit Function

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

