New USB Device Library Released!

General discussion on Libstock website & codes posted on this website.
Author
Message
User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: New USB Device Library Released!

#31 Post by filip » 15 Apr 2013 11:26

Hi,
I would like to use a USB port in my device for both communicating with a PC application and for programming using the bootloader. Can the PIC32MX7 bootloader be used with the Fusion v7 board? It appears that the wiring is the same for the USB Device port, except for the USB-ID pin. I would like to test all my functions on one platform, emulating the final project where there will only be one USB port.
Yes, the same bootloader can be used on both of these boards.

I would need bi-directional comms, like ... USB port?
You could develop the UART bootloader for this MCU, but since it has a lots of Flash memory it would be slow if some complex project/HEX file is uploaded.

Regards,
Filip.

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: New USB Device Library Released!

#32 Post by Const50 » 22 Apr 2013 10:19

So. A month of fighting with new USB device library showed:
1. Absolutely raw product. Very much errors in source and text, very whimsical constructions, type "to dress the trousers over a head", the total absent of any comments and explanations.
2. Absolute incompatibility with previous library, result - impossibility to use old good ajusted USB descriptor file and impossibility to make own new because there is no explanations how to do it. For explanations the developers refer to USB.ORG site. But how about firm slogan "Compiler does all the work for you. Beginners are experts"?
3. Standard promises to improve everything in nearest future "when a schedule will allow it". It means and experience prompts it - never.
4. The basic for new library implementation - "in order to support more advanced USB features". But detailed explanations of the improvements and "more advanced features" are absent. What for made unworking library?? As result - the new library impossible to use. In old library doesn't work as polling so and interrupt modes!!
5. Why the developers don't made two variants: simple old with interrupts and advanced new?? Now in fact we have no new, no old.

I've loose $200, 8 month and business reputation.
Who next?

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: New USB Device Library Released!

#33 Post by dejan.odabasic » 22 Apr 2013 13:26

Hello,

For any deficiencies regarding library or it examples, please send us your suggestions and reports at support@mikroe.com

Provided projects are commented and library functions are described in separate Library help file.
Lack of comments in TouchPanel example will be corrected soon.

This library is completely new library and unrelated to USB HID library.

Simply by comparing the descriptor files from two examples(HID library and USB Device library), should be enough to see differences in descriptor file.
The only difference is that some bytes are not grouped in logic parts.
USB_Desc1.png
USB_Desc1.png (57.06 KiB) Viewed 181846 times
USB_Desc2.png
USB_Desc2.png (19.75 KiB) Viewed 181846 times
Basic understanding of USB protocol would help greatly to all USB oriented developers, that's why we suggest USB.org as quality source of documentation.

Best regards.

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: New USB Device Library Released!

#34 Post by Const50 » 22 Apr 2013 15:19

Dejan,

I hope you know the fundamental, absolute and basic law of electronics: DON'T TOUCH TILL IT'S WORKING. the same for programming. What for you made new library, which destroyed our all previous work? Why you don't finished (as promised a long time) old variant of USB HID lib in Interrupt mode which we used on 16 and 18 family without problems last a little years? Whom need your new advanced library, if we didn't find this advantages, only problems.
That what you made, I'd exactly evaluate in Russian if you'd understand it.

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: New USB Device Library Released!

#35 Post by dejan.odabasic » 23 Apr 2013 11:48

Hello,

Release of the new library doesn't influence the old library or a project that was developed with it in any way.
I warmly suggest you to read the help regarding the new USB library and follow the comments in the code, you will learn everything you need to know about it.

Best regards.

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: New USB Device Library Released!

#36 Post by Const50 » 23 Apr 2013 13:45

Hi.

I read HELP from early morning till late evening. And what I see:
Upper USB library - it is an old one, which you couldn't implement for PIC32 a long time till present time, despite of many promises to do it. Lower ones - USB PIC32 library, which I fight now with. You propose to read HELP file. O'K. I try to understand what do new library functions (are they library functions?) USBDev_HIDInit and very close in name to old's USB lib function HIDWrite - USBDev_HIDWrite. What I see in HELP? I see nothing, no description. Another ones described literally in two words.
I tell you just about it: impossible to understand how it works if there is no detailed descriptions and comments! What means _USBHID_CONFIG_DESC_SIZ >> 8?? And many another whims without explanations.
Attachments
Lib32.jpg
Lib32.jpg (61.96 KiB) Viewed 181828 times

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: New USB Device Library Released!

#37 Post by dejan.odabasic » 24 Apr 2013 17:31

Hello,

USB Library functions are described in compiler help file, section USB Library.
Additionally installed libraries, like USB Devise library, have separate help file.
USB Device help file is located in: ..compiler\Packages\USB_Device_PIC32\help

USBDev_HID functions are described in USB Device Library.chm - select compiler>HID section.
Const50 wrote:What means _USBHID_CONFIG_DESC_SIZ >> 8??
Please take a look at Bitwise Operators section of compiler help file.

Best regards.

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

Re: New USB Device Library Released!

#38 Post by anikolic » 29 Apr 2013 12:03

Web Department Manager

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: New USB Device Library Released!

#39 Post by Const50 » 29 Apr 2013 15:28

What difference with the same, issued at March 25 (see page 1)?

aCkO
Posts: 1119
Joined: 14 Feb 2011 04:07
Location: Bar, Montenegro

Re: New USB Device Library Released!

#40 Post by aCkO » 29 Apr 2013 15:33

Const50 wrote:What difference with the same, issued at March 25 (see page 1)?
This one is for PIC :)

Regards

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: New USB Device Library Released!

#41 Post by Const50 » 01 May 2013 03:18

There is a test program for sending bytes to and from PC:

Code: Select all

program HIDDevice_Custom

dim buffer as byte[64] 	' Buffer of 64 bytes

' USB interrupt service routine
sub procedure USB0Interrupt() iv IVT_USB_1 ilevel 7 ics ICS_SRS  
  USBDev_IntHandler()		' Call library interrupt handler routine
end sub

' Callback function which will be called on received packet
sub procedure DataReceived(dim ep as byte, dim size as word)
  USBDev_SendPacket(1, @buffer, 64)	'Send 64 bytes of data from buff
  ' Prepere buffer for reception of next packet
  USBDev_SetReceiveBuffer(1, @buffer)
end sub


main:
  
  AD1PCFG = 0xFFFF		' Configure AN pins as digital I/O
  USBDev_HIDInit()		' Initialize HID Class

  ' Register callback function which will be called on received packet
  USBDev_RegisterDataReceivedHandler(@DataReceived)

  USBDev_Init()  		' Initialize USB device module
 
  USBIE_bit = 1			' Enable USB device interrupt
  IPC11 = longword(7) << USBIP0
  EnableInterrupts()

  ' Wait until device is configured (enumeration is successfully finished)
  while(USBDev_GetDeviceState() <> _USB_DEV_STATE_CONFIGURED)
  wend

  ' Set receive buffer where received data is stored
  USBDev_SetReceiveBuffer(1, @buffer)

  while(1) 			' Infinite loop
  wend

end.
Who can prompt, how to modify it to send two words to PC?
What is function of Callback functions here?

aCkO
Posts: 1119
Joined: 14 Feb 2011 04:07
Location: Bar, Montenegro

Re: New USB Device Library Released!

#42 Post by aCkO » 01 May 2013 04:58

In this example data is sent in 64 bytes packets. If you want to send words you will have to send high byte, then low byte of each word and reassemble the bytes to words on the other side.
Callback functions are similar to events in C#, VB or Delphi.

Regards

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: New USB Device Library Released!

#43 Post by Const50 » 01 May 2013 05:13

If on the PC side should be my own program, where I send the words, would be no problems. But there there is standard mouse driver.
Will be enough to understand the driver, what I send to it if in descriptor will be the lines:

Code: Select all

  0x09, 0x30,             ' Usage (X)
  0x09, 0x31,             ' Usage (Y)
  0x16, 0x00, 0x00,       ' Logical Minimum (0)
  0x26, 0x00, 0x7D,       ' Logical Maximum (32000)
  0x75, 0x10,             ' Report Size: 16-bit field size
  0x95, 2,                ' Report Count (2)
  0x81, 0x02,             ' Input (Data, Var, Abs)
?

aCkO
Posts: 1119
Joined: 14 Feb 2011 04:07
Location: Bar, Montenegro

Re: New USB Device Library Released!

#44 Post by aCkO » 01 May 2013 05:49

Did you check touchpad example from: http://www.libstock.com/projects/view/5 ... ce-library?

Regards

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: New USB Device Library Released!

#45 Post by Const50 » 01 May 2013 07:37

Yes I did it. But very difficult to understand the 26 pages sample program code without any explanations and comments. As I understood, there is been used a some driver, but how it is implemented in the source code I can't understand. From another hand I heard there are simple programs for mouse with absolute coordinates. In the touchpad sample is been applied relative coordinates...

Post Reply

Return to “Libstock Discussion”