10 years, 3 months ago.

USB Stick removal

HI Norimasa, thanks for sharing this, and for doing the KLXX drivers port. Fantastic. Still working through the structure of it. I've pulled it in to a FRDM-KL25z project, modified the board for USB Host powering and using it as part of AnalogIn for building a logger. Reading adc and writing results to a USB stick.
I have writes going through to the USB stick.
Two items that I'm wondering about
1) detecting removal of a USB stick.
2) starting up with a USB stick - and detecting the insertion. I'm doing a check in USBHostMSD msd("usbAa");

main.cpp

 ..
  if (!msd.connected())     pc.printf("  USB Flash drive removed.\n\r");
..

however it doesn't detect when the USB Stick is removed.
I am opening and closing the stream with no USB stick and that is working.
Should I be looking at some other function like a fprintf() fail

The other area is it requires the USB stick to be inserted before it completes initialization.
That is if I start the program with no USB Stick it waits for a USB stick to be inserted before it completes the initialization of msd("usbAa") The seems to be implicit in the constructor .. unless I'm missing something.

USBHostMSD.cpp

USBHostMSD::USBHostMSD(const char * rootdir) : FATFileSystem(rootdir)
{

Many thanks for any insights from anybody

Question relating to:

Simple USBHost library for Nucleo F446RE/F411RE/F401RE FRDM-KL46Z/KL25Z/F64F LPC4088/LPC1768 F401RE, F411RE, F446RE, K64F, KL25z, kl46z, USBHOST, UVC
Be the first to answer this question.