USB Connect/Disconnect Hooks

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

USB Connect/Disconnect Hooks

Post by Tabulous »

is there anyway to get these notifications ? i.e. when USB is inserted get a notification callback ?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB Connect/Disconnect Hooks

Post by Giovanni »

You get a callback on enumeration, you could try sensing the 5V for insertion (using EXT may be) if your board supports that.

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: USB Connect/Disconnect Hooks

Post by Tabulous »

Giovanni wrote:You get a callback on enumeration, you could try sensing the 5V for insertion (using EXT may be) if your board supports that.

Giovanni


what callback is that ? the usb_event ?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB Connect/Disconnect Hooks

Post by Giovanni »

The USB driver does not support callbacks for insertion. You can use the EXT driver IF the 5V can be detected on an input pin.

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: USB Connect/Disconnect Hooks

Post by Tabulous »

Is there any technical reason why having connect / disconnect notification in the driver is an issue ?

To me it seems logical to have this ? i know the ST driver as something to support this
mobyfab
Posts: 484
Joined: Sat Nov 19, 2011 6:47 pm
Has thanked: 21 times
Been thanked: 31 times

Re: USB Connect/Disconnect Hooks

Post by mobyfab »

In my case I just connect the 5v USB to an npn transistor and use it to pull a gpio down.

When the gpio goes down I call usbConnectBus which pulls D+ up using a pin, and vice versa.

Works fine using the pal or exti driver :)
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB Connect/Disconnect Hooks

Post by Giovanni »

Tabulous wrote:Is there any technical reason why having connect / disconnect notification in the driver is an issue ?

To me it seems logical to have this ? i know the ST driver as something to support this


Because the feature is not necessarily present in the USB peripheral.

Giovanni
Post Reply