Code: Alles auswählen
; Source generiert durch DLL2PBLib
; Copyright 2005 by Thomas Schulz (TS-Soft)
;HD44780 instructions, compare HD44780 Data sheet
cmd_Clear_Display = $01
cmd_Return_Home = $02
cmd_Entry_Mode_Set = $04
cmd_Display_On_Off = $08
cmd_Cursor_or_Display_Shift = $10
cmd_Function_Set = $20
cmd_Set_CGRAM_Address = $40
cmd_Set_DDRAM_Address = $80
;HD44780 instruction params
;cmd_Entry_Mode_Set params
cursor_Shift_Left =$00
cursor_Shift_Right =$02
cursor_Shift_On =$01
cursor_Shift_Off =$00
;cmd_Display_On_Off params
display_On =$04
display_Off =$00
cursor_On =$02
cursor_Off =$00
Cursor_Blink_On =$01
Cursor_Blink_Off =$00
;cmd_Cursor_or_Display_Shift params
Shift_Display =$08
Shift_Cursor =$00
Shift_Left =$04
Shift_Right =$00
;cmd_Function_Set params
interface_8Bit =$10
interface_4Bit =$00
display_2lines =$08
display_1line =$00
Font_5x11 =$04
Font_5x8 =$00
; Globale Variablen deklaration
Global CH341AbortInter.l
Global CH341AbortRead.l
Global CH341AbortWrite.l
Global CH341BitStreamSPI.l
Global CH341CloseDevice.l
Global CH341CloseDeviceEx.l
Global CH341DriverCommand.l
Global CH341EppReadAddr.l
Global CH341EppReadData.l
Global CH341EppSetAddr.l
Global CH341EppWriteAddr.l
Global CH341EppWriteData.l
Global CH341FlushBuffer.l
Global CH341GetConfigDescr.l
Global CH341GetDeviceDescr.l
Global CH341GetDeviceName.l
Global CH341GetDeviceNameEx.l
Global CH341GetDrvVersion.l
Global CH341GetInput.l
Global CH341GetStatus.l
Global CH341GetVerIC.l
Global CH341GetVersion.l
Global CH341InitParallel.l
Global CH341MemReadAddr0.l
Global CH341MemReadAddr1.l
Global CH341MemWriteAddr0.l
Global CH341MemWriteAddr1.l
Global CH341OpenDevice.l
Global CH341OpenDeviceEx.l
Global CH341QueryBufDownload.l
Global CH341QueryBufUpload.l
Global CH341ReadData.l
Global CH341ReadData0.l
Global CH341ReadData1.l
Global CH341ReadEEPROM.l
Global CH341ReadI2C.l
Global CH341ReadInter.l
Global CH341ResetDevice.l
Global CH341ResetInter.l
Global CH341ResetRead.l
Global CH341ResetWrite.l
Global CH341SetBufDownload.l
Global CH341SetBufUpload.l
Global CH341SetDelaymS.l
Global CH341SetDeviceNotify.l
Global CH341SetDeviceNotifyEx.l
Global CH341SetExclusive.l
Global CH341SetIntRoutine.l
Global CH341SetOutput.l
Global CH341SetParaMode.l
Global CH341SetStream.l
Global CH341SetTimeout.l
Global CH341Set_D5_D0.l
Global CH341SetupSerial.l
Global CH341StreamI2C.l
Global CH341StreamSPI3.l
Global CH341StreamSPI4.l
Global CH341StreamSPI5.l
Global CH341WriteData.l
Global CH341WriteData0.l
Global CH341WriteData1.l
Global CH341WriteEEPROM.l
Global CH341WriteI2C.l
Global CH341WriteRead.l
; Init-Funktion
ProcedureDLL CH341DLLDLL_Init()
Shared DLL.l
DLL = LoadLibrary_("CH341DLL.DLL")
If DLL
CH341AbortInter = GetProcAddress_(DLL, "CH341AbortInter")
CH341AbortRead = GetProcAddress_(DLL, "CH341AbortRead")
CH341AbortWrite = GetProcAddress_(DLL, "CH341AbortWrite")
CH341BitStreamSPI = GetProcAddress_(DLL, "CH341BitStreamSPI")
CH341CloseDevice = GetProcAddress_(DLL, "CH341CloseDevice")
CH341CloseDeviceEx = GetProcAddress_(DLL, "CH341CloseDeviceEx")
CH341DriverCommand = GetProcAddress_(DLL, "CH341DriverCommand")
CH341EppReadAddr = GetProcAddress_(DLL, "CH341EppReadAddr")
CH341EppReadData = GetProcAddress_(DLL, "CH341EppReadData")
CH341EppSetAddr = GetProcAddress_(DLL, "CH341EppSetAddr")
CH341EppWriteAddr = GetProcAddress_(DLL, "CH341EppWriteAddr")
CH341EppWriteData = GetProcAddress_(DLL, "CH341EppWriteData")
CH341FlushBuffer = GetProcAddress_(DLL, "CH341FlushBuffer")
CH341GetConfigDescr = GetProcAddress_(DLL, "CH341GetConfigDescr")
CH341GetDeviceDescr = GetProcAddress_(DLL, "CH341GetDeviceDescr")
CH341GetDeviceName = GetProcAddress_(DLL, "CH341GetDeviceName")
CH341GetDeviceNameEx = GetProcAddress_(DLL, "CH341GetDeviceNameEx")
CH341GetDrvVersion = GetProcAddress_(DLL, "CH341GetDrvVersion")
CH341GetInput = GetProcAddress_(DLL, "CH341GetInput")
CH341GetStatus = GetProcAddress_(DLL, "CH341GetStatus")
CH341GetVerIC = GetProcAddress_(DLL, "CH341GetVerIC")
CH341GetVersion = GetProcAddress_(DLL, "CH341GetVersion")
CH341InitParallel = GetProcAddress_(DLL, "CH341InitParallel")
CH341MemReadAddr0 = GetProcAddress_(DLL, "CH341MemReadAddr0")
CH341MemReadAddr1 = GetProcAddress_(DLL, "CH341MemReadAddr1")
CH341MemWriteAddr0 = GetProcAddress_(DLL, "CH341MemWriteAddr0")
CH341MemWriteAddr1 = GetProcAddress_(DLL, "CH341MemWriteAddr1")
CH341OpenDevice = GetProcAddress_(DLL, "CH341OpenDevice")
CH341OpenDeviceEx = GetProcAddress_(DLL, "CH341OpenDeviceEx")
CH341QueryBufDownload = GetProcAddress_(DLL, "CH341QueryBufDownload")
CH341QueryBufUpload = GetProcAddress_(DLL, "CH341QueryBufUpload")
CH341ReadData = GetProcAddress_(DLL, "CH341ReadData")
CH341ReadData0 = GetProcAddress_(DLL, "CH341ReadData0")
CH341ReadData1 = GetProcAddress_(DLL, "CH341ReadData1")
CH341ReadEEPROM = GetProcAddress_(DLL, "CH341ReadEEPROM")
CH341ReadI2C = GetProcAddress_(DLL, "CH341ReadI2C")
CH341ReadInter = GetProcAddress_(DLL, "CH341ReadInter")
CH341ResetDevice = GetProcAddress_(DLL, "CH341ResetDevice")
CH341ResetInter = GetProcAddress_(DLL, "CH341ResetInter")
CH341ResetRead = GetProcAddress_(DLL, "CH341ResetRead")
CH341ResetWrite = GetProcAddress_(DLL, "CH341ResetWrite")
CH341SetBufDownload = GetProcAddress_(DLL, "CH341SetBufDownload")
CH341SetBufUpload = GetProcAddress_(DLL, "CH341SetBufUpload")
CH341SetDelaymS = GetProcAddress_(DLL, "CH341SetDelaymS")
CH341SetDeviceNotify = GetProcAddress_(DLL, "CH341SetDeviceNotify")
CH341SetDeviceNotifyEx = GetProcAddress_(DLL, "CH341SetDeviceNotifyEx")
CH341SetExclusive = GetProcAddress_(DLL, "CH341SetExclusive")
CH341SetIntRoutine = GetProcAddress_(DLL, "CH341SetIntRoutine")
CH341SetOutput = GetProcAddress_(DLL, "CH341SetOutput")
CH341SetParaMode = GetProcAddress_(DLL, "CH341SetParaMode")
CH341SetStream = GetProcAddress_(DLL, "CH341SetStream")
CH341SetTimeout = GetProcAddress_(DLL, "CH341SetTimeout")
CH341Set_D5_D0 = GetProcAddress_(DLL, "CH341Set_D5_D0")
CH341SetupSerial = GetProcAddress_(DLL, "CH341SetupSerial")
CH341StreamI2C = GetProcAddress_(DLL, "CH341StreamI2C")
CH341StreamSPI3 = GetProcAddress_(DLL, "CH341StreamSPI3")
CH341StreamSPI4 = GetProcAddress_(DLL, "CH341StreamSPI4")
CH341StreamSPI5 = GetProcAddress_(DLL, "CH341StreamSPI5")
CH341WriteData = GetProcAddress_(DLL, "CH341WriteData")
CH341WriteData0 = GetProcAddress_(DLL, "CH341WriteData0")
CH341WriteData1 = GetProcAddress_(DLL, "CH341WriteData1")
CH341WriteEEPROM = GetProcAddress_(DLL, "CH341WriteEEPROM")
CH341WriteI2C = GetProcAddress_(DLL, "CH341WriteI2C")
CH341WriteRead = GetProcAddress_(DLL, "CH341WriteRead")
Else
Debug "kann dll nicht öffnen"
EndIf
EndProcedure
; End-Funktion
ProcedureDLL CH341DLLDLL_End()
Shared DLL.l
FreeLibrary_(DLL)
EndProcedure
; Allgemeine Funktionen
ProcedureDLL.l CH341AbortInter(a.l)
ProcedureReturn CallFunctionFast(CH341AbortInter,a)
EndProcedure
ProcedureDLL.l CH341AbortRead(a.l)
ProcedureReturn CallFunctionFast(CH341AbortRead,a)
EndProcedure
ProcedureDLL.l CH341AbortWrite(a.l)
ProcedureReturn CallFunctionFast(CH341AbortWrite,a)
EndProcedure
ProcedureDLL.l CH341BitStreamSPI(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341BitStreamSPI,a,b,c)
EndProcedure
ProcedureDLL.l CH341CloseDevice(a.l)
ProcedureReturn CallFunctionFast(CH341CloseDevice,a)
EndProcedure
ProcedureDLL.l CH341CloseDeviceEx(a.l)
ProcedureReturn CallFunctionFast(CH341CloseDeviceEx,a)
EndProcedure
ProcedureDLL.l CH341DriverCommand(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341DriverCommand,a,b)
EndProcedure
ProcedureDLL.l CH341EppReadAddr(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341EppReadAddr,a,b,c)
EndProcedure
ProcedureDLL.l CH341EppReadData(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341EppReadData,a,b,c)
EndProcedure
ProcedureDLL.l CH341EppSetAddr(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341EppSetAddr,a,b)
EndProcedure
ProcedureDLL.l CH341EppWriteAddr(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341EppWriteAddr,a,b,c)
EndProcedure
ProcedureDLL.l CH341EppWriteData(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341EppWriteData,a,b,c)
EndProcedure
ProcedureDLL.l CH341FlushBuffer(a.l)
ProcedureReturn CallFunctionFast(CH341FlushBuffer,a)
EndProcedure
ProcedureDLL.l CH341GetConfigDescr(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341GetConfigDescr,a,b,c)
EndProcedure
ProcedureDLL.l CH341GetDeviceDescr(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341GetDeviceDescr,a,b,c)
EndProcedure
ProcedureDLL.l CH341GetDeviceName(a.l)
ProcedureReturn CallFunctionFast(CH341GetDeviceName,a)
EndProcedure
ProcedureDLL.l CH341GetDeviceNameEx(a.l)
ProcedureReturn CallFunctionFast(CH341GetDeviceNameEx,a)
EndProcedure
ProcedureDLL.l CH341GetDrvVersion()
ProcedureReturn CallFunctionFast(CH341GetDrvVersion)
EndProcedure
ProcedureDLL.l CH341GetInput(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341GetInput,a,b)
EndProcedure
ProcedureDLL.l CH341GetStatus(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341GetStatus,a,b)
EndProcedure
ProcedureDLL.l CH341GetVerIC(a.l)
ProcedureReturn CallFunctionFast(CH341GetVerIC,a)
EndProcedure
ProcedureDLL.l CH341GetVersion()
ProcedureReturn CallFunctionFast(CH341GetVersion)
EndProcedure
ProcedureDLL.l CH341InitParallel(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341InitParallel,a,b)
EndProcedure
ProcedureDLL.l CH341MemReadAddr0(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341MemReadAddr0,a,b,c)
EndProcedure
ProcedureDLL.l CH341MemReadAddr1(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341MemReadAddr1,a,b,c)
EndProcedure
ProcedureDLL.l CH341MemWriteAddr0(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341MemWriteAddr0,a,b,c)
EndProcedure
ProcedureDLL.l CH341MemWriteAddr1(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341MemWriteAddr1,a,b,c)
EndProcedure
ProcedureDLL.l CH341OpenDevice(a.l)
ProcedureReturn CallFunctionFast(CH341OpenDevice,a)
EndProcedure
ProcedureDLL.l CH341OpenDeviceEx(a.l)
ProcedureReturn CallFunctionFast(CH341OpenDeviceEx,a)
EndProcedure
ProcedureDLL.l CH341QueryBufDownload(a.l)
ProcedureReturn CallFunctionFast(CH341QueryBufDownload,a)
EndProcedure
ProcedureDLL.l CH341QueryBufUpload(a.l)
ProcedureReturn CallFunctionFast(CH341QueryBufUpload,a)
EndProcedure
ProcedureDLL.l CH341ReadData(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341ReadData,a,b,c)
EndProcedure
ProcedureDLL.l CH341ReadData0(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341ReadData0,a,b,c)
EndProcedure
ProcedureDLL.l CH341ReadData1(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341ReadData1,a,b,c)
EndProcedure
ProcedureDLL.l CH341ReadEEPROM(a.l,b.l,c.l,d.l,e.l)
ProcedureReturn CallFunctionFast(CH341ReadEEPROM,a,b,c,d,e)
EndProcedure
ProcedureDLL.l CH341ReadI2C(a.l,b.l,c.l,d.l)
ProcedureReturn CallFunctionFast(CH341ReadI2C,a,b,c,d)
EndProcedure
ProcedureDLL.l CH341ReadInter(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341ReadInter,a,b)
EndProcedure
ProcedureDLL.l CH341ResetDevice(a.l)
ProcedureReturn CallFunctionFast(CH341ResetDevice,a)
EndProcedure
ProcedureDLL.l CH341ResetInter(a.l)
ProcedureReturn CallFunctionFast(CH341ResetInter,a)
EndProcedure
ProcedureDLL.l CH341ResetRead(a.l)
ProcedureReturn CallFunctionFast(CH341ResetRead,a)
EndProcedure
ProcedureDLL.l CH341ResetWrite(a.l)
ProcedureReturn CallFunctionFast(CH341ResetWrite,a)
EndProcedure
ProcedureDLL.l CH341SetBufDownload(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341SetBufDownload,a,b)
EndProcedure
ProcedureDLL.l CH341SetBufUpload(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341SetBufUpload,a,b)
EndProcedure
ProcedureDLL.l CH341SetDelaymS(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341SetDelaymS,a,b)
EndProcedure
ProcedureDLL.l CH341SetDeviceNotify(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341SetDeviceNotify,a,b,c)
EndProcedure
ProcedureDLL.l CH341SetDeviceNotifyEx(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341SetDeviceNotifyEx,a,b,c)
EndProcedure
ProcedureDLL.l CH341SetExclusive(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341SetExclusive,a,b)
EndProcedure
ProcedureDLL.l CH341SetIntRoutine(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341SetIntRoutine,a,b)
EndProcedure
ProcedureDLL.l CH341SetOutput(a.l,b.l,c.l,d.l)
ProcedureReturn CallFunctionFast(CH341SetOutput,a,b,c,d)
EndProcedure
ProcedureDLL.l CH341SetParaMode(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341SetParaMode,a,b)
EndProcedure
ProcedureDLL.l CH341SetStream(a.l,b.l)
ProcedureReturn CallFunctionFast(CH341SetStream,a,b)
EndProcedure
ProcedureDLL.l CH341SetTimeout(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341SetTimeout,a,b,c)
EndProcedure
ProcedureDLL.l CH341Set_D5_D0(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341Set_D5_D0,a,b,c)
EndProcedure
ProcedureDLL.l CH341SetupSerial(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341SetupSerial,a,b,c)
EndProcedure
ProcedureDLL.l CH341StreamI2C(a.l,b.l,c.l,d.l,e.l)
ProcedureReturn CallFunctionFast(CH341StreamI2C,a,b,c,d,e)
EndProcedure
ProcedureDLL.l CH341StreamSPI3(a.l,b.l,c.l,d.l)
ProcedureReturn CallFunctionFast(CH341StreamSPI3,a,b,c,d)
EndProcedure
ProcedureDLL.l CH341StreamSPI4(a.l,b.l,c.l,d.l)
ProcedureReturn CallFunctionFast(CH341StreamSPI4,a,b,c,d)
EndProcedure
ProcedureDLL.l CH341StreamSPI5(a.l,b.l,c.l,d.l,e.l)
ProcedureReturn CallFunctionFast(CH341StreamSPI5,a,b,c,d,e)
EndProcedure
ProcedureDLL.l CH341WriteData(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341WriteData,a,b,c)
EndProcedure
ProcedureDLL.l CH341WriteData0(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341WriteData0,a,b,c)
EndProcedure
ProcedureDLL.l CH341WriteData1(a.l,b.l,c.l)
ProcedureReturn CallFunctionFast(CH341WriteData1,a,b,c)
EndProcedure
ProcedureDLL.l CH341WriteEEPROM(a.l,b.l,c.l,d.l,e.l)
ProcedureReturn CallFunctionFast(CH341WriteEEPROM,a,b,c,d,e)
EndProcedure
ProcedureDLL.l CH341WriteI2C(a.l,b.l,c.l,d.l)
ProcedureReturn CallFunctionFast(CH341WriteI2C,a,b,c,d)
EndProcedure
ProcedureDLL.l CH341WriteRead(a.l,b.l,c.l,d.l,e.l,f.l,g.l)
ProcedureReturn CallFunctionFast(CH341WriteRead,a,b,c,d,e,f,g)
EndProcedure
Procedure Open()
;Verbindung zum Chip herstellen... ChipIndex: 0= 1.Chip am USB, 1= 2.Chip, usw.
If (CH341OpenDevice(0)>0)
Debug "ok"
Else
Debug "nicht ok"
EndIf
EndProcedure
Procedure Close()
;Verbindung schliessen...
CH341CloseDevice(0)
EndProcedure
Procedure WriteToLCDControlReg(aByte.b)
Define BufferLen
BufferLen=1
;Write With A0=0 selects LCD control reg.
CH341MemWriteAddr0(0, @aByte, @BufferLen) ; Adr. 0 = Control Reg.
Delay(5) ; Wait 5 ms for controller to execute command
EndProcedure
Procedure WriteToLCDDataReg(Datas.s)
Define BufferLen,i.i,aChar.s
BufferLen=1
For i=0 To Len(Datas)-1 ;write one by one; LCD needs delays!
aChar=Mid(Datas, i + 1, 1)
; Write With A0=1 selects LCD Datas reg.
CH341MemWriteAddr1(0, @aChar, @BufferLen) ; Adr. 1 = Data Reg.
Delay(5) ; Wait 5 ms for controller to execute command
Next
EndProcedure
CH341DLLDLL_Init()
Open()
;-LCDInit
WriteToLCDControlReg(cmd_Function_Set | interface_8Bit)
Delay(10)
For i=1 To 3
WriteToLCDControlReg(cmd_Function_Set | interface_8Bit)
Next
WriteToLCDControlReg(cmd_Function_Set | Interface_8Bit | display_2lines | Font_5x8)
WriteToLCDControlReg(cmd_Display_On_Off | display_off | cursor_off | cursor_blink_off)
WriteToLCDControlReg(cmd_Clear_Display)
WriteToLCDControlReg(cmd_Entry_Mode_Set | cursor_Shift_Off | Cursor_Shift_right)
WriteToLCDControlReg(cmd_Display_On_Off | display_On | cursor_off | cursor_blink_off)
; ----
WriteToLCDDataReg("Hello World!")