⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cls9859evbd.cls

📁 AD9954源码
💻 CLS
📖 第 1 页 / 共 5 页
字号:

Public Property Let Reset_DUT1(ByVal vData As adiBinValues)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.D4 = Form1
    Dim wPwdwn As Boolean
    If mvarEnabled Then
        'mvarD4 = vData
        
        'Set the bit value
        SetBitVal evb59Buff2, bnReset_DUT1, vData
'        'Write the value to the buffer
'        WriteEvbBuffVal evb59Buff2
        
        'If the reset line is going from 0 to a 1
        If mvarReset_DUT1 = abvHigh And vData = abvLow Then
            
            'If either of the major powerdown bits are high then the dut was powered down
            If sGetRegMapBitVal(1, 0, 7) = abvHigh Or sGetNewRegMapBitVal(1, 0, 4) = abvHigh Then
                wPwdwn = True
            Else
                wPwdwn = False
            End If
            
            'Clear out the register map buffers
            ResetREGMAP (1)
            RaiseEvent ResetOccured(1, wPwdwn)
            mvarLSBFirstDUT1 = False
            mvarSerialIOModeDUT1 = TwoWire
        End If
        mvarReset_DUT1 = vData
    
    End If
End Property


Public Property Get Reset_DUT1() As adiBinValues
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.D4
    Reset_DUT1 = GetBitVal(evb59Buff2, bnReset_DUT1)
End Property



Public Property Let ClkMdSel_DUT1(ByVal vData As adiBinValues)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.D3 = Form1
    If mvarEnabled Then
        'mvarD3 = vData
        
        'Set the bit value
        SetBitVal evb59Buff2, bnClkMdSel_DUT1, vData
'        'Write the value to the buffer
'        WriteEvbBuffVal evb59Buff2
        
        'Latch the data through the buffer
'        Clock_D = abvHigh
'        Clock_D = abvLow
    End If
End Property


Public Property Get ClkMdSel_DUT1() As adiBinValues
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.D3
    ClkMdSel_DUT1 = GetBitVal(evb59Buff2, bnClkMdSel_DUT1)
End Property



Public Property Let PwrDwnCtl_Dut2(ByVal vData As adiBinValues)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.D2 = Form1
    If mvarEnabled Then
        'mvarD2 = vData
        
        'Set the bit value
        SetBitVal evb59Buff2, bnPwrDwnCtl_DUT2, vData
'        'Write the value to the buffer
'        WriteEvbBuffVal evb59Buff2
        
        'Latch the data through the buffer
'        Clock_D = abvHigh
'        Clock_D = abvLow
    End If
End Property


Public Property Get PwrDwnCtl_Dut2() As adiBinValues
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.D2
    PwrDwnCtl_Dut2 = GetBitVal(evb59Buff2, bnPwrDwnCtl_DUT2)
End Property



Public Property Let PwrDwnCtl_Dut1(ByVal vData As adiBinValues)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.D1 = Form1
    If mvarEnabled Then
        'mvarD1 = vData
        
        'Set the bit value
        SetBitVal evb59Buff2, bnPwrDwnCtl_DUT1, vData
'        'Write the value to the buffer
'        WriteEvbBuffVal evb59Buff2
        
        'Latch the data through the buffer
'        Clock_D = abvHigh
'        Clock_D = abvLow
    End If
End Property


Public Property Get PwrDwnCtl_Dut1() As adiBinValues
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.D1
    PwrDwnCtl_Dut1 = GetBitVal(evb59Buff2, bnPwrDwnCtl_DUT1)
End Property

Public Property Let IOSync_DUT2(ByVal vData As adiBinValues)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.D0 = Form1
    If mvarEnabled Then
        'mvarD0 = vData
        
        'Set the bit value
        SetBitVal evb59Buff2, bnIOSync_DUT2, vData
'        'Write the value to the buffer
'        WriteEvbBuffVal evb59Buff2
        
        'Latch the data through the buffer
'        Clock_D = abvHigh
'        Clock_D = abvLow
    End If
End Property


Public Property Get IOSync_DUT2() As adiBinValues
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.D0
    IOSync_DUT2 = GetBitVal(evb59Buff2, bnIOSync_DUT2)   'mvarD0
End Property

Private Sub Class_Initialize()
    Dim cntr As Integer
        
    'Setup the lptio class
    Set PPIO = New clsLPTIO
    
    mvarEnabled = True
    mvarLSBFirst = False
    'Default value for AutoFUD mode is on.
    mvarAutoFUD = True
    
    'Initialize the bitvals array
    For cntr = 0 To 7
        evbBitVals(cntr) = 2 ^ cntr
    Next cntr
    
    'Initialize the OldResetDUT1Val & OldResetDUT2Val variable
    OldResetDUT1Val = abvLow
    OldResetDUT2Val = abvLow
    
    mvar_DUTsDetected = 0
    
    'Initialize the serial mode register size lookup table,
    'sizes are in number of bytes
    sRegSize(smCFR1) = 4
    sRegSize(smCFR2) = 3
    sRegSize(smASF) = 2
    sRegSize(smARR) = 1
    sRegSize(smFTW0) = 4
    sRegSize(smPOW0) = 2
    sRegSize(smFTW1) = 4
    sRegSize(smRSCW0) = 5
    sRegSize(smRSCW1) = 5
    sRegSize(smRSCW2) = 5
    sRegSize(smRSCW3) = 5
    sRegSize(smRAM) = 4
    sRegSize(smTR) = 4
    
    mvarAutoFUD_DUT1 = True
    mvarAutoFUD_DUT2 = True
    
    'Reset the register map to its initial values
    'Initialize the register map
    'Clear out the register map values for DUT1
    sRegMapVals(0, 0) = String(32, "0")
    sRegMapVals(0, 1) = String(24, "0")
    sRegMapVals(0, 2) = String(16, "0")
    sRegMapVals(0, 3) = String(8, "0")
    sRegMapVals(0, 4) = String(24, "0")
    sRegMapVals(0, 5) = String(16, "0")
    sRegMapVals(0, 6) = String(32, "0")
    sRegMapVals(0, 7) = String(40, "0")
    sRegMapVals(0, 8) = String(40, "0")
    sRegMapVals(0, 9) = String(40, "0")
    sRegMapVals(0, 10) = String(40, "0")
    sRegMapVals(0, 11) = String(32, "0")
    sRegMapVals(0, 12) = cbaseDec2Bin(&H59000800, 32)

    'Clear out the register map values for DUT2
    sRegMapVals(1, 0) = String(32, "0")
    sRegMapVals(1, 1) = String(24, "0")
    sRegMapVals(1, 2) = String(16, "0")
    sRegMapVals(1, 3) = String(8, "0")
    sRegMapVals(1, 4) = String(24, "0")
    sRegMapVals(1, 5) = String(16, "0")
    sRegMapVals(1, 6) = String(32, "0")
    sRegMapVals(1, 7) = String(40, "0")
    sRegMapVals(1, 8) = String(40, "0")
    sRegMapVals(1, 9) = String(40, "0")
    sRegMapVals(1, 10) = String(40, "0")
    sRegMapVals(1, 11) = String(32, "0")
    sRegMapVals(1, 12) = cbaseDec2Bin(&H59000800, 32)

    'Initialize the register map
    'Clear out the register map values for DUT1
    sRegMapValsNew(0, 0) = String(32, "0")
    sRegMapValsNew(0, 1) = String(24, "0")
    sRegMapValsNew(0, 2) = String(16, "0")
    sRegMapValsNew(0, 3) = String(8, "0")
    sRegMapValsNew(0, 4) = String(24, "0")
    sRegMapValsNew(0, 5) = String(16, "0")
    sRegMapValsNew(0, 6) = String(32, "0")
    sRegMapValsNew(0, 7) = String(40, "0")
    sRegMapValsNew(0, 8) = String(40, "0")
    sRegMapValsNew(0, 9) = String(40, "0")
    sRegMapValsNew(0, 10) = String(40, "0")
    sRegMapValsNew(0, 11) = String(32, "0")
    sRegMapValsNew(0, 12) = cbaseDec2Bin(&H59000800, 32)

    'Clear out the register map values for DUT2
    sRegMapValsNew(1, 0) = String(32, "0")
    sRegMapValsNew(1, 1) = String(24, "0")
    sRegMapValsNew(1, 2) = String(16, "0")
    sRegMapValsNew(1, 3) = String(8, "0")
    sRegMapValsNew(1, 4) = String(24, "0")
    sRegMapValsNew(1, 5) = String(16, "0")
    sRegMapValsNew(1, 6) = String(32, "0")
    sRegMapValsNew(1, 7) = String(40, "0")
    sRegMapValsNew(1, 8) = String(40, "0")
    sRegMapValsNew(1, 9) = String(40, "0")
    sRegMapValsNew(1, 10) = String(40, "0")
    sRegMapValsNew(1, 11) = String(32, "0")
    sRegMapValsNew(1, 12) = cbaseDec2Bin(&H59000800, 32)
End Sub

Private Sub Class_Terminate()
    'Release the lptio class
    Set PPIO = Nothing
End Sub
'Flips a string - used to flip the data in lsb first mode
Public Function FlipString(ByVal MyStr As String) As String
    Dim cntr As Integer
    For cntr = Len(MyStr) To 1 Step -1
        FlipString = FlipString & Mid(MyStr, cntr, 1)
    Next cntr
End Function
'Sets the specified bit value to the specified buffer
Public Sub SetBitVal(ByVal Buff As evb59Buffs, ByVal Bit As evbBits, ByVal value As adiBinValues)
    If value <> 0 Then
        'Set the bit
        evbBuffers(Buff) = evbBuffers(Buff) Or evbBitVals(Bit)
    Else
        'Clear the bit
        evbBuffers(Buff) = evbBuffers(Buff) And Not evbBitVals(Bit)
    End If
End Sub
'Returns the current bit value from the specified buffer
Public Function GetBitVal(ByVal Buff As evb59Buffs, ByVal Bit As evbBits) As Integer
    'Test the bit
    If evbBuffers(Buff) And evbBitVals(Bit) Then
        'If a one the return 1
        GetBitVal = 1
    Else
        'If a zero then return 0
        GetBitVal = 0
    End If
End Function
'Returns the current value of the specified software buffer which should be the
'current hardware buffer value if SetBitVal,SetEvbBuffVal,and WriteEvbBuffVal
'are used exclusively
Public Function GetEvbBuffVal(ByVal Buff As evb59Buffs) As Integer
    'Return the requested information
    GetEvbBuffVal = evbBuffers(Buff)
End Function

'Sets the software buffer value specifed by RegVal
'To write the value from the software buffer to the hardware buffer call
'WriteEvbBuffVal()
Public Sub SetEvbBuffVal(ByVal Buff As evb59Buffs, ByVal BuffVal As Integer)
    
    'Set the register value
    evbBuffers(Buff) = BuffVal
    
End Sub

'Writes the value specified by buff to the software buffer and the hardware buffer
'specifed by evbBuffs.  If BuffVal is not passed then it writes the value currently
'in the software buffer.
'The write sequence is as follows
'1. Write the value to the dataport of the parallel port
'2. Latch the data into the proper hardware buffer on the eval board.
Public Sub WriteEvbBuffVal(ByVal Buff As evb59Buffs, Optional BuffVal As Variant)
    Dim Val As Integer
    Static ResetDUT2Old As Boolean
    Static ResetDUT1Old As Boolean
    Dim wPwdwnDut1 As Boolean
    Dim wPwdwnDut2 As Boolean
    
    'Check to see if a value was passed, if not then use the value in the buffer
    If IsMissing(BuffVal) Then
        Val = evbBuffers(Buff)
    Else
        Val = BuffVal
    End If
    
    'Try and detect if the DUT(s) are being reset
    If Buff = evb59Buff2 Then 'Only check if BUFF2 is being written
        If Val And &H40 Then 'Test for a ResetDUT1
            If OldResetDUT1Val = abvLow Then
            'If either of the major powerdown bits are high then the dut was powered down
                If sGetRegMapBitVal(1, 0, 7) = abvHigh Or sGetNewRegMapBitVal(1, 0, 4) = abvHigh Then
                    wPwdwnDut1 = True
                Else
                    wPwdwnDut1 = False
                End If
                
                'A Reset is occuring so trigger the ResetOccurred
                RaiseEvent ResetOccured(1, wPwdwnDut1)
            End If
            'Store the state of the Reset Pin for future reference
            OldResetDUT1Val = abvHigh
        Else
            'Store the state of the Reset Pin for future reference
            OldResetDUT1Val = abvLow
        End If
        
        If Val And &H80 Then 'Test for a ResetDUT2
            If OldResetDUT2Val = abvLow Then
            'If either of the major powerdown bits are high then the dut was powered down
                If sGetRegMapBitVal(2, 0, 7) = abvHigh Or sGetNewRegMapBitVal(2, 0, 4) = abvHigh Then
                    wPwdwnDut2 = True
                Else
                    wPwdwnDut2 = False
                End If
                'A Reset is occuring so trigger the ResetOccurred
                RaiseEvent ResetOccured(2, wPwdwnDut2)
            End If
            'Store the state of the Reset Pin for future reference
            OldResetDUT2Val = abvHigh
        Else
            'Store the state of the Reset Pin for future reference
            OldResetDUT2Val = abvLow
        End If
    End If
    
    'Write it to the parallel port
    PPIO.WritePort ppDataRegister, Val

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -