-
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
Open
alexrayne
wants to merge
8
commits into
insane-adding-machines:master
Choose a base branch
from
alexrayne:alexrayne-add-usbd-power
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
21d87c3
+common:regs:dwc - append some USB FS power and session control bits …
alexrayne 84012d3
+usbd:session callback - add this handle on session start/stop events…
alexrayne 65231b0
*usbd:session - fixed code style, linked disconnect and enablevia fea…
5624172
!usbd:session:usbd_enable - fixed disconnection on disabling
alexrayne c1cda4f
+usbd:is_enabled - enhanse usbd_backend.power_control to allow core s…
alexrayne 114158f
!usbd:otg init:HS detection - valid CID for stm32f7
alexrayne d9d1cf9
!usbd:powerdown:enable, disconnect - recursion release
alexrayne aff4105
!usbd:powedrown:disconnect -keep disconnection status during powerdow…
alexrayne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,16 @@ enum usbd_speed { | |
|
||
typedef enum usbd_speed usbd_speed; | ||
|
||
/** Optional features */ | ||
enum usbd_backend_features{ | ||
USBD_FEATURE_NONE = 0 | ||
, USBD_PHY_EXT = (1 << 0) | ||
, USBD_VBUS_SENSE = (1 << 1) | ||
, USBD_VBUS_EXT = (1 << 2) | ||
//* provide usb-core auto power-up/down on connect/disconnect | ||
, USBD_USE_POWERDOWN = (1 << 3) | ||
}; | ||
|
||
struct usbd_backend_config { | ||
/** Number of endpoints. (Including control endpoint) */ | ||
uint8_t ep_count; | ||
|
@@ -145,13 +155,8 @@ struct usbd_backend_config { | |
/** Device speed */ | ||
usbd_speed speed; | ||
|
||
/** Optional features */ | ||
enum { | ||
USBD_FEATURE_NONE = 0, | ||
USBD_PHY_EXT = (1 << 0), | ||
USBD_VBUS_SENSE = (1 << 1), | ||
USBD_VBUS_EXT = (1 << 2) | ||
} feature; | ||
/** Optional features see usbd_backend_features*/ | ||
unsigned int feature; | ||
}; | ||
|
||
typedef struct usbd_backend_config usbd_backend_config; | ||
|
@@ -279,7 +284,7 @@ enum usbd_transfer_flags { | |
USBD_FLAG_PACKET_PER_FRAME_MASK = (0x3 << 5) | ||
}; | ||
|
||
typedef enum usbd_transfer_flags usbd_transfer_flags; | ||
typedef unsigned char usbd_transfer_flags; | ||
|
||
/** | ||
* USB Transfer status | ||
|
@@ -431,6 +436,8 @@ typedef void (*usbd_set_interface_callback)(usbd_device *dev, | |
typedef void (*usbd_setup_callback)(usbd_device *dev, uint8_t addr, | ||
const struct usb_setup_data *setup_data); | ||
|
||
typedef void (* usbd_session_callback)(usbd_device *dev, bool online); | ||
|
||
typedef void (* usbd_generic_callback)(usbd_device *dev); | ||
|
||
/** | ||
|
@@ -515,6 +522,16 @@ void usbd_register_resume_callback(usbd_device *dev, | |
void usbd_register_sof_callback(usbd_device *dev, | ||
usbd_generic_callback callback); | ||
|
||
/** | ||
* Register session connect/disconnect callback | ||
* with USBD_VBUS_SENSE feature primary need for cable | ||
* plug detection | ||
* @param[in] dev USB Device | ||
* @param[in] callback callback to be invoked | ||
*/ | ||
void usbd_register_session_callback(usbd_device *dev, | ||
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. session callback facility look like a good idea. |
||
usbd_session_callback callback); | ||
|
||
/** | ||
* Register SET_CONFIGURATION callback \n | ||
* stack will invoke @a callback when ever SET_CONFIGURATION is received | ||
|
@@ -643,6 +660,30 @@ uint8_t usbd_get_address(usbd_device *dev); | |
*/ | ||
usbd_speed usbd_get_speed(usbd_device *dev); | ||
|
||
|
||
/** | ||
* Get status of connected cable. | ||
* @param[in] dev USB Device | ||
* @return true - cable connected, and Vbus active | ||
*/ | ||
bool usbd_is_vbus(usbd_device *dev); | ||
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. ability to know VBUS state also look like a good idea too. |
||
|
||
/** | ||
* Controls power state of usb-core and PHY | ||
* @param[in] dev USB Device | ||
* @param[in] onoff - true turn on device in action, and power PHY | ||
* false disconnects, disable PHY and stops usb-core | ||
*/ | ||
void usbd_enable(usbd_device *dev, bool onoff); | ||
|
||
/** | ||
* Checks power state of usb-core and PHY | ||
* @param[in] dev USB Device | ||
* @param[in] \return true - device in action, and power PHY | ||
* false - disabled PHY and stops usb-core | ||
*/ | ||
bool usbd_is_enabled(usbd_device *dev); | ||
|
||
/** | ||
* Perform a transfer | ||
* | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why?
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.
possibly i
ve got a warning here? enum and typedef - with same name. it
s confusing me, i newer see such trick.i`ve saw overriding enum item name with macro definition, but override enum by typedef - is it vlalid practice for C?
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.
@alexrayne https://stackoverflow.com/questions/17918380/typedef-and-enum-with-same-name
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.
yep, i know about namespaces, and that code was compiled succesfully.
when i ask about "valid practice for C" i mean - is it good? is it helpful? can it lead to some errors?
the name "usbd_transfer_flags" imho nott very suitable for enum. such name also can be imagine for struct of a binary set of flags.
anyway, if you insist - let`s revert this typedef back to code.
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.
you forgot to denote
+typedef unsigned char usbd_transfer_flags;
ARMCC compiler generates warning when we try to assign to enum variable integer value (with set of flags).
therefore i denote for usbd_transfer_flags as numeric type