Commit Graph

98 Commits (4625221f1e00df13412e5a0217d8dc9a4018ac28)

Author SHA1 Message Date
Kevin Bracey 2fbbd9d2ca Introduce Semaphore::acquire methods
Deprecate wait() in favour of acquire(), try_acquire(),
try_acquire_for() and try_acquire_until().

Brings Semaphore more into line with CMSIS-RTOS 2 (which uses "acquire"),
itself (as it has "release"), and other classes having "try", "try for"
and "try until".

Also steps away from vague "wait" term - the primary operation here is
to acquire the semaphore, and this will of course sleep.
2019-05-28 17:02:06 +03:00
Martin Kojtal d299b3fc8b
Merge pull request #9443 from juhaylinen/usbcdc_ecm
Add USBCDC_ECM class
2019-05-20 10:30:19 +01:00
Martin Kojtal 3ea1c56124
Merge pull request #10147 from kjbracey-arm/atomic_bitwise
Assembler atomics
2019-05-13 14:18:05 +01:00
Kevin Bracey 87396e0bf6 Assembler atomics
Reimplement atomic code in inline assembly. This can improve
optimisation, and avoids potential architectural problems with using
LDREX/STREX intrinsics.

API further extended:
* Bitwise operations (fetch_and/fetch_or/fetch_xor)
* fetch_add and fetch_sub (like incr/decr, but returning old value -
  aligning with C++11)
* compare_exchange_weak
* Explicit memory order specification
* Basic freestanding template overloads for C++

This gives our existing C implementation essentially all the functionality
needed by C++11.

An actual Atomic<T> template based upon these C functions could follow.
2019-04-26 13:12:35 +03:00
Russ Butler 3a891f9bfe Fix USB control transfers using small size
Fix support for wMaxPacketSize values other than 64 for endpoint 0.
2019-04-24 11:12:40 -05:00
Martin Kojtal 6b9d1573fb
Merge pull request #10096 from fkjagodzinski/test-usb-hid
Add USB HID tests
2019-04-17 14:06:51 +01:00
Filip Jagodzinski 565ceb0048 USBHID: Fix the initial HID report read operation
The first 4 bytes received were lost due to a wrong address.
Read the output report into HID_REPORT.data.
2019-04-09 17:03:21 +02:00
Russ Butler 2986b3af7c Fix doxygen comment in USBDevice
Update the doxygen to correctly describe the return value of
endpoint_read_result.
2019-04-08 17:30:22 -05:00
Martin Kojtal e7987a9f04
Merge pull request #10166 from cmonr/astyle-fix
Travis CI: Tweak astyle to not over-exclude files
2019-03-22 06:36:07 +01:00
Martin Kojtal f99431f7c2
Merge pull request #9444 from maciejbocianski/usb_msd_tests
Usb msd tests
2019-03-21 10:42:55 +01:00
Cruz Monrreal II a1c047aba4 Added missing astyle corrections for usb/device/targets/* 2019-03-20 12:57:36 -05:00
Juha Ylinen 4b714597bf Fix mutex issue 2019-03-13 12:20:46 +02:00
Juha Ylinen 87f2f7f93f USBCDC_ECM: Add receive functionality
Handle SET_ETHERNET_PACKET_FILTER request
2019-03-13 12:17:37 +02:00
Juha Ylinen fc00718917 USBCDC_ECM: send connection notifications to the host
Fix build issues after rebase
2019-03-13 12:17:37 +02:00
Juha Ylinen e7416db621 Fix USBCDC_ECM descriptors
Replace static arrays used for iMAC and config descriptor with class members
Minor coding style fixes
2019-03-13 12:17:37 +02:00
Juha Ylinen 4e4653b7d4 Add USBCDC_ECM class
Add initial Ethernet over USB communication support using
the ECM (Ethernet Control Model) subclass of USB CDC.
2019-03-13 12:17:37 +02:00
Cruz Monrreal 3d1b55da36
Merge pull request #9879 from c1728p9/usb_sleep_lock
Lock sleep when USB is initialized
2019-02-28 19:56:41 -06:00
Russ Butler 8ffbe5c603 Lock sleep when USB is initialized
None of the USB drivers currently support entering deep sleep mode
while USB is active. To protect USB from malfunctioning lock deep
sleep in USBPhyHw::init.
2019-02-28 15:21:23 -06:00
Maciej Bocianski 7ff689be20 Add USB mass storage test 2019-02-27 17:18:41 +01:00
Maciej Bocianski 0cd9d24d08 USBMSD: Add media removal event check function 2019-02-27 17:18:39 +01:00
Michael Schwarcz 53a8cb7513 Add mbed_lib.json to usb folder 2019-02-27 11:47:35 +02:00
Russ Butler 6527cf2bad Update files to include SPDX-License-Identifier
Update the header of all files to use a newer license template which
includes SPDX-License-Identifier.
2019-02-22 10:53:24 -06:00
Russ Butler 9f116d9f33 Applied more astyle fixes 2019-02-22 10:53:24 -06:00
Russ Butler 005df3559c Applied suggested astyle fixes 2019-02-22 10:53:23 -06:00
Russ Butler 8d731561cf Remove inclusion of mbed.h from USB
Remove mbed.h from USB files and fix the build errors this causes.
This is required to pass CI.
2019-02-22 10:53:23 -06:00
bcostm a98eb739b1 STM32F7 USB: add NUCLEO_F756ZG in pins definition 2019-02-22 10:53:23 -06:00
bcostm e96b8a4803 STM32F7 USB: change VBUS pin for DISCO_F746NG FS 2019-02-22 10:53:22 -06:00
bcostm 82498cf3f8 STM32L4 USB: add pins definition for STM32L496/L4R5 MCUs 2019-02-22 10:53:22 -06:00
TomoYamanaka b3dec25ceb Renesas : Implement USB Device feature
I implemented USB Device feature for Renesas mbed boards.
The code referenced the following code as a starting point and is implemented it by inheritting USBPhy same as other boards.
(mbed-os\features\unsupported\USBDevice\targets\TARGET_RENESAS)
2019-02-22 10:53:22 -06:00
bcostm becb32061d STM32F4 USB: remove useless macro 2019-02-22 10:53:22 -06:00
Russ Butler 468df713fc Ignore disabled Kinetis USB endpoint interrupts
Ignore interrupts on disabled USB endpoints. This prevents handling
interrupts when in the wrong state.

Prior to this patch when running the serial test on a K64F the assert
on line 908 of USBDevice.cpp would sometimes be triggered. This
assert indicates that an endpoint 0 IN interrupt occurred before
the device was ready.

This occurs during the test_cdc_usb_reconnect test when the host sends
a "Set Control Line State" USB request and the device acknowledges it
just before USB is disconnected.
2019-02-22 10:53:20 -06:00
Russ Butler 130927068c Remove HAL_GetTick from ST USBPhy
Remove the function HAL_GetTick from the ST USBPhy driver. This is no
longer needed as that change has been made on master.
2019-02-22 10:53:20 -06:00
Filip Jagodzinski 5a312406c4 USB: EndpointResolver: Add a generic method to get a free endpoint 2019-02-22 10:53:19 -06:00
Russ Butler 6b0e9400b0 Fix ST test failures due to endpoint reconfiguration
Also always use the max endpoint size for SetTxFifo
since re-configuring fifos when endpoints are added or removed
causes tests to fail.
2019-02-22 10:53:18 -06:00
Russ Butler 5fde071509 Implement endpoint_abort for STM32
Make use of the added function HAL_PCD_EP_Abort to implement
endpoint_abort.
2019-02-22 10:53:18 -06:00
Russ Butler c4cf19ee3b Revert "Create HAL_PCD_EP_Abort"
Revert the patch "Create HAL_PCD_EP_Abort" in preparation for an
alternate fix.
2019-02-22 10:53:18 -06:00
Russ Butler 0f70912028 Reset data toggle on Kinetis when unstalling
Data toggle must be reset to DATA0 when an endpoint is unstalled.
This patch makes that change.
2019-02-22 10:53:18 -06:00
Russ Butler dbe41c3659 Abort the current USB transfer when stalling
It is undefined behavior if stalling and unstalling clears an ongoing
transfer. Abort any ongoing transfers explicitly when stalling and
unstalling so the behavior is consistent across devices.
2019-02-22 10:53:18 -06:00
Russ Butler c76d80e36e Alternate Kinetis USB stuck sending bug fix
If an IN endpoint is stalled during a transfer then the data being
sent will repeated and flood the USB bus. This patch prevents
endpoints from being stalled in the middle of a transfer by control
requests by keeping USB suspended until the setup phase of the
control request is done.
2019-02-22 10:53:18 -06:00
Russ Butler a75b40a778 Revert "Fix Kinetis bug causing USB to get stuck"
Revert the commit "Fix Kinetis bug causing USB to get stuck sending"
since this change causes stalls to be missed sometimes.
2019-02-22 10:53:18 -06:00
Russ Butler 3657dab5db Update USBMSD to be more consistent with others
Add second constructor and reorder constructor parameters to match
other USB classes. Also remove the ready() function since there
are no calls that can only mbe made from a ready state.
2019-02-22 10:53:18 -06:00
Russ Butler 799cde0fc3 Remove endpoint parameter from USB callbacks
Remove the endpoint parameter from endpoint callbacks. This
information is redundant because endpoints are known at
construction time because they must be in the configuration
descriptor.
2019-02-22 10:53:18 -06:00
Russ Butler 4284afd297 USBMSD fixes
Make the following fixes:
-deinit in destructor to prevent race conditions
-cancel the reset task before calling it since it may be in progress
-wait for tasks to complete without mutex held
-prevent double connect with _init flag
2019-02-22 10:53:17 -06:00
Russ Butler c08da25aa7 Update USBMSD
Update the USBMSD class for the new API. Add support for passing in
a BlockDevice directly without the need to extend USBMSD.
2019-02-22 10:53:17 -06:00
Russ Butler 33756e2316 Add the PolledQueue implementation of TaskQueue
Add the PolledQueue class which provides a TaskQueue which is run
by calling PolledQueue::process.
2019-02-22 10:53:17 -06:00
Russ Butler 29e59d6b83 Add the TaskQueue abstract interface and friends
Add the classes Task, TaskBase and TaskQueue. TaskQueue queue is an
interface class which can be implemented by anything which can run
code. Task and TaskBase are concrete classes which allow callbacks
to be posted to a TaskQueue to be run.
2019-02-22 10:53:17 -06:00
Russ Butler 322b4b72af Update USBDevice endpoint checks to fix asserts
Only assert if disabled endpoints are used when USBDevice is
configured. USBDevice can leave the configured state due to a
reset at any time, which disables all endpoints. Because this
can happen at any time, thread processing could be performing
any endpoint operation. The endpoint operation should return
failure and do nothing in this case, rather than asserting
as this is not an application error.

An assert should only be triggered when an invalid endpoint is
used after the use of USBDevice acknoledges the switch to
configured mode by complete_set_configuration.

In specific this PR fixes the assert caused with the following
sequence:

-ISR: OUT event sent
-ISR: USB reset event
-ISR: USB configure request start
-Thread: OUT event processed on thread and next read starts
        ***endpoint is used while disabled causing an invalid assert***
-Thread: reset event processed
-Thread: configure event processed

This patch fixes this problem by making the following changes:
1. Operations done on disabled endpoints only assert when in the configured state
2. Adding and removing endpoints is only allowed when
    the flag _endpoint_add_remove_allowed is set
3. The flag _endpoint_add_remove_allowed is set on the set
    configuration request and cleared if the request is aborted  or
    fails
2019-02-22 10:53:17 -06:00
Russ Butler d5fc72d5b4 Fix unbalanced USBDevice unlock
Remove calls to unlock which are not preceded by calls to lock.
Also move the location of the unlock underflow assert so unbalanced
unlocking during post processing is caught.
2019-02-22 10:53:17 -06:00
Russ Butler 793044eb26 Fix various USB warnings
Fix the following warnings:
-[Warning] USBTester.cpp@45,0:  #1299-D: members and base-classes will
    be initialized in declaration order, not in member initialisation
    list order
-[Warning] USBTester.h@41,0:  #1300-D: ~USBTester inherits implicit
    virtual
-[Warning] USBAudio.cpp@345,0:  #1035-D: single-precision operand
    implicitly converted to double-precision
-[Warning] USBHID.cpp@29,0:  #1300-D: ~AsyncSend inherits implicit
    virtual
-[Warning] USBHID.cpp@61,0:  #1300-D: ~AsyncRead inherits implicit
    virtual
-[Warning] USBHID.cpp@93,0:  #1300-D: ~AsyncWait inherits implicit
    virtual
-[Warning] EndpointResolver.cpp@125,26: '<<' in boolean context, did
    you mean '<' ? [-Wint-in-bool-context]
2019-02-22 10:53:17 -06:00
Russ Butler 6d88bd118f Update USBAudio
Update the USBAudio class to use the new USB API. This patch also adds
buffering and blocking functionality so it can be used in practice
from thread context.
2019-02-22 10:53:17 -06:00