I am trying to learn about Android open accessory, because I am a newbie to ARM programming. So I want to put everything up from bottom, use free open source tools and code.
- Compiler: yagarto GNU ARM
- NXP LPC1768 demo board: from a company named "waveshare"
- USB driver example: NXP hostlite
- Android phone is NEXUS 4, Android 4.2.2 version
The reference example NXP hostlite is small and clear. But I can not set accessory correctly in my devised code.
Description:
- Inserting detection, and USB reset ---- OK
- Read device descriptor ---- OK
- Set address to 1, change maximum-pakcet-size to 64 ----- OK
- Read protocol, it returns 0x0002 . this means AOA v2 is supported. ----OK
- Write identifying string , 5 of them, ----- OK
- Set accessory mode. I can see there is a port disconnect and then a port connect interrupt nitification in my Log print-out, ---- so seems this command is also OK
- But when I try to read device descriptor now, it returns a Completion code of 5 to me when TD_SETUP is sent out. CC = = 5 means a stall or no response. So I can't judge if the VID, PID is OK or not. ---- Fail
According to AOA protocol, after setting accessory mode, the device would re-enumerate itself.
So my question is: What should I do for re-enumeration?
- Wait there until it finish itself; Do I need a delay?
- Or reset the device and then read device descriptor again?(I don't think so, because the returned VID/PID are not correct.)
- Or any suggestion you would like to share with me.