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

📄 test.frm

📁 用VB通过并口控制I2C总线
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   5520
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6870
   LinkTopic       =   "Form1"
   ScaleHeight     =   5520
   ScaleWidth      =   6870
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command5 
      Caption         =   "ToolTest"
      Height          =   375
      Left            =   840
      TabIndex        =   6
      Top             =   4320
      Width           =   1455
   End
   Begin VB.CommandButton Command4 
      Caption         =   "位读"
      Height          =   375
      Left            =   4080
      TabIndex        =   5
      Top             =   3240
      Width           =   1335
   End
   Begin VB.CommandButton Command3 
      Caption         =   "位写"
      Height          =   375
      Left            =   1080
      TabIndex        =   4
      Top             =   3240
      Width           =   1455
   End
   Begin VB.CommandButton Command2 
      Caption         =   "写"
      Height          =   495
      Left            =   960
      TabIndex        =   3
      Top             =   2160
      Width           =   1575
   End
   Begin VB.TextBox Text2 
      Height          =   1095
      Left            =   600
      TabIndex        =   2
      Text            =   "Text2"
      Top             =   360
      Width           =   2295
   End
   Begin VB.CommandButton Command1 
      Caption         =   "读"
      Height          =   495
      Left            =   4080
      TabIndex        =   1
      Top             =   2160
      Width           =   1455
   End
   Begin VB.TextBox Text1 
      Height          =   1095
      Left            =   3600
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Text            =   "test.frx":0000
      Top             =   360
      Width           =   2775
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim flag As Boolean
Private Sub Command1_Click()
Dim temp As Byte
temp = LptIic.IicReadByte(160, 0)
If LptIic.IicError = False Then
Text1.Text = CStr(temp)
Else
MsgBox "error!!!"
End If

End Sub

Private Sub Command2_Click()
LptIic.IicWriteByte 160, 0, Val(Text2.Text)
If LptIic.IicError Then
   MsgBox "error!!!"
End If
End Sub

Private Sub Command3_Click()
'Dim temp As Byte
'temp = IicReadByte(160, 0)
'If LptIic.IicError = False Then
'   Text2.Text = CStr(temp)
'Else
'   MsgBox "error!!!"
'End If
If Text2.Text = "1" Then
LptIic.SetSDA
Else
LptIic.ClrSDA
End If
End Sub

Private Sub Command4_Click()
Text1.Text = LptIic.GetSDAPort(889, 7, 0)
End Sub

Private Sub Command5_Click()
Dim temp As Byte
If flag = False Then
'----------------------------------
If LptIic.IicBusSearch(160) Then
   MsgBox "Iic Ok!!!"
   flag = True
   temp = LptIic.IicReadByte(160, 0)
   If LptIic.IicError = False Then
      Text1.Text = CStr(temp)
   Else
     MsgBox "read error!!!"
   End If
Else
  MsgBox "Iic Error!!!"
End If
'-----------------------------------
Else
   temp = LptIic.IicReadByte(160, 0)
   If LptIic.IicError = False Then
      Text1.Text = CStr(temp)
   Else
     MsgBox "read error!!!"
   End If
End If
End Sub

Private Sub Form_Load()
Set LptIic = New LptI2C
Set LPTini = New LPT
'LptIic.SDA_In_Config 889, 7, 0
'LptIic.SDA_Out_Config 888, 0, 1
'LptIic.SCL_In_Config 889, 6, 1
'LptIic.SCL_Out_Config 888, 1, 1
'LptIic.IicBusDelayTime = 1
End Sub

⌨️ 快捷键说明

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