[<<][staapl][>>][..]
Mon Jun 1 10:44:27 CEST 2009

usb

So, how to tackle USB.

On the PIC this boils down to dealing with endpoint buffers, so let's
write some abstractions to deal with those.

We can use the simplest scheme: no double buffering, one endpoint and
fixed buffers for IN and OUT.

An endpoint buffer descriptor is a 4-byte structure:

  0 STAT  status register
  1 CNT   buffer elements
  2 ADR   buffer address

This descriptor resides in the USB RAM, which is a dual ported memory
bank accessible by the MCU (microcontroller unit) and the SIE (serial
interface engine).  Ownership is governed by the UOWN bit in the STAT
register for each buffer.  The buffer descriptor addresses are mapped
to buffer descriptor registers when the UEPn bit is set (endpoint
enable), or to RAM when the endpoint is disabled.

The STAT register's contents depend on wheter the MCU or SIE owns the
endpoint buffer.

           7    6    5     4      3     2     1   0
SIE mode  UOWN  -   PID3 PID2   PID1  PID0   BC9 BC8
MCU mode  UOWN DTS  KEN  INCDIS DTSEN BSTALL BC9 BC8


3222222634222626262222263

Jun  1 13:21:15 zzz kernel: [415980.152170] usb 4-1.3: new full speed USB device using ehci_hcd and address 95
Jun  1 13:21:15 zzz kernel: [415980.224150] usb 4-1.3: device descriptor read/64, error -32
Jun  1 13:21:15 zzz kernel: [415980.400121] usb 4-1.3: device descriptor read/64, error -32
Jun  1 13:21:15 zzz kernel: [415980.576090] usb 4-1.3: new full speed USB device using ehci_hcd and address 96
Jun  1 13:21:15 zzz kernel: [415980.648072] usb 4-1.3: device descriptor read/64, error -32
Jun  1 13:21:15 zzz kernel: [415980.824042] usb 4-1.3: device descriptor read/64, error -32
Jun  1 13:21:15 zzz kernel: [415981.000135] usb 4-1.3: new full speed USB device using ehci_hcd and address 97
Jun  1 13:21:16 zzz kernel: [415981.408010] usb 4-1.3: device not accepting address 97, error -32
Jun  1 13:21:16 zzz kernel: [415981.480547] usb 4-1.3: new full speed USB device using ehci_hcd and address 98
Jun  1 13:21:26 zzz kernel: [415991.888009] usb 4-1.3: device not accepting address 98, error -110
Jun  1 13:21:26 zzz kernel: [415991.888255] hub 4-1:1.0: unable to enumerate USB device on port 3


It seems to try 5 times to reset the device.
Apparently we need to send something back.

In [1], section 8.3.3 (usb enumeration) i find this:

 - host sends USB RESET
 - host sends GET DESCRIPTOR to find out


After URSTIF (6) there's ACTVIF (4).  It looks like we need to send
something back, but what?

Maybe [2] will help.  It contains the USB stack for PIC18.



[1] http://www.elsevier.com/wps/find/bookdescription.cws_home/714114/description#description
[2] http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en540668



[Reply][About]
[<<][staapl][>>][..]