'#Uses "..\include\Global.inc"
'#Uses "..\include\Const.inc"
'#Uses "..\include\Format.inc"
'#Uses "..\classes\FunctionClass.cls"
'#Uses "..\classes\ParameterClass.cls"
'#Uses "..\include\Port.inc"

Option Explicit

'*****************************************************************************
' Module:
'        SSC
'-----------------------------------------------------------------------------
' Description:
'        This module contains all functions that are used in the 
'        SSC dialog script and in the SSC codegenerator script.
'
'-----------------------------------------------------------------------------
' History:
'                 
'        Rev. Author         Date        Description
'        ----------------------------------------------------------------------
'        1.0    ahe       17.02.00     final version for 
'                                         C165UTAH
'                                         C165H
'                                         C161U
'
'        ----------------------------------------------------------------------
'        2.0    ahe       05.09.00     final version for 
'                                         C167CS
'                                         C161PI
'                                         C161CS/JC/JI
'
'
'        ----------------------------------------------------------------------
'        3.0    ahe       25.10.00     final version for 
'                                         C167CS
'                                         C161PI
'                                         C161CS/JC/JI
'                                         C167CR/SR r2
'
'                                      - changes IsModuleDisabled (check SYSCON3)
'
'               ahe       31.10.00     - changes the description for SendData
'                                      - changes the description for RxDataReady
'
'*****************************************************************************


'*****************************************************************************
' Constants
'*****************************************************************************
Global Const SSC_PRECISION = "0.000"


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

  sVarPre = "SSC"

  ' 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 SSCx_NAME_Init
  '------------------------------------------------------------------------------------------------
  sDescription = GetGeneralInitDescription(sVarPre)
  sReturnValue = "None" 
  If (Not func.AddFunction(sVarPre & "_NAME_Init", "void", sDescription, sReturnValue, 1)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_SendData
  '------------------------------------------------------------------------------------------------
  sDescription = "The master device can initiate the first data transfer by " & _
                 "writing the transmit data into transmit buffer. This value is " & _
                 "copied into the shift register (which is assumed to be empty at " & _
                 "this time), and the selected first bit of the transmit data is placed " & _
                 "onto the MTSR line on the next clock from the baud rate generator. " & vbCrLf & _
                 "A slave device immediately outputs the selected first bit (MSB or LSB " & _
                 "of the transfer data) at pin MRST, when the contents of the transmit " & _
                 "buffer are copied into the slave's shift register. "
  sReturnValue = "None" 
  If (Not func.AddFunction(sVarPre & "_NAME_SendData", "void", sDescription, sReturnValue, 1)) Then Exit Function
    sDescription = "Data to be send"
    If (Not func.AddParameter(sVarPre & "_NAME_SendData_Par1", "uwData", "uword", sDescription)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_GetData
  '------------------------------------------------------------------------------------------------
  sDescription = "This function returns the contents of the receive buffer. " & _
                 "When the receive interrupt request flag is set this implies " & _
		             "that data is available for reading in the receive buffer. "
  sReturnValue = "Received data" 
  If (Not func.AddFunction(sVarPre & "_NAME_GetData", "uword", sDescription, sReturnValue, 1)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_TxBufFree
  '------------------------------------------------------------------------------------------------
  sDescription = "This macro can be used for checking the status of the " & _
               	 "transmit buffer register (" & sVarPre & "TB). The transmit buffer may only " & _
               	 "be written to if it is empty, that means if the previous " & _
               	 "contents of the transmit buffer have been loaded into the " & _
               	 "shift register. "

  sReturnValue = "Returns a 1 if the transmit buffer is empty, else 0" 
  If (Not func.AddFunction(sVarPre & "_NAME_TxBufFree", "", sDescription, sReturnValue, 0)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_RxDataReady
  '------------------------------------------------------------------------------------------------
  sDescription = "This macro can be used for calling the status of the " & sVarPre & " " &  _
                 "receiver interrupt flag (" & sVarPre & "RIC). This is to recognize " & _
                 "that the " & sVarPre & " received data. If data has been received, " & _
                 "the function " & r.v(sVarPre & "_Name_GetData") & " must be called. " 

  sReturnValue = "Returns a 1 if received data is valid, else 0"
  If (Not func.AddFunction(sVarPre & "_NAME_RxDataReady", "", sDescription, sReturnValue, 0)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_ErrorCheck
  '------------------------------------------------------------------------------------------------
  sDescription = "This function checks if an error occured. With the help " & _
               	 "of error flags it is possible to establish the cause of " & _
               	 "errors. " & vbCrLf & _
               	 "The possible values for the retuned error are: " & vbCrLf & _
               	 "Bit 0 = 1   ->  receive error " & vbCrLf & _
               	 "Bit 1 = 1   ->  phase error " & vbCrLf & _
               	 "Bit 2 = 1   ->  baudrate error (only in slave mode) " & vbCrLf & _
               	 "Bit 3 = 1   ->  transmit error (only in slave mode) "

  sReturnValue = "Returns the error code"
  If (Not func.AddFunction(sVarPre & "_NAME_ErrorCheck", "ubyte", sDescription, sReturnValue, 1)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_Tx
  '------------------------------------------------------------------------------------------------
  sDescription = "This interrupt service routine is called when the contents " & _
               	 "of the transmit buffer have been loaded into the shift register. " & _
               	 "This means that the transmit buffer can now be loaded with the " & _
               	 "next data. "  & TOOLTIP_ISR_USERCODE

  sReturnValue = "None"
  If (Not func.AddFunction(sVarPre & "_NAME_Tx", "void", sDescription, sReturnValue, 2)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_Rx
  '------------------------------------------------------------------------------------------------
  sDescription = "This interrupt service routine is called when the contents " & _
            	   "of the shift register have been loaded into the receive buffer. " & _
               	 "The receive buffer must be read before receiving the next data. " & _
               	 "If the receive buffer is not read before receiving new " & _
               	 "data, the receive error flag is set. " & vbCrLf & _
               	 TOOLTIP_ISR_USERCODE 

  sReturnValue = "None"
  If (Not func.AddFunction(sVarPre & "_NAME_Rx", "void", sDescription, sReturnValue, 2)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_Error
  '------------------------------------------------------------------------------------------------
  sDescription = "This interrupt service routine is called when during the " & _
               		sVarPre & " tranfer an error occured. With the help of the error " & _
               		"flags it is possible to find out the exact cause of error. " & _
               		"Possible errors include reveice error, phase error, " & _
               		"baudrate error (only slave) and transmit error (only slave). " & vbCrLf & _
               		TOOLTIP_ISR_USERCODE 

  sReturnValue = "None"
  If (Not func.AddFunction(sVarPre & "_NAME_Error", "void", sDescription, sReturnValue, 2)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_TransData
  '------------------------------------------------------------------------------------------------
  sDescription = "This function initiates a data transfer. This means up to " & _
               		"255 bytes can be sent without application control. The " & _
               		"data transfer must be carried out within the ISR. " & _
               		"Both forwarded pointers can reference the same " & _
               		"buffer, then the sent data is written over. " & _
               		"In slave mode this function may be used to enable the " & _
               		"master to access the data. " & _
               		"This function can only be used if the " & r.v(sVarPre & "_Name_Tx") & " and " & _
               		r.v(sVarPre & "_Name_Rx") & " functions are selected. " 
  sReturnValue = "None"
  If (Not func.AddFunction(sVarPre & "_NAME_TransData", "void", sDescription, sReturnValue, 1)) Then Exit Function
    sDescription = "Pointer to transmit buffer"
    If (Not func.AddParameter(sVarPre & "_NAME_TransData_Par1", "*TxBuffer", "uword", sDescription)) Then Exit Function
    sDescription = "Pointer to receive buffer"
    If (Not func.AddParameter(sVarPre & "_NAME_TransData_Par2", "*RxBuffer", "uword", sDescription)) Then Exit Function
    sDescription = "Size of buffer"
    If (Not func.AddParameter(sVarPre & "_NAME_TransData_Par3", "BufferSize", "ubyte", sDescription)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_Busy
  '------------------------------------------------------------------------------------------------
  sDescription = "This macro may be used for checking the status of the " & _
               		"busy flag (" & sVarPre & "BSY). When a transfer starts, the busy flag " & _
               		"is set. At the end of a transfer (" & sVarPre & "TB is empty) the busy " & _
               		"flag is cleared."
  sReturnValue = "Returns a 1 if " & sVarPre & " is busy, else 0"
  If (Not func.AddFunction(sVarPre & "_NAME_Busy", "", sDescription, sReturnValue, 0)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_EnTransmitter
  '------------------------------------------------------------------------------------------------
  sDescription = "In slave mode a device may only switch its MRST pin to " & _
                 "output mode if chosen by the master (by chip select or " & _
                 "SW command). If the device is not chosen, the MRST pin has " & _
                 "to be switched to input mode (not valid for Wired-AND). " & _
                 "This macro configures the MRST pin as output and so " & _
                 "releases the transmitter function. " & vbCrLf & _
                 "Note: " & vbCrLf & _
                 "This need only apply when several slaves are available in " & _
                 "the system."
  sReturnValue = "None"
  If (Not func.AddFunction(sVarPre & "_NAME_EnTransmitter", "", sDescription, sReturnValue, 0)) Then Exit Function

  '------------------------------------------------------------------------------------------------
  ' Description for SSCx_NAME_DisTransmitter
  '------------------------------------------------------------------------------------------------
  sDescription = "In slave mode a device may only switch its MRST pin to " & _
                 "output mode if chosen by the master (by chip select or " & _
                 "SW command). If the device is not chosen, the MRST pin has " & _
                 "to be switched to input mode (not valid for Wired-AND). " & _
                 "This macro configures the MRST pin as input and so " & _
                 "blocks the transmitter function. " & vbCrLf & _
                 "Note: " & vbCrLf & _
                 "This need only apply when several slaves are available in " & _
                 "the system."
  sReturnValue = "None"
  If (Not func.AddFunction(sVarPre & "_NAME_DisTransmitter", "", sDescription, sReturnValue, 0)) 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 sParaName As String
  Dim i As Integer

  sVarPre = "SSC" & 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

 	
 	If (Not para.Sort) Then Exit Function

  RefreshParameterDescriptions = True
End Function



'*****************************************************************************
'Description:
'         This function updates the SSC baudrate.
'
'-----------------------------------------------------------------------------
'Parameters:
'        r                reference to the Registers object
'
'*****************************************************************************
Sub UpdateSSCBaudrate(r As ProjectData)
    On Error Resume Next
    Dim sVarPre As String
    Dim vBaudrate As Variant
    Dim vIndex As Variant

    sVarPre = "SSC"

    vBaudrate = r.d(sVarPre & "_Baudrate")
      If (vBaudrate < GetSSCMinBaudrate(r)) Then
        vBaudrate = GetSSCMinBaudrate(r)
      End If
      If (vBaudrate > GetSSCMaxBaudrate(r)) Then
        vBaudrate =  GetSSCMaxBaudrate(r)
      End If

    r.d(sVarPre & "_Baudrate") = vBaudrate
    r.l(sVarPre & "BR_" & sVarPre & "BR") = GetSSCModuleClock(r, vIndex) * 1000000 / ( 2 * vBaudrate) - 1

End Sub


'*****************************************************************************
'Description:
'          This function returns the module clock (in MHz) of the 
'          SSC module depending on the configured modes
'-----------------------------------------------------------------------------
'Parameters:
'         r               reference to the Registers object
'         vIndex          ProjectData
'
'-----------------------------------------------------------------------------
'Returns:
'      SSC module clock [MHz]
'
'*****************************************************************************
Function GetSSCModuleClock(r As ProjectData, vIndex As Variant) As Double
  On Error Resume Next

  GetSSCModuleClock = GetSystemClock(r) 

End Function


'*****************************************************************************
'Description:
'          This function returns the minimum baudrate (in kbaud) of the 
'          SSC module depending on the module clock and the configured modes
'-----------------------------------------------------------------------------
'Parameters:
'        r                reference to the Registers object
'
'-----------------------------------------------------------------------------
'Returns:
'      at a minimum possible baud rate [baud]
'
'*****************************************************************************
Function GetSSCMinBaudrate(r As ProjectData) As Double
  On Error Resume Next
  Dim sVarPre As String
  Dim v As String
  Dim vIndex As Variant
  sVarPre = "SSC" 

  GetSSCMinBaudrate = GetSSCModuleClock(r, vIndex) * 1000000 / (2 * (65535 + 1))

End Function


'*****************************************************************************
'Description:
'          This function returns the maximum baudrate (in kbaud) of the 
'          SSC module depending on the module clock and the configured modes
'-----------------------------------------------------------------------------
'Parameters:
'        r                reference to the Registers object
'
'-----------------------------------------------------------------------------
'Returns:
'      at a maximum possible baud rate [baud]
'
'*****************************************************************************
Function GetSSCMaxBaudrate(r As ProjectData) As Double
  On Error Resume Next
  Dim sVarPre As String
  Dim v As String
  Dim vIndex As Variant
  sVarPre = "SSC"  

  If (r.v(sVarPre & "CON_" & sVarPre & "MS") = 0) Then  ' if slave mode
    GetSSCMaxBaudrate = GetSSCModuleClock(r, vIndex) * 1000000 / (2 * (1 + 1))
  Else  ' if master mode
    GetSSCMaxBaudrate = GetSSCModuleClock(r, vIndex) * 1000000 / (2 * (0 + 1))
  End If

End Function


'*****************************************************************************
'Description:
'          This function returns the real baudrate (in kbaud) of the 
'          SSC module depending on the module clock and the configured modes
'-----------------------------------------------------------------------------
'Parameters:
'        r                reference to the Registers object
'
'-----------------------------------------------------------------------------
'Returns:
'      the real-time baud rate [baud]
'
'*****************************************************************************
Function GetSSCRealBaudrate(r As ProjectData) As Double
  On Error Resume Next
  Dim sVarPre As String
  Dim v As String
  Dim vIndex As Variant
  sVarPre = "SSC" 

  GetSSCRealBaudrate = GetSSCModuleClock(r, vIndex) * 1000000 / (2 * (r.v(sVarPre & "BR_" & sVarPre & "BR") + 1))


End Function


'*****************************************************************************
'Description:
'        This function returns a formated disabled tooltip if the module
'        clock is disabled.
'-----------------------------------------------------------------------------
'Parameters:
'        r               reference to the ProjectData object
'        sVarPre         modul name
'-----------------------------------------------------------------------------
'Returns:
'        disabled tooltip
'*****************************************************************************
Function GetTooltipModuleDisabled(r As ProjectData, sVarPre As String) As String
  On Error Resume Next
  
  GetTooltipModuleDisabled = ""            
  GetTooltipModuleDisabled =  GetTooltipModuleDisabled & FormatDisabledToolTip("the module is disabled")

End Function


'*****************************************************************************
'Description:
'        This function check  the SYSCON3 register and SSCEN, 
'        whether the modul is disabled.
'
'-----------------------------------------------------------------------------
'Parameters:
'        r              As ProjectData
'        sVarPre        modul name
'
'-----------------------------------------------------------------------------
'Returns:
'        disabled tooltip    
'*****************************************************************************
Function  GetTooltipSSCModuleDisabled(r As ProjectData, sVarPre As String) As String
  On Error Resume Next

  Dim a As String
  a = ""

  If (IsModuleDisabled(r, sVarPre)) Then
    a = a & GetTooltipModuleDisabled(r, sVarPre)
  End If

  If (r.v("SSCCON_SSCEN") = 0) Then
    a = a & FormatDisabledToolTip("MRST, MTSR and SCLK pin's are not used")
  End If
  GetTooltipSSCModuleDisabled = a

End Function 


'*****************************************************************************
'Description:
'        This function check  the SYSCON3 register, whether the modul is disabled
'-----------------------------------------------------------------------------
'Parameters:
'        r               As ProjectData
'        sVarPre         modul name (e.g SSC)
'-----------------------------------------------------------------------------
'Returns:
'        True  -  if the modul is disabled
'        False -  else
'
'*****************************************************************************
Function IsModuleDisabled(r As ProjectData, sVarPre As String) As Boolean

  IsModuleDisabled = False

  If Not(GetSSCDisebleBitName(r, sVarPre) = "") Then
      If (r.v("SYSCON3_" & GetSSCDisebleBitName(r, sVarPre)) = 1) Then
        IsModuleDisabled = True
      End If
  End If

End Function



'*****************************************************************************
'Description:
'        This function checks if all error checks are disabled
'-----------------------------------------------------------------------------
'Parameters:
'        r      As ProjectData
'-----------------------------------------------------------------------------
'Returns:
'       False       if all error cheks disabled
'       True        else
'*****************************************************************************
Function IsErrorCheckDisabled(r As ProjectData) As Boolean
  On Error Resume Next
  Dim sVarPre As String
  sVarPre = "SSC"
  
  IsErrorCheckDisabled = False            
  If (r.v(sVarPre & "CON_" & sVarPre & "TEN_TE") = 0 AND _
      r.v(sVarPre & "CON_" & sVarPre & "REN_RE") = 0 AND _
      r.v(sVarPre & "CON_" & sVarPre & "PEN_PE") = 0 AND _
      r.v(sVarPre & "CON_" & sVarPre & "BEN_BE") = 0 ) Then

    IsErrorCheckDisabled = True
  End If
End Function



'*****************************************************************************
'Description:
'          This function checks if none error enabled. Is so then release this
'          interrupt (SSCEIC_SSCEIE).
'
'-----------------------------------------------------------------------------
'Parameters:
'        r  ProjectData  
'
'*****************************************************************************

Sub ReleaseErrorInterrupt(r As ProjectData)
    On Error Resume Next
    Dim sVarPre As String

    sVarPre = "SSC"

    If (r.v(sVarPre & "CON_" & sVarPre & "TEN_TE") = 0 AND _
        r.v(sVarPre & "CON_" & sVarPre & "REN_RE") = 0 AND _
        r.v(sVarPre & "CON_" & sVarPre & "PEN_PE") = 0 AND _
        r.v(sVarPre & "CON_" & sVarPre & "BEN_BE") = 0 ) Then

        Call DisableSRN(r, sVarPre, "SSCEIC", "SSCEIE" , "Error")
        r.v("SSC_USE_ErrorCheck") = 0
    End If

End Sub

'*****************************************************************************
'Description:
'        This function set the SSC-Modul into the devault.
'-----------------------------------------------------------------------------
'Parameters:
'        r      As ProjectData
'
'*****************************************************************************
Sub  SetSSCDefault(r As ProjectData)
  On Error Resume Next
  Dim sVarPre As String

  sVarPre = "SSC_USE_"

  If r.v("SSCCON_SSCMS") = 0 Then
    Call ReleaseAlternateOutputPin(r, "MRST_O")
    Call ReleaseAlternateInputPin(r, "MTSR_I")
    Call ReleaseAlternateInputPin(r, "SCLK_I")
  Else
    Call ReleaseAlternateInputPin(r, "MRST_I")
    Call ReleaseAlternateOutputPin(r, "MTSR_O")
    Call ReleaseAlternateOutputPin(r, "SCLK_O")
  End If

  'default control page
  r.v("SSCCON_SSCBM_BC") = 7             'SSCBM Reg = 1 => 8 bit Data

  r.v("SSCCON_SSCHB") = 0
  r.v("SSCCON_SSCPH") = 0
  r.v("SSCCON_SSCPO") = 0
  Call DisableSRN(r, "SSC", "SSCTIC", "SSCTIE", "Tx")
  Call DisableSRN(r, "SSC", "SSCRIC", "SSCRIE", "Rx")
  r.v("SSCCON_SSCTEN_TE") = 0
  r.v("SSCCON_SSCREN_RE") = 0
  r.v("SSCCON_SSCPEN_PE") = 0
  r.v("SSCCON_SSCBEN_BE") = 0
  r.v("SSCCON_SSCAREN_BSY") = 0
  Call ReleaseErrorInterrupt(r)    'unbedingt hier, da ErrorInterrupt muss erst = 0 sein

  'default function page
  r.v(sVarPre & "Init") = 0
  r.v(sVarPre & "SendData") = 0
  r.v(sVarPre & "GetData") = 0
  r.v(sVarPre & "TxBufFree") = 0
  r.v(sVarPre & "RxDataReady") = 0
  r.v(sVarPre & "ErrorCheck") = 0
  r.v(sVarPre & "TransData") = 0
  r.v(sVarPre & "Busy") = 0
  r.v(sVarPre & "EnTransmitter") = 0
  r.v(sVarPre & "DisTransmitter") = 0
  
  
  'default baud rat page
  r.v("SSC_Baudrate") = 100000
  Call UpdateSSCBaudrate(r)

End Sub 

'*****************************************************************************
'Description:
'        This function returns the disable bit name of SYSCON3 register (e.g SSCDIS).
'-----------------------------------------------------------------------------
'Parameters:
'        r               reference to the ProjectData object
'        sVarPre         module name
'
'-----------------------------------------------------------------------------
'Returns:
'       disable bit name
'*****************************************************************************
Function GetSSCDisebleBitName(r As ProjectData, sVarPre As String) As String
    On Error Resume Next

    If (r.Regs.BitFind("SYSCON3_SSCDIS") = True) Then
        GetSSCDisebleBitName = "SSCDIS"
    ElseIf (r.Regs.BitFind("SYSCON3_PERDIS2") = True) Then
        GetSSCDisebleBitName = "PERDIS2"
    Else
        GetSSCDisebleBitName = ""
    End If


End Function

'*****************************************************************************
'Description:
'        This function check the SSCCON_SSCEN => pins not used
'-----------------------------------------------------------------------------
'Parameters:
'        r               As ProjectData
'        sVarPre         modul name (e.g SSC)
'-----------------------------------------------------------------------------
'Returns:
'        True  -  if SSCEN = 0 => pins not used
'        False -  else
'
'*****************************************************************************
Function IsPinInterfaceDeselected(r As ProjectData, sVarPre As String) As Boolean

  IsPinInterfaceDeselected = False

  If (r.v("SSCCON_SSCEN") = 0) Then
    IsPinInterfaceDeselected = True
  End If

End Function

'*****************************************************************************
'Description:
'        This function returns tooltip if the pins not use.
'
'-----------------------------------------------------------------------------
'Parameters:
'        r              As ProjectData
'        sVarPre        modul name
'
'-----------------------------------------------------------------------------
'Returns:
'        Formated tooltip    
'*****************************************************************************
Function  GetTooltipPinInterfaceDisabled(r As ProjectData, sVarPre As String) As String
  On Error Resume Next

  Dim a As String
  a = ""
  a = a & FormatDisabledToolTip("MRST, MTSR and SCLK pin's are not used")

  GetTooltipPinInterfaceDisabled = a

End Function 


