unsigned char readbuff[8] absolute 0x280; // Buffers should be in USB RAM, please consult datasheet
unsigned char writebuff[8] absolute 0x288;
void main() {
char cnt;
ANSEL=0; // CONFIGURE ALL PORTS FOR DITITAL I/O
ANSELH=0; // NEVER DO THIS IN REAL LIFE. UNUSED PINS MUST BE LEFT ANALOG INPUTS
HID_Enable(&readbuff,&writebuff); // Enable HID communication
while(1)
{
while(!HID_Read());
for(cnt=0;cnt<8;cnt++)
writebuff[cnt]=readbuff[cnt];
while(!HID_Write(&writebuff,8));
}
}
void interrupt(){
USB_Interrupt_Proc(); // USB servicing is done inside the interrupt
}
unsigned char readbuff[8] absolute 0x280; // Buffers should be in USB RAM, please consult datasheet
unsigned char writebuff[8] absolute 0x288;
void interrupt (void)
{
if (PIR1.TMR1IF!=0) {PIR1.TMR1IF=0; TMR1INT_Handle();}
if (PIR2.USBIF!=0) USB_Interrupt_Proc();
}
Please, update your version to 5.30.Thanks nice TUT,
I am using mikroC ver. 8.1.0.0 which version you are using in this TUT ? because I have not such a device in list that u r using here, and also non of USBdis.c file shown in source folder. . .
This code for main program. You no need to edit USBdsc.c. It was generated by MikroCThe code above is given for USBdsc.c is where to past in that file? there is number of written code here?
Yes. Little bit later. It will much difficult. Wait, please.Hello!! Easy Rider Can You tell me how to make GUI to send data and receive data from and to PC using Visual Basic.
For Your Code....
Module DLL_declare
Public Declare Function HID_OpenDevice Lib "HID_Lib_Plus.dll" (ByVal PID As Integer, ByVal VID As Integer, ByVal VersionNumber As Short, ByVal Index As Short) As Integer
Public Declare Function HID_CloseDevice Lib "HID_Lib_Plus.dll" (ByVal Handle As Integer) As Integer
Public Declare Function HID_ReadDevice Lib "HID_Lib_Plus.dll" (ByVal Handle As Integer, ByVal buffer() As Byte, ByVal Len As Integer) As Integer
Public Declare Function HID_WriteDevice Lib "HID_Lib_Plus.dll" (ByVal Handle As Integer, ByVal buffer() As Byte, ByVal Len As Integer) As Integer
Public Declare Function HID_DeviceTest Lib "HID_Lib_Plus.dll" (ByVal PID As Integer, ByVal VID As Integer, ByVal VersionNumber As Short, ByVal Index As Short) As Integer
Public Declare Function HID_GetInputReport Lib "HID_Lib_Plus.dll" (ByVal Handle As Integer, ByVal buffer() As Byte, ByVal Len As Integer) As Integer
Public Declare Function HID_SetOutputReport Lib "HID_Lib_Plus.dll" (ByVal Handle As Integer, ByVal buffer() As Byte, ByVal Len As Integer) As Integer
Public Declare Function HID_GetManufacturerString Lib "HID_Lib_Plus.dll" (ByVal Handle) As String
Public Declare Function HID_GetProductString Lib "HID_Lib_Plus.dll" (ByVal Handle) As String
Public Declare Function HID_GetSerialNumberString Lib "HID_Lib_Plus.dll" (ByVal Handle) As String
End Module
Public check_connection_thread As New System.Threading.Thread(AddressOf check_connection)
Public Const VID As Integer = 8755 ' decimal value of VID
Public Const PID As Integer = 8197
Public Const vers As Short = 1
Public Const index As Short = 0
Module MainModule
Public Sub check_connection()
Do
If HID_DeviceTest(PID, VID, vers, index) <> 0 Then
MsgBox("CONNECTED!")
End If
System.Threading.Thread.Sleep(1000)
Loop
End Sub
End Module
check_connection_thread.Start()
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?