USBkey mass storage question

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I recently purchased an Atmel USBkey dev kit (AT90USB1287) and have been trying to under stand how the mass storage example works so I can modify it (and save the USB driver-foo I do not understand) to work when not connected to a computer and display text files to an LCD display. The example code is the demo project the board comes programmed with (also found here I think http://www.atmel.com/dyn/resourc... ) My general idea at the moment is just to display text to the lcd and "page" up and down via buttons on GPIO.

As far as I understand, the current setup loops forever in the scheduler waiting for USB stuff to happen from the host computer. The driver stuff is really confusing to me. Can I detect if the device is not connected to the computer and if so break to my own code?

Also, is it even going to be possible to use the FAT code in the example to manually open a file/show files in a directory? Looking through the code I don't see an easy way to list all the files in a directory or even work with a directory but maybe I just need to read the code a bit more. I could switch to an SD cad with Fatfs which I have read about but then it looks like I would lose USB support which would be nice.

Thank you for your advice

John

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You may want to switch to LUFA which is better designed/documented and has the major advantage that you can directly ask the author (Dean="abcminiuser") here about anything you don't understand. I think he's said previously that it'd be easy to add FatFs (to provide FAT support) to it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

The mass storage demos normally are just attaching a flash storage to the computer. This means the computer is doing all the FAT filesystem access, the USB stick is just shovelling bits between the USB and FLASH.

If you want to read/write the files in FLASH then you'll need to add FAT support to the code. The USB demo seems to have a 'fat.h' file, but I don't think there is actually anything to go with it?

Quote:
Can I detect if the device is not connected to the computer and if so break to my own code?

There is some docs at /USBKEY-series6-ms_df-2_0_1-doc/doc/html/index.html that might help.

There it docs the usb_drv.h file, which has the function 'Is_usb_vbus_high()'. This tells you if the voltage is present on the USB bus, which would mean you are powering the device not from USB.

Note that if someone was powering your device through a USB power adaptor this would still call the device 'connected'. Which is annoying when you see it done; you try to charge a device for instance that charges through USB, but since it sees USB is connected it disables the user interface.

You might want to check if you actually get to some stage of the code that enumerates the device instead.

Regards,

-Colin