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

📄 p8255b.frm

📁 本CD-ROM包括《Verilog-HDL实践与应用系统设计》一书中的全部例子
💻 FRM
字号:
VERSION 5.00
Begin VB.Form P8255 
   Caption         =   "P8255B"
   ClientHeight    =   8250
   ClientLeft      =   3570
   ClientTop       =   1875
   ClientWidth     =   10035
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   8250
   ScaleWidth      =   10035
   Begin VB.CommandButton Command16 
      Caption         =   "testing"
      Height          =   315
      Left            =   1080
      TabIndex        =   21
      Top             =   240
      Visible         =   0   'False
      Width           =   1095
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   1
      Left            =   480
      Top             =   120
   End
   Begin VB.PictureBox Picture1 
      Height          =   6855
      Left            =   240
      Picture         =   "P8255B.frx":0000
      ScaleHeight     =   6795
      ScaleWidth      =   9435
      TabIndex        =   1
      Top             =   720
      Width           =   9495
      Begin VB.CommandButton Command15 
         Caption         =   "连续运行"
         Height          =   375
         Left            =   5640
         TabIndex        =   20
         Top             =   4680
         Width           =   975
      End
      Begin VB.CommandButton Command14 
         Caption         =   "停止"
         Height          =   375
         Left            =   5640
         TabIndex        =   19
         Top             =   5040
         Width           =   975
      End
      Begin VB.TextBox Text3 
         BackColor       =   &H00FFFFC0&
         Height          =   375
         Left            =   8880
         TabIndex        =   18
         Text            =   "0"
         Top             =   2040
         Width           =   375
      End
      Begin VB.CommandButton Command13 
         Caption         =   "向指定口发送数据 (Hex)"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9.75
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   6960
         TabIndex        =   17
         Top             =   1680
         Width           =   2415
      End
      Begin VB.Frame Frame2 
         Caption         =   "端口"
         Height          =   1215
         Left            =   7560
         TabIndex        =   13
         Top             =   2400
         Width           =   1335
         Begin VB.OptionButton Option2 
            Caption         =   "A Port"
            Height          =   180
            Index           =   0
            Left            =   240
            TabIndex        =   16
            Top             =   360
            Value           =   -1  'True
            Width           =   975
         End
         Begin VB.OptionButton Option2 
            Caption         =   "B Port"
            Height          =   180
            Index           =   1
            Left            =   240
            TabIndex        =   15
            Top             =   600
            Width           =   975
         End
         Begin VB.OptionButton Option2 
            Caption         =   "C Port"
            Height          =   180
            Index           =   2
            Left            =   240
            TabIndex        =   14
            Top             =   840
            Width           =   975
         End
      End
      Begin VB.TextBox Text2 
         BackColor       =   &H00FFFFC0&
         Height          =   375
         Left            =   6240
         TabIndex        =   9
         Text            =   "9B"
         Top             =   2520
         Width           =   375
      End
      Begin VB.TextBox Text1 
         BackColor       =   &H00FFFFC0&
         Height          =   375
         Left            =   840
         TabIndex        =   8
         Text            =   "3"
         Top             =   2280
         Width           =   255
      End
      Begin VB.Frame Frame1 
         Caption         =   "端口"
         Height          =   1215
         Left            =   5280
         TabIndex        =   6
         Top             =   3480
         Width           =   1335
         Begin VB.OptionButton Option1 
            Caption         =   "C Port"
            Height          =   180
            Index           =   2
            Left            =   240
            TabIndex        =   12
            Top             =   840
            Width           =   975
         End
         Begin VB.OptionButton Option1 
            Caption         =   "B Port"
            Height          =   180
            Index           =   1
            Left            =   240
            TabIndex        =   11
            Top             =   600
            Width           =   975
         End
         Begin VB.OptionButton Option1 
            Caption         =   "A Port"
            Height          =   180
            Index           =   0
            Left            =   240
            TabIndex        =   7
            Top             =   360
            Value           =   -1  'True
            Width           =   975
         End
      End
      Begin VB.CommandButton Command4 
         Caption         =   "发送数据(Hex)"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9.75
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4800
         TabIndex        =   4
         Top             =   2520
         Width           =   1455
      End
      Begin VB.CommandButton Command3 
         Caption         =   "接收数据(Hex)"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9.75
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4680
         TabIndex        =   3
         Top             =   3120
         Width           =   1815
      End
      Begin VB.CommandButton Command2 
         Caption         =   "指定8255地址(0-3)"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9.75
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1080
         TabIndex        =   2
         Top             =   2280
         Width           =   2055
      End
      Begin VB.Label Label1 
         BackColor       =   &H0080FF80&
         Caption         =   "HEX"
         Height          =   375
         Left            =   4200
         TabIndex        =   10
         Top             =   3120
         Width           =   495
      End
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Exit"
      BeginProperty Font 
         Name            =   "MS PMincho"
         Size            =   11.25
         Charset         =   128
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4080
      TabIndex        =   0
      Top             =   7680
      Width           =   1815
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      BackColor       =   &H00C0E0FF&
      Caption         =   "P8255B板基本控制实验"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2760
      TabIndex        =   5
      Top             =   240
      Width           =   4335
   End
End
Attribute VB_Name = "P8255"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
    Unload Me
End Sub


Private Sub Command12_Click()



End Sub


Private Sub Command10_Click()

End Sub

Private Sub Command11_Click()

End Sub

Private Sub Command13_Click()
    Dim datas  As Integer
    Dim port As Integer
    For i = 0 To 2
        If Option2(i).Value = True Then
            Select Case i
                    Case 0
                        port = A_port
                    Case 1
                        port = B_port

                    Case 2
                        port = C_port
                    End Select
          
            End If
        Next i
   P8255B_set_A1A0 (port)
   
   datas = Val(h_to_d(Text3.Text))
   P8255B_write_data (datas)
End Sub

Private Sub Command14_Click()
    Timer1.Enabled = False
    Command14.Enabled = False
    Command15.Enabled = True
End Sub

Private Sub Command15_Click()
    Timer1.Enabled = True
    Command14.Enabled = True
    Command15.Enabled = False
End Sub

Private Sub Command16_Click()
Command3_Click
End Sub

Private Sub Command2_Click()

   Dim addr As Integer
   
   addr = Text1.Text
   
   P8255B_set_A1A0 (addr)

End Sub


Private Sub Command3_Click()
    Dim datas  As Integer
    Dim port As Integer
    For i = 0 To 2
        If Option1(i).Value = True Then
            Select Case i
                    Case 0
                        port = A_port
                    Case 1
                        port = B_port

                    Case 2
                        port = C_port
                    End Select
          
            End If
        Next i
    datas = P8255B_read_data(port)
    Label1.Caption = Hex(datas)

End Sub


Private Sub Command4_Click()
   Dim data As Integer
   data = Val(h_to_d(Text2.Text))
   P8255B_write_data (data)
End Sub

Private Sub Form_Load()
    form_init
End Sub


Function h_to_d(ByVal hdat As String) As String
    Dim dval As Long
    Dim hexchar As String
    Dim hexval As String
    Dim i As Integer
    Dim power As Long
    Dim tempval As Integer
    hexchar = "123456789ABCDEF"
    hexval = UCase$(hdat)
    dval = 0
    For i = 1 To Len(hexval)
        power = 16 ^ (Len(hexval) - i)
        tempval = InStr(hexchar, Mid$(hexval, i, 1))
        dval = dval + (tempval * power)
    Next i
    h_to_d = Str$(dval)
End Function

Private Sub form_init()
    Width = 10155
    Height = 8655
    Left = (Screen.Width - Width) / 2
    Top = (Screen.Height - Height) / 2
    'Picture1.Top = 33
    'Picture1.Left = (Width - Picture1.Width) / 2
End Sub


Private Sub Timer1_Timer()
  Command16_Click
End Sub


⌨️ 快捷键说明

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