'#Uses "..\include\Global.inc"
'#Uses "..\include\Const.inc"
'#Uses "..\include\Format.inc"
'#Uses "..\include\Port.inc"
'#Uses "..\classes\FunctionClass.cls
'#Uses "..\classes\ParameterClass.cls
Option Explicit
'*****************************************************************************
' Module:
'        SDLM
'-----------------------------------------------------------------------------
' Description:
'        This module contains all functions that are used in the 
'        SDLM dialog script and in the SDLM codegenerator script.
'
'-----------------------------------------------------------------------------
' History:
'                 
'        Rev. Author         Date        Description
'        ---------------------------------------------------------------------
'        1.0  rkt            04.01.00    final version for TC1775A
'        ---------------------------------------------------------------------
'        1.1  rkt            04.01.00    error corrections
'
'        ---------------------------------------------------------------------
'        1.0  ahe            15.09.00    final version for C161JC/JI
'
'
'*****************************************************************************


'*****************************************************************************
' @Constants
'*****************************************************************************


'*****************************************************************************
' @Function descriptions
'*****************************************************************************

'*****************************************************************************
'Description:
'        For each function which should be used for this module a line 
'        "If (Not func.AddFunction .." must be insert in this function.
'        For each parameter that should be used for this function a  
'        line "If (Not func.AddParameter .." must be insert in this function.
'
'        Note:
'        For each added function a project variable with the name 
'        "SDLM_NAME_Functionname" must be exist in the *.vars file. 
'-----------------------------------------------------------------------------
'Parameters:
'        func             reference to the FunctionClass object
'        r                reference to the Registers object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function RefreshFunctionDescriptions(vIndex As Variant, func As FunctionClass, r As ProjectData) As Boolean
  On Error Resume Next 

  RefreshFunctionDescriptions = False

  Dim sDescription As String
  Dim sReturnValue As String
  Dim sIndex As String
  Dim sPrefix As String
  Dim i As Integer

  sIndex = "SDLM" & vIndex
  sPrefix = sIndex & "_"


  ' for each function of this module the property AddFunction must be called
  '
  ' AddFunction(sFuncName As String, sFuncType As String, sFuncDescription As String, 
  '             sReturnvalue As String, lSort As Long) As Boolean
  '
  ' sFuncName          | String | function name as key (use the name of the variable 
  '                               for the function name e.g. SSC_NAME_Init) 
  ' sFuncType          | String | type of the function
  ' sFuncDescription   | String | description of the function
  ' sReturnvalue       | String | description of the return value
  ' lSort              | Long   | ' sort of the function (0 => macro, 1 => function, 2 => ISR, 3 => TRAP)

    ' for each parameter of a function the property AddParameter must be called
    '
    'AddParameter(sParName As String, sPar As String, sParType As String, sParDescription As String) As Boolean    
    '
    ' sParName         | String | parameter name (key)
    ' sPar             | String | parameter name
    ' sParType         | String | type of the parameter
    ' sParDescription  | String | description of the parameter


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_Init
  '------------------------------------------------------------------------------------------------
  sDescription = GetGeneralInitDescription(sIndex)
  sReturnValue = "None" 
  If (Not func.AddFunction(sIndex & "_NAME_Init", "void", sDescription, sReturnValue, 1)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_ReceiveBufferValid
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro should be used before calling" & vbCrLf & _
    r.v(sIndex & "_NAME_ReadReceiveBuffer") & " or " & vbCrLf & _
    r.v(sIndex & "_NAME_ReadReceiveFIFO") & vbCrLf & _
    "in order to check if the receive buffer" & vbCrLf & _
    "contains valid data."

  sReturnValue = "1 if receive buffer is valid, else 0"
  If (Not func.AddFunction(sIndex & "_NAME_ReceiveBufferValid", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_TransmitInProgress
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro should be used before calling" & vbCrLf & _
    r.v(sIndex & "_NAME_TransmitBuffer") & " or " & vbCrLf & _
    r.v(sIndex & "_NAME_TransmitFIFO") & vbCrLf & _
    "in order to check if the transmission of" & vbCrLf & _
    "data is possible." & vbCrLf & _
    ""

  sReturnValue = "1 if a transmission is in progress, else 0"
  If (Not func.AddFunction(sIndex & "_NAME_TransmitInProgress", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_ReceptionInProgress
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro checks if a reception is in progress."

  sReturnValue = "1 if a reception is in progress, else 0"
  If (Not func.AddFunction(sIndex & "_NAME_ReceptionInProgress", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_SingleByteHeader
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro can be used to determine the" & vbCrLf & _
    "header type. It must be called immidiately" & vbCrLf & _
    "after a header had been received."

  sReturnValue = "1 for single byte headers, else 0"
  If (Not func.AddFunction(sIndex & "_NAME_SingleByteHeader", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_IFRNotAllowed
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro can be used to determine if" & vbCrLf & _
    "IFR is allowed. It must be called immidiately" & vbCrLf & _
    "after a header had been received."

  sReturnValue = "1 if an IFR is not allowed, else 0"
  If (Not func.AddFunction(sIndex & "_NAME_IFRNotAllowed", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_ReadReceiveBuffer
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This function copys received data from the" & vbCrLf & _
    "receive buffer into ubBuffer." & vbCrLf & _
    "Note:" & vbCrLf & _
    "The parameter ubBuffer must always be" & vbCrLf & _
    "declared with a length of 11."

  sReturnValue = "the number of valid bytes"
  If (Not func.AddFunction(sIndex & "_NAME_ReadReceiveBuffer", "ubyte", sDescription, sReturnValue, 1)) Then Exit Function
    sDescription = "buffer to retrieve the received data."
    If (Not func.AddParameter(sIndex & "_NAME_ReadReceiveBuffer_Par1", "*ubBuffer", "ubyte", sDescription)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_ReadReceiveFIFO
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This function copys received data from the" & vbCrLf & _
    "receive buffer into ubBuffer using the FIFO mode." & vbCrLf & _
    "Note:" & vbCrLf & _
    "The parameter ubBuffer must always be" & vbCrLf & _
    "declared with a length of 11."

  sReturnValue = "the number of valid bytes"
  If (Not func.AddFunction(sIndex & "_NAME_ReadReceiveFIFO", "ubyte", sDescription, sReturnValue, 1)) Then Exit Function
    sDescription = "buffer to retrieve the received data."
    If (Not func.AddParameter(sIndex & "_NAME_ReadReceiveFIFO_Par1", "*ubBuffer", "ubyte", sDescription)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_TransmitBuffer
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This functions copys the first ubLen bytes of" & vbCrLf & _
    "ubBuffer into the transmit buffer and initiates" & vbCrLf & _
    "a data transmission." & vbCrLf & _
    "Note:" & vbCrLf & _
    "The parameter ubBuffer must always be" & vbCrLf & _
    "declared with a length of 11."

  sReturnValue = "1 if transmission successfully started, else 0"
  If (Not func.AddFunction(sIndex & "_NAME_TransmitBuffer", "ubyte", sDescription, sReturnValue, 1)) Then Exit Function
    sDescription = "buffer with transmit data."
    If (Not func.AddParameter(sIndex & "_NAME_TransmitBuffer_Par1", "*ubBuffer", "ubyte", sDescription)) Then Exit Function
    sDescription = "lenght of buffer (number of bytes to be transmitted)"
    If (Not func.AddParameter(sIndex & "_NAME_TransmitBuffer_Par2", "ubLen", "ubyte", sDescription)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_TransmitFIFO
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This functions copys the first ubLen bytes of" & vbCrLf & _
    "ubBuffer into the transmit buffer and initiates" & vbCrLf & _
    "a data transmission using FIFO mode."

  sReturnValue = "1 if transmission successfully started, else 0"
  If (Not func.AddFunction(sIndex & "_NAME_TransmitFIFO", "ubyte", sDescription, sReturnValue, 1)) Then Exit Function
    sDescription = "buffer with transmit data."
    If (Not func.AddParameter(sIndex & "_NAME_TransmitFIFO_Par1", "*ubBuffer", "ubyte", sDescription)) Then Exit Function
    sDescription = "lenght of buffer (number of bytes to be transmitted)"
    If (Not func.AddParameter(sIndex & "_NAME_TransmitFIFO_Par2", "ubLen", "ubyte", sDescription)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_EnableAutomaticIFR
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This function enables the automatic transmission" & vbCrLf & _
    "of a one byte IFR without CRC generation for frame" & vbCrLf & _
    "types 1, 2 with 3 byte headers." & vbCrLf & _
    "This function must only be called once except" & vbCrLf & _
    "when " & r.v(sIndex & "_NAME_DisableAutomaticIFR") & "," & vbCrLf & _
    r.v(sIndex & "_NAME_TransmitOneByteIFR") & "," & vbCrLf & _
    r.v(sIndex & "_NAME_TransmitIFR") & " or" & vbCrLf & _
    r.v(sIndex & "_NAME_TransmitIFRFIFO") & " have been called." & vbCrLf & _
    ""

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_EnableAutomaticIFR", "void", sDescription, sReturnValue, 1)) Then Exit Function
    sDescription = "one byte IFR value"
    If (Not func.AddParameter(sIndex & "_NAME_EnableAutomaticIFR_Par1", "ubIFR", "ubyte", sDescription)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_DisableAutomaticIFR
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro disables the automatic transmission" & vbCrLf & _
    "of a one byte IFR."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_DisableAutomaticIFR", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_TransmitOneByteIFR
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This function transmits a one byte IFR for frame" & vbCrLf & _
    "types 1, 2 for 1-byte and 3-byte headers with no" & vbCrLf & _
    "CRC generation." & vbCrLf & _
    "To transmit the IFR this function must be called" & vbCrLf & _
    "immidiately after a header had been received." & vbCrLf & _
    "Note:" & vbCrLf & _
    "After this function have been called, automatic" & vbCrLf & _
    "IFR for frame types 1, 2 with 3-byte headers is" & vbCrLf & _
    "enabled. To disable the automatic IFR call" & vbCrLf & _
    r.v(sIndex & "_NAME_DisableAutomaticIFR") & " after" & vbCrLf & _
    "the complete transmission."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_TransmitOneByteIFR", "void", sDescription, sReturnValue, 1)) Then Exit Function
    sDescription = "one byte IFR value"
    If (Not func.AddParameter(sIndex & "_NAME_TransmitOneByteIFR_Par1", "ubIFR", "ubyte", sDescription)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_TransmitIFR
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This function transmits an IFR specified by ubBuffer" & vbCrLf & _
    "with a length of ubLen for all frame types with " & vbCrLf & _
    "1-byte and 3-byte headers." & vbCrLf & _
    "To transmit the IFR this function must be called" & vbCrLf & _
    "immidiately after a header had been received." & vbCrLf & _
    "Note:" & vbCrLf & _
    "The parameter ubBuffer must always be" & vbCrLf & _
    "declared with a length of 11."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_TransmitIFR", "void", sDescription, sReturnValue, 1)) Then Exit Function
    sDescription = "buffer with IFR data."
    If (Not func.AddParameter(sIndex & "_NAME_TransmitIFR_Par1", "*ubBuffer", "ubyte", sDescription)) Then Exit Function
    sDescription = "lenght of buffer (number of bytes to be transmitted)"
    If (Not func.AddParameter(sIndex & "_NAME_TransmitIFR_Par2", "ubLen", "ubyte", sDescription)) Then Exit Function
    sDescription = "1 to generate IFR-CRC, else 0"
    If (Not func.AddParameter(sIndex & "_NAME_TransmitIFR_Par3", "ubCRC", "ubyte", sDescription)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_TransmitIFRFIFO
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This function transmits an IFR specified by ubBuffer" & vbCrLf & _
    "with a length of ubLen for all frame types with " & vbCrLf & _
    "1-byte and 3-byte headers using FIFO mode." & vbCrLf & _
    "To transmit the IFR this function must be called" & vbCrLf & _
    "immidiately after a header had been received."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_TransmitIFRFIFO", "void", sDescription, sReturnValue, 1)) Then Exit Function
    sDescription = "buffer with IFR data."
    If (Not func.AddParameter(sIndex & "_NAME_TransmitIFRFIFO_Par1", "*ubBuffer", "ubyte", sDescription)) Then Exit Function
    sDescription = "lenght of buffer (number of bytes to be transmitted)"
    If (Not func.AddParameter(sIndex & "_NAME_TransmitIFRFIFO_Par2", "ubLen", "ubyte", sDescription)) Then Exit Function
    sDescription = "1 to generate IFR-CRC, else 0"
    If (Not func.AddParameter(sIndex & "_NAME_TransmitIFRFIFO_Par3", "ubCRC", "ubyte", sDescription)) Then Exit Function



  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_SendBreak
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro initiates the transmission of" & vbCrLf & _
    "a break."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_SendBreak", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_ResetBreakReceived
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro resets the break received flag." & vbCrLf & _
    "Note:" & vbCrLf & _
    "The break received flag must be reset by software."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_ResetBreakReceived", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_ResetArbitrationLoss
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro resets the arbitration loss flag." & vbCrLf & _
    "Note:" & vbCrLf & _
    "The arbitration loss flag is only reset by" & vbCrLf & _
    "hardware if the arbitration has been won or" & vbCrLf & _
    "the transmission has been aborted."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_ResetArbitrationLoss", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_ResetTransmittedStatus
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro resets the message transmitted flag." & vbCrLf & _
    "Note:" & vbCrLf & _
    "The message transmitted flag must be reset by software."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_ResetTransmittedStatus", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_ResetReceivedAndMessLostStatus
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro resets the message received and" & vbCrLf & _
    "message lost status flags." & vbCrLf & _
    "Note:" & vbCrLf & _
    "If " & r.v(sIndex & "_NAME_ReadReceiveBuffer") & " or" & vbCrLf & _
    r.v(sIndex & "_NAME_ReadReceiveFIFO") & vbCrLf & _
    "are used to get the received data this macro" & vbCrLf & _
    "must not be used."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_ResetReceivedAndMessLostStatus", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_ResetBusStatus
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro resets the bus status flags." & vbCrLf & _
    "Note:" & vbCrLf & _
    "The bus status flags except the bus idle" & vbCrLf & _
    "flag must be reset by software."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_ResetBusStatus", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_ResetErrorFlags
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro resets the error flags." & vbCrLf & _
    "Note:" & vbCrLf & _
    "The error flags must be reset by software."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_ResetErrorFlags", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_GetStartOfFramePointer
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro can be used in block mode to" & vbCrLf & _
    "determine the position of the first new" & vbCrLf & _
    "byte of a frame in the 16-byte receive buffer."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_GetStartOfFramePointer", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_SetTxData
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro writes a byte into the" & vbCrLf & _
    "transmit FIFO."

  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_SetTxData", "", sDescription, sReturnValue, 0)) Then Exit Function
    sDescription = "byte to be written into the FIFO"
    If (Not func.AddParameter(sIndex & "_NAME_SetTxData_Par1", "ub", "", sDescription)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_GetRxData
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro reads a byte from the receive FIFO."

  sReturnValue = "the next byte from the receive FIFO"
  If (Not func.AddFunction(sIndex & "_NAME_GetRxData", "", sDescription, sReturnValue, 0)) Then Exit Function


  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_GetStatus0
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro returns the contents of the buffer and transmission status " & _
    "registers. The two high bytes contains the transmission status register (TRASSTAT) and the two lower bytes " & _
    "contains the buffer status register (BUFFSTAT)"

  sReturnValue = "the contents of the buffer and transmission status registers"
  If (Not func.AddFunction(sIndex & "_NAME_GetStatus0", "ulong", sDescription, sReturnValue, 1)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_GetStatus1
  '------------------------------------------------------------------------------------------------
  sDescription = _
    "This macro returns the contents of the bus and error status " & _
    "registers. The two high bytes contains the error status register (ERRSTAT) and the two lower bytes " & _
    "contains the bus status register (BUSSTAT)"

  sReturnValue = "the contents of the buffer and transmission status registers"

  sReturnValue = "the contents of the bus and error status registers"
  If (Not func.AddFunction(sIndex & "_NAME_GetStatus1", "ulong", sDescription, sReturnValue, 1)) Then Exit Function



  '------------------------------------------------------------------------------------------------
  ' Description for SDLMx_NAME_SRNx
  '------------------------------------------------------------------------------------------------
  sDescription = "This is the interrupt service routine for the Service " & _
  	               "Request Node of the " & sIndex & " module. " & vbCrLf & _
               		TOOLTIP_ISR_USERCODE 
  sReturnValue = "None"
  If (Not func.AddFunction(sIndex & "_NAME_SDLM", "void", sDescription, sReturnValue, 2)) Then Exit Function

 	If (Not func.Sort) Then Exit Function

  RefreshFunctionDescriptions = True
End Function


'*****************************************************************************
'Description:
'        For each parameter that should be used as a constant (on page "Parameters")  
'        a line "If (Not func.AddParameter .." must be insert in this function.
'
'        Note:
'        For each added parameter a project variable with the name 
'        "DUMMY_PARA_Parametername" must be exist in the *.vars file. 
'-----------------------------------------------------------------------------
'Parameters:
'        vIndex           parameter of the module which was added with AddModule
'        func             reference to the FunctionClass object
'        r                reference to the Registers object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function RefreshParameterDescriptions(vIndex As Variant, para As ParameterClass, r As ProjectData) As Boolean
  On Error Resume Next 

  RefreshParameterDescriptions = False

  Dim sDescription As String
  Dim sVarPre As String
  Dim sRegPre As String
  Dim i As Integer
  Dim n As String

  sVarPre = "SDLM" & vIndex
  sRegPre = sVarPre & "_"


  ' for each parameter of this module the property AddParameter must be called
  '
  ' AddParameter(sParameterName As String, sParameterDescription As String) As Boolean
  '
  ' sParameterName         | String | parameter name as key (use the name of the variable 
  '                                   for the parameter name e.g. SSC_PARA_MODE) 
  ' sParameterDescription  | String | description of the parameter


'  n = "SOURCE_AUTOSCAN"
'  sDescription = "Requested source was autoscan"
'  If (Not para.AddParameter(sVarPre & "_PARA_" & n, sDescription)) Then Exit Function
'
'
'
'
' 	If (Not para.Sort) Then Exit Function

  RefreshParameterDescriptions = True
End Function


'*****************************************************************************
' @Functions
'*****************************************************************************

'*****************************************************************************
'Description:
'          This function returns the module clock [MHz] of the 
'          SDLM module depending on the configured modes
'-----------------------------------------------------------------------------
'Parameters:
'        r                reference to the Registers object
'        vIndex           ParameterValue
'-----------------------------------------------------------------------------
'Returns:
'      input clock for SDLM [MHz]
'
'*****************************************************************************
Function GetSDLMModuleClock(r As ProjectData, vIndex As Variant) As Double
  On Error Resume Next
  GetSDLMModuleClock = GetSystemClock(r) 
End Function



