FEZ Cobra - USB Detect via VBUS

On FEZ Min the USB device connector has VBUS exposed as IO36 - so one can detect a USB connection by looking at IO36, smart.

On Fez Cobra the VBUS is not exposed as an IO pin.

How to do the same trick her - with out mods to hardware?

VBUS is connected to a pin on EMX but I am not sure how to read that pin! I will check with our experts and get back to you

I am also looking forward for that answer… :slight_smile:

We still waiting… :wink:

Try this. It tells the status of the connection:
Microsoft.SPOT.Hardware.UsbClient.UsbController.GetController(0).Status
Running connected, otherwise, assume not connected.

Problem is here that one have to wait for e.g. Windows to open a connection… takes 30 sec.

What I want to know is if there is power on the VBUS from a USB master device or not - I do not care if it is windows or some other stuff - and I will not wait.

When my IO-pin say - yes, there is power - then I start up the MassStorage on the FEZ.

When power is gone I returen the e.g. SD Card to the FEZ system for local use.

That can be done on a FEZmini on an IO pin.

It is connected to pin 1.30 on the processor.
To read it, do something like this:


// init
Register PINSEL3 = new Register(0xE002C00C);
PINSEL3 .ClearBits(3 << 28); // gpio
Register PINMODE3 = new Register(0xE002C04C);
PINMODE3.SetBits(3 << 28); // pull down
Register FIO1DIR = new Register(0x3FFFC020);
FIO1DIR.ClearBits(1 << 30); // input
Register FIO1PIN = new Register(0x3FFFC034);

// to read
bool connected = (FIO1PIN.Read() & (1 << 30)) != 0;

This code worked and was nice…

But now ½ of the code is missing !!!

Does any one have it - I need it again.

Better?