0

Adafruit TinyUSB library
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit TinyUSB library

by Pedrinbeep on Tue Aug 20, 2019 6:20 pm

Hi!

I´m trying to understand how to use the library TinyUSB works (https://github.com/adafruit/Adafruit_TinyUSB_Arduino) to make Adafruit Grand Central M4 working like a USB Drive when I press a button and not when is connected to PC/Mac, but I don't know how to do it.

Any help on this?

Thank you in advance.

Pedrinbeep
 
Posts: 8
Joined: Sun Jul 14, 2019 10:37 am

Re: Adafruit TinyUSB library

by franklin97355 on Tue Aug 20, 2019 7:51 pm

The TinyUSB library does not do what you want. I don't know exactly what it is you want but the M4's should be able to show up as USB drives to a computer with the proper uf2 file installed.

franklin97355
 
Posts: 21103
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Adafruit TinyUSB library

by Pedrinbeep on Fri Aug 23, 2019 3:06 pm

franklin97355 wrote:The TinyUSB library does not do what you want. I don't know exactly what it is you want but the M4's should be able to show up as USB drives to a computer with the proper uf2 file installed.


You are right, I'm explaining bad. I want to see an internal MicroSD card as USB drive when I press a button and not when is connected. I see the SDfat example but I don't really understand how to do it.

Thank you Franklin97355, and sorry for the bad explanation.

Pedrinbeep
 
Posts: 8
Joined: Sun Jul 14, 2019 10:37 am

Re: Adafruit TinyUSB library

by Pedrinbeep on Tue Aug 27, 2019 8:00 am

Hi! I'm still with this problem and not find the way to make it work. Anyone have an idea of how to do it?

Thank you in advance.

Pedrinbeep
 
Posts: 8
Joined: Sun Jul 14, 2019 10:37 am

Re: Adafruit TinyUSB library

by emtark on Wed Aug 28, 2019 7:27 pm

If I understand your question correctly - the msc_sdfat example can do what you need - just need to initialize the card when you push a button, not in the setup function.

How are you powering the board if not through USB? The example will allow you to read the SD card to the Arduino but if not connected via USB there are easier libraries to use for this application, which don't include all the extra code for USB.

emtark.
emtark
 
Posts: 5
Joined: Sat Apr 26, 2014 7:36 am

Re: Adafruit TinyUSB library

by Pedrinbeep on Thu Aug 29, 2019 10:39 am

emtark wrote:If I understand your question correctly - the msc_sdfat example can do what you need - just need to initialize the card when you push a button, not in the setup function.

How are you powering the board if not through USB? The example will allow you to read the SD card to the Arduino but if not connected via USB there are easier libraries to use for this application, which don't include all the extra code for USB.

emtark.


Yes, the board is powered with a battery and the microSD is also used for other things (datalogger) and need to initialize the card at the setup.

But I only want to make is accesible like USB Drive on PC/Mac with this library (or other library, but I don't know any library like this one for Arduino) and not when is plugged via USB, only with a button. I mean, what is the only part I need just to add with an if condition on a button to make the board working like that?

Pedrinbeep
 
Posts: 8
Joined: Sun Jul 14, 2019 10:37 am

Re: Adafruit TinyUSB library

by emtark on Thu Aug 29, 2019 6:55 pm

You could do a check for your button press inside your main loop, then if pushed initialize the USB.

You can also set the 'usb_msc.setUnitReady(true);' line to false in your setup(), then when you are ready for the PC/Mac to have access you can set it back to true. I am still in the process of understanding the TinyUSB library so hopefully there are others that can chime in with better suggestions.

emtark.
emtark
 
Posts: 5
Joined: Sat Apr 26, 2014 7:36 am

Please be positive and constructive with your questions and comments.