-
Notifications
You must be signed in to change notification settings - Fork 8
USBD add core-power and Vbus handle #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
21d87c3
84012d3
65231b0
5624172
c1cda4f
114158f
d9d1cf9
aff4105
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,16 +78,20 @@ static usbd_device *init(const usbd_backend_config *config) | |
_usbd_dev.backend = &usbd_stm32_otg_fs; | ||
_usbd_dev.config = config; | ||
|
||
//* stm32f4 use FS CID=0x1100, HS CID=0x02000600 | ||
//* stm32f7 0x3000, CID=0x00003100 | ||
const unsigned otg_hs_cid_boundary = 0x3000; | ||
|
||
if (config->feature & USBD_VBUS_SENSE) { | ||
if (OTG_FS_CID >= 0x00002000) { /* 2.0 HS core*/ | ||
if (OTG_FS_CID >= otg_hs_cid_boundary) { /* 2.0 HS core*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
/* Enable VBUS detection */ | ||
OTG_FS_GCCFG |= OTG_GCCFG_VBDEN; | ||
} else { /* 1.x FS core*/ | ||
/* Enable VBUS sensing in device mode */ | ||
OTG_FS_GCCFG |= OTG_GCCFG_VBUSBSEN; | ||
} | ||
} else { | ||
if (OTG_FS_CID >= 0x00002000) { /* 2.0 */ | ||
if (OTG_FS_CID >= otg_hs_cid_boundary) { /* 2.0 */ | ||
/* Disable VBUS detection. */ | ||
OTG_FS_GCCFG &= ~OTG_GCCFG_VBDEN; | ||
REBASE(DWC_OTG_GOTGCTL) |= DWC_OTG_GOTGCTL_BVALOEN | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,7 +235,7 @@ bool usbd_is_vbus(usbd_device *dev){ | |
|
||
void usbd_enable(usbd_device *dev, bool onoff){ | ||
if (!onoff) | ||
usbd_disconnect(dev, false); | ||
usbd_disconnect(dev, true); | ||
if (dev->backend->power_control) | ||
dev->backend->power_control(dev, (onoff)? usbd_paActivate : usbd_paShutdown ); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Look at the flow of control. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don`t understand you - enable(false) MUST not shutdown? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, i see, thank you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for your new code.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, see alredy. more trouble now bother me - cant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, resolve it. but not preferable way - not like what i write There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this was confused me too. disconnection MUST be provided before powerdown. but fro stm DWC core it is mean that USB enter to non-connectable state. imho, name 'disconnect' - not very suitable for this operation. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"//*" (IMO) Please C style comment only (code consistancy).
@danielinux @brabo what do you think?