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

📄 i2cdisplay.frm

📁 PC端的USB主机源代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form DisplayWindow 
   BackColor       =   &H00FF8080&
   Caption         =   "USB Design By Example:  I2C Development System"
   ClientHeight    =   5595
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8475
   LinkTopic       =   "Form1"
   ScaleHeight     =   5595
   ScaleWidth      =   8475
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox ReadWindow 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2535
      Left            =   5280
      TabIndex        =   10
      Text            =   "Text1"
      Top             =   1920
      Width           =   2055
   End
   Begin VB.TextBox WriteWindow 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2535
      Left            =   1080
      TabIndex        =   9
      Text            =   "Text1"
      Top             =   1920
      Width           =   2055
   End
   Begin VB.TextBox ReadAddress 
      Alignment       =   2  'Center
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   6720
      TabIndex        =   8
      Text            =   "21"
      Top             =   1320
      Width           =   615
   End
   Begin VB.TextBox WriteAddress 
      Alignment       =   2  'Center
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   465
      Left            =   2520
      TabIndex        =   7
      Text            =   "40"
      Top             =   1320
      Width           =   615
   End
   Begin VB.CommandButton ReadFile 
      Caption         =   "Read Data from File"
      Height          =   495
      Left            =   360
      TabIndex        =   3
      Top             =   4680
      Width           =   1695
   End
   Begin VB.CommandButton WriteFile 
      Caption         =   "Write Data to File"
      Height          =   495
      Left            =   6360
      TabIndex        =   2
      Top             =   4680
      Width           =   1695
   End
   Begin VB.CommandButton ReadI2C 
      Caption         =   "Read from I2C"
      Height          =   495
      Left            =   4560
      TabIndex        =   1
      Top             =   4680
      Width           =   1695
   End
   Begin VB.CommandButton WriteI2C 
      Caption         =   "Write  to I2C"
      Height          =   495
      Left            =   2160
      TabIndex        =   0
      Top             =   4680
      Width           =   1695
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "I2C Development System"
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   24
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   735
      Left            =   1320
      TabIndex        =   6
      Top             =   360
      Width           =   6015
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Read Addr."
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   615
      Index           =   1
      Left            =   5280
      TabIndex        =   5
      Top             =   1440
      Width           =   2295
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Write Addr."
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   615
      Index           =   0
      Left            =   1080
      TabIndex        =   4
      Top             =   1440
      Width           =   2295
   End
End
Attribute VB_Name = "DisplayWindow"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub Form_Load()
' Initialize the I2C address's to match the EZ-USB develoment board
WriteAddress.Text = "42": ReadAddress.Text = "41"
' Clear the display windows
WriteWindow.Text = "": ReadWindow.Text = ""
End Sub
Private Sub ReadI2C_Click()
' Send a I2C bus read request to the I0 device
Dim OutBuffer(2) As Byte: Dim InBuffer(2) As Byte
OutBuffer(0) = ReturnHexByte(ReadAddress.Text)
OutBuffer(1) = 0 ' Required pad
Call WriteUSBdevice(AddressFor(OutBuffer(0)), 2)
' I/O device will respond with an Input Report
' This version sends a single byte
Call ReadUSBdevice(AddressFor(InBuffer(0)), 2)
ReadWindow.Text = TwoHexCharacters(InBuffer(0))
End Sub
Private Sub WriteI2C_Click()
' Send the data in "WriteWindow" to the I2C "WriteAddress"
Dim Buffer(2) As Byte
Buffer(0) = ReturnHexByte(WriteAddress.Text)
Buffer(1) = ReturnHexByte(WriteWindow.Text)
Call WriteUSBdevice(AddressFor(Buffer(0)), 2)
End Sub
Private Sub ReadFile_Click()
' Not implemented in this version
End Sub
Private Sub WriteFile_Click()
' Not implemented in this version
End Sub

⌨️ 快捷键说明

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