'#Uses "..\classes\Port.cls
'#Uses "..\classes\PortPin.cls
Option Explicit
'*****************************************************************************
' Module:
'        IO
'-----------------------------------------------------------------------------
' Description:
'        This file contains the 'Update' functions for the module.
'
'-----------------------------------------------------------------------------
' History:
'                 
'        Rev. Author         Date        Description
'        ----------------------------------------------------------------------
'        1.0  ste            02.02.00    final version
'
'        ---------------------------------------------------------------------
'        3.0  ahe            02.02.00    final version for C161PI
'                                        - changes 'As PortPin' to 'As Object'
'        ---------------------------------------------------------------------
'        4.0  ahe            23.05.01    final version for Pegasus
'                                         - 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

    Dim sIndex As String
    Dim sPrefix As String

    Dim cPorts As DAvECollection
    Dim Port As Port
    Dim cPins As Object
    Dim sPin As String
    Dim iPin As Integer

    Set cPorts = ObjectCollection("PORTS")
    Set cPins = ObjectCollection("PORTPINS")

    sIndex = "IO" ' & vIndex
    sPrefix = sIndex & "_"

    UpdateProjectData = False

    Select Case lngUpdateDescriptor
        Case 0 
            r.v(sIndex & "_NAME_Init") = sIndex & "_vInit"
            r.v(sIndex & "_NAME_ReadPin") = sIndex & "_ubReadPin"
            r.v(sIndex & "_NAME_SetPin") = sIndex & "_vSetPin"
            r.v(sIndex & "_NAME_ResetPin") = sIndex & "_vResetPin"
            r.v(sIndex & "_NAME_TogglePin") = sIndex & "_vTogglePin"
            r.v(sIndex & "_NAME_SetPinIn") = sIndex & "_vSetPinIn"
            r.v(sIndex & "_NAME_SetPinOut") = sIndex & "_vSetPinOut"
            r.v(sIndex & "_NAME_ReadPort") = sIndex & "_uwReadPort"
            r.v(sIndex & "_NAME_WritePort") = sIndex & "_vWritePort"
            r.v(sIndex & "_NAME_SetPortIn") = sIndex & "_vSetPortIn"
            r.v(sIndex & "_NAME_SetPortOut") = sIndex & "_vSetPortOut"
            r.v(sIndex & "_CFile") = sIndex & ".C"
            r.v(sIndex & "_HFile") = sIndex & ".H"
            r.v(sIndex & "_Notes") = "" 

            For Each Port In cPorts
              For iPin = 0 To 15
                sPin = "P" & Port.PortNumber & "_" & iPin
                If (cPins.Use(sPin) = TRUE) Then
                    r.v(sIndex & "_PARA_" & sPin) = sIndex & "_" & sPin
                End If
              Next iPin
              r.v(sIndex & "_P" & Port.PortNumber & "_Notes") = ""
            Next Port


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

    UpdateProjectData = True
    Exit Function

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

