Skip to content
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

Add SETUP_EP0_OUT_BUF(), to be used for OUT control transfers. #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions firmware/library/include/fx2usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ void usb_init(bool disconnect);
} while(0)

/**
* Configure EP0 for an IN or OUT transfer from or to `EP0BUF`.
* For an OUT transfer, specify `length` as `0`.
* Configure EP0 for an IN transfer from `EP0BUF`.
*
* Using this for an OUT transfer is deprecated, because it exposes a
* race condition. For OUT transfers please use one or more calls to
* `SETUP_EP0_OUT_BUF()` instead followed by a single call to `ACK_EP0()`.
* Do not call `ACK_EP0()` before processing all pending data in `EP0BUF`
*/
#define SETUP_EP0_BUF(length) \
do { \
Expand All @@ -64,6 +68,13 @@ void usb_init(bool disconnect);
EP0CS = _HSNAK; \
} while(0)

#define SETUP_EP0_OUT_BUF() \
do { \
SUDPTRCTL = _SDPAUTO; \
EP0BCH = 0; \
EP0BCL = 0; \
} while(0)

/**
* Acknowledge an EP0 SETUP or OUT transfer.
*/
Expand Down
Loading