Make the following changes
-Make blocking the first parameter in the constructor
-Add destructor and proper cleanup
-Add ready and wait_ready functions
Add a destructor to USBDevice to ensure that resources have been
properly released. Additionally add an assert in the destructor that
deinit has already been called. If it has not been called then
interrupts can still occur which may cause a crash.
Remove the option to block in USBDevice::connect since this
should be handled at a higher level. Also call init to ensure that
the USBDevice has been initalized.
Create the define MIN_DISCONNECT_TIME_US to be used as the amount of
time that must pass between connect and disconnect for the host to
reliably detect reconnection. Replace the wait calls delaying for this
value to wait_us to indicate the precision required. Finally, remove
the unnecessary calls to wait_ms in
repeated_construction_destruction_test.
When disconnecting in the middle of a setup packet USB stops working
even after being re-connected. This is because the setup packet
suspended endpoint events but nothing resumed endpoint events.
This patch adds code to resume endpoint events in the reset handler.
Add the helper function endpoint_remove_all which removes all added
endpoints. This is useful for class drivers switching between
different USB configurations.
Move the USBPhy header files into usb/device/USBPhy. Also move hal
and target USB files since mbed 2 does not compile when these files
are present without the USBPhy headers.
Directory restructure summary:
platform/USBPhy*
to usb/device/USBPhy/USBPhy*
hal/*
to usb/device/hal/*
targets/TARGET_Freescale/usb/*
to usb/device/targets/TARGET_Freescale/*
targets/TARGET_NXP/TARGET_LPC176X/usb/*
to usb/device/targets/TARGET_NXP/*
Make the following changes to improve stability:
-When disconnecting set address to disabled to prevent nacks
-Clear EP_SLOW one and only once for every interrupt where it is set_address
-Disable and clear control endpoint interrupts when disconnecting
Even thought the USB phy is disabled during disconnect, endpoints
still nack packets sent. This patch disables all endpoints so after
disconnect no USB traffic will be sent. This allows brief disconnects
of ~200us (or more) to be reliably detected by the host PC.
Update the USBCDC and USBSerial classes to the new API. This patch also
updates the blocking behavior to unblock at the appropriate times and
to let the processor sleep when blocking rather than busy waiting.
Add an allocation free linked list implementation. Additionally add
the class AsyncOp which provides blocking and wakeup funcionality
to simplify making asynchronous operations block.
Stalling endpoint 0 indicates the end of a control transfer.
Return immediately when this occurs rather than continuing processing.
In particular, this patch prevents status from erroneously being
sent when _request_setup returns false inside _complete_request.
Perform processing triggered by user callbacks when USB is being
unlocked rather than synchronously. This prevents recursive callbacks
which reduces stack usage. This also prevents state change inside
the user callback which makes the code easier to reason about.
Initialize the _transfer structure so the behavior is the same
regardless of prior memory contents. This fixes a hang during
USB testing when CI flags are used.
Remove the USBDevice function read_start and automatically start all
reads internally in USBDevice. This patch also renames the function
read_finish to read.