1. 程式人生 > >STM32 ISP串列埠燒錄 VB原始碼(二)關鍵程式碼

STM32 ISP串列埠燒錄 VB原始碼(二)關鍵程式碼

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function timeGetTime Lib "winmm.dll"() As Long
在程式最開始。

一、主要引數

Dim i As Long
Dim bin() As Byte
Dim BINLEN As Long
Dim Slen As Long
Dim str As String
Dim BAnk As Long          '總共有多少塊
Dim ConStstus As Boolean  '連線狀態
Dim Sendbuff() As Byte    '傳送快取
Dim Recvbuff(256) As Byte '接收快取
Dim Binfile() As Byte     '檔案快取

二、一般操作程式碼

Private Sub CmdClear_Click() '清空操作
    Textdata = ""
End Sub
Private Sub Command2_Click()   '重新整理埠
Dim G As Integer
Dim Index As Integer
if Index = 0 Then
   On Error Resume Next    '出現錯誤
   For G=1 To 9            '新增通訊選擇
      MSComm1.CommPort = G
      MSComm1.PortOpen = true
      If MSComm1.PortOpen = true Then
          ComPortlist.AddItem "COM" & Trim$(G)
      End If
      MSComm1.PortOpen = False
    Next G
    ComPortlist.ListIndex = 0
End If
End Sub
Public Sub waittime(delay As Single)
Dim starttime As Single
starttime=Timer
Do Until (Timer-starttime)>delay
DoEvents
Loop
End Sub
Private Sub Command1_Click()  '退出操作
    If MSComm1.PortOpen=True Then MSComm1.PortOpen=False
    Unload Form1
    End
End Sub

三、核心程式