'#Uses "include.inc"

Option Explicit
'*****************************************************************************
' Module:
'        SCU
'-----------------------------------------------------------------------------
' Description:
'        This file contains the 'Update' functions for the module.
'
'-----------------------------------------------------------------------------
' History:
'                 
'        Rev. Author         Date        Description
'        ----------------------------------------------------------------------
'        3.0   ahe          13.09.00    final version for C161CS/JC/JI (PM)
'
'        ----------------------------------------------------------------------
'        1.0   ahe          02.05.01    final version for Pegasus
'        1.1   ste          06.01.03    no changes
'
'*****************************************************************************


'*****************************************************************************
'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 sVarPre As String
    sVarPre = "SCU"

    Select Case lngUpdateDescriptor
        Case 0 

            r.v(sVarPre & "_NAME_GetSystemStatus")          = sVarPre & "_uwGetSystemStatus"
            r.v(sVarPre & "_NAME_SetPowerDown")          = sVarPre & "_vSetPowerDown"
            r.v(sVarPre & "_NAME_SetIdle")               = sVarPre & "_vSetIdle"
            r.v(sVarPre & "_NAME_SetSleep")              = sVarPre & "_vSetSleep"
            r.v(sVarPre & "_NAME_EnableModule")          = sVarPre & "_vEnableModule"
            r.v(sVarPre & "_NAME_DisableModule")         = sVarPre & "_vDisableModule"
            r.v(sVarPre & "_NAME_StartCount")            = sVarPre & "_vStartCount"
            r.v(sVarPre & "_NAME_StopCount")             = sVarPre & "_vStopCount"
            r.v(sVarPre & "_NAME_SetReloadValue")        = sVarPre & "_vSetReloadValue"
            r.v(sVarPre & "_NAME_Init")                  = sVarPre & "_vInit"
            
            r.v(sVarPre & "_CFile")                      = sVarPre & ".C"
            r.v(sVarPre & "_HFile")                      = sVarPre & ".H"
            r.v(sVarPre & "_Notes")                      = ""

            r.v(sVarPre & "_PARA_ADC")                   = sVarPre & "_ADC"
            r.v(sVarPre & "_PARA_ASC0")                  = sVarPre & "_ASC0"
            r.v(sVarPre & "_PARA_SSC0")                  = sVarPre & "_SSC0"
            r.v(sVarPre & "_PARA_GPT1_2")                = sVarPre & "_GPT1_2"
            r.v(sVarPre & "_PARA_PFM")                   = sVarPre & "_PFM"
            r.v(sVarPre & "_PARA_CC1")                   = sVarPre & "_CC1"
            r.v(sVarPre & "_PARA_CC2")                   = sVarPre & "_CC2"

            If (r.Regs.BitFind("SYSCON3_CC6DIS")) Then
                r.v(sVarPre & "_PARA_CC6")              = sVarPre & "_CC6"
            End If

            If (r.Regs.BitFind("SYSCON3_ASC1DIS")) Then
                r.v(sVarPre & "_PARA_ASC1")              = sVarPre & "_ASC1"
            End If

            If (r.Regs.BitFind("SYSCON3_I2CDIS")) Then
                r.v(sVarPre & "_PARA_I2C")               = sVarPre & "_I2C"
            End If

            If (r.Regs.BitFind("SYSCON3_SDLMDIS")) Then
                r.v(sVarPre & "_PARA_SDLM")                  = sVarPre & "_SDLM"
            End If

            r.v(sVarPre & "_PARA_CAN")                  = sVarPre & "_CAN"
            r.v(sVarPre & "_PARA_SSC1")                  = sVarPre & "_SSC1"

            r.v(sVarPre & "_ReqFreq")                    = 10
            Call UpdateOutputFrequency(r)
            '...
        Case 1
            '...
            Call UpdateOutputFrequency(r)
       'Case...
    End Select

    UpdateProjectData = True
    Exit Function

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

