Content originally posted in LPCWare by gregd on Sat Apr 02 09:51:37 MST 2016
Hello,
I am working on developing a USB Mass Storage Host application running on the LPC4350 using LPCOpen v2.12 with IAR EWARM. I have an application based off the Mass Storage Host example using LPCUSBLIB. In my application, I need to periodically power up the USB and thumb drive write some data to a file and then power down the USB and thumb drive. Everything works fine for 2 attempts, but on the third attempt I start running out of memory when Pipe_ConfigurePipe (Pipe.c) calls USB_Memory_Alloc. The problem seems to be that USB_Mem_Buffer is not being cleared out when I shut down the USB Host. As a test, I added code to force clearing out USB_Mem_buffer but then I started having problems in AllocQhd (EHCI.c) with HCD_STATUS_NOT_ENOUGH_ENDPOINT. As far as I can tell, the memory and pipes handling is not cleared out unless an interrupt triggers the USB_Host_DeEnumerate() function through the PortSatusChangeIsr() function.
What is the proper sequence to shut down the Mass Storage USB Host and clear out all memory/resource allocations to allow a clean restart later. My application is very power sensitive and must only power up the USB host periodically.
Here is the current sequence I am using:
Chip_USB1_Init();
USB_Init(FlashDisk_MS_Interface.Config.PortNumber, USB_MODE_Host);
USB_ReadWriteFile();
USB_Host_SetDeviceConfiguration(FlashDisk_MS_Interface.Config.PortNumber, 0);
USB_Disable(FlashDisk_MS_Interface.Config.PortNumber, USB_MODE_Host);
Thanks,
Greg Dunn