Commit Graph

353 Commits

Author SHA1 Message Date
hathach 3cc1979adb migrate dfu runtime device to new control xfer cb 2020-11-20 15:42:32 +07:00
hathach 7df979673d migrate usbtmc device to new control xfer cb 2020-11-20 15:38:56 +07:00
hathach 8813f9d3b8 clean up 2020-11-20 15:33:05 +07:00
hathach e2abb089f4 migrate midi device to new control xfer cb 2020-11-20 15:30:36 +07:00
hathach dc9a309839 migrate hid device to new control xfer cb 2020-11-19 22:00:49 +07:00
hathach dd07fecc5f migrate cdc_device to new control_xfer_cb 2020-11-19 21:26:06 +07:00
hathach 3c31d08051 merge class driver control_request & control_complete to control_xfer_cb()
migrated msc_device
2020-11-19 21:01:33 +07:00
Reinhard Panhuber 032e84c9be Revert dcd_alloc_mem_for_conf() but keep changes from @kasjer for ISO EP
Add tud_audio_set_itf_close_EP_cb()
2020-10-09 19:50:05 +02:00
hathach d41248900b Merge branch 'uac2' of https://github.com/PanRe/tinyusb into PanRe-uac2 2020-10-06 22:32:22 +07:00
Jerzy Kasenberg b2ce7a39b0 device: Make number of endpoints configurable
Currently number of endpoints was hard coded to 8.
NRF52 has 9 IN and 9 OUT endpoints.
ISO endpoints are 0x08 and 0x88 and without this change those
two ISO endpoint could not be used.
2020-10-01 09:22:49 +02:00
Reinhard Panhuber 142871654e Merge remote-tracking branch 'upstream/master' into uac2 2020-09-28 18:08:39 +02:00
hathach 9c0d15fc43 more const 2020-09-14 22:23:59 +07:00
hathach 23e6ee2ea2 cdc device: claim endpoint before checking fifo availability
- add pre-check to reduce mutex lock in usbd_edpt_claim
2020-09-14 22:14:31 +07:00
hathach ce4a9b9c3a clean up 2020-09-11 00:14:07 +07:00
hathach 33f0a18523 update cdc edpt read 2020-09-09 16:25:31 +07:00
hathach 8b9893cada introduce optional usbd_edpt_claim, usbd_edpt_release which can be used to gain exclusive access to usbd_edpt_xfer 2020-09-09 15:48:11 +07:00
Reinhard Panhuber 6309364722 Merge remote-tracking branch 'upstream/master' into uac2
Conflicts:
	src/device/usbd.c
	src/device/usbd.h
	src/portable/st/synopsys/dcd_synopsys.c
2020-08-16 14:08:24 +02:00
hathach 01b9b77d3b allow application driver to overwrite built-in one
- position application driver before built-in
- remove dcd.h from public include.
2020-08-07 14:47:32 +07:00
hathach 9df8057702 Merge branch 'master' into add-app-driver 2020-08-07 12:13:13 +07:00
hathach acde49ccc9
enable pull-up in dcd_init() instead of usbd 2020-08-01 20:14:58 +07:00
Reinhard Panhuber 01903a4a6d Implement dynamic reallocation of RX and TX fifos for EP0.
Tested with EP0 size 8/16/32/64.
2020-07-27 21:03:20 +02:00
Reinhard Panhuber e047fbe8fb Merge remote-tracking branch 'upstream/master' into uac2 2020-07-25 14:26:24 +02:00
Ha Thach be744e1e01
Merge pull request #466 from chang196700/feature/string_desc_msos
Remove 0xEE index string if statement & change TU_ASSERT to TU_VERIFY
2020-07-21 20:25:08 +07:00
Chang Feng 5cd654838b
Remove 0xEE index string if statement & change TU_ASSERT to TU_VERIFY
Signed-off-by: Chang Feng <chang_196700@hotmail.com>
2020-07-19 19:13:17 +08:00
hathach 706413f751 add tud_speed_get()
- define both fs and hs configuration descriptor
- rename CFG_TUD_CDC_EPSIZE to CFG_TUD_CDC_EP_BUFSIZE with default size of 64 for FS, and 512 for HS
2020-07-16 00:44:09 +07:00
hathach ab75998316 Merge branch 'master' into add-stm-hs 2020-06-30 01:55:57 +07:00
Reinhard Panhuber 28505cf03e Merge branch 'master' into uac2
Conflicts:
	src/device/usbd.c
2020-06-20 11:10:35 +02:00
Reinhard Panhuber ada82b840f Get update from tinyusb. 2020-06-20 10:51:21 +02:00
Mengsk 57b553e023 Fix IAR warnings.
Pa039 : use of address of unaligned structure member.
Pe188: enumerated type mixed with another type.
2020-06-17 10:08:33 +02:00
Reinhard Panhuber bc7e24b659 Fix wrong comment for IAD checks. 2020-06-14 14:22:10 +02:00
hathach 95966c2201 improve usbd log for control transfer 2020-06-14 18:29:02 +07:00
Reinhard Panhuber b25bbf4776 Fix alignment. 2020-06-14 12:58:16 +02:00
Reinhard Panhuber 3012175351 Fix alignment. 2020-06-14 12:57:00 +02:00
Reinhard Panhuber 862d1667f0 Fix alignment. 2020-06-14 12:55:52 +02:00
Reinhard Panhuber 930817221d Merge branch 'fix-too-strict-iad-checks' into uac2
Conflicts:
	src/device/usbd.c
2020-06-14 12:36:59 +02:00
Reinhard Panhuber 48b2e6cf78 Fix too strict checks on subclass and interface of iad descriptor. 2020-06-13 13:51:50 +02:00
Reinhard Panhuber 4362665fb3 Fix mic audio descriptor, fix too strict check on IAD desc. in usbd.c 2020-06-13 12:36:05 +02:00
Reinhard Panhuber d2f1bb58b3 Merge branch 'master' into uac2 2020-06-11 14:35:44 +02:00
hathach e92118635c adding speed detect on bus reset 2020-06-01 13:40:18 +07:00
hathach f771afe6af fixed EP0 size to 64 since LS is not supported in device mode
- set turn-around and report actual speed in Enum Done
- add dcd_event_bus_reset() helper to report speed
2020-05-31 23:43:29 +07:00
Ha Thach 5efeaf2ac1
Merge pull request #413 from kasjer/kasjer/ble-over-usb
Bluetooth HCI transport over USB
2020-05-31 15:07:56 +07:00
hathach d6d29897f3 add get device qualifier descriptor 2020-05-28 23:16:16 +07:00
Jerzy Kasenberg 56d46483e4 Add bt hci device class
Code implements USB transport for bluetooth HCI.
2020-05-28 10:58:49 +02:00
Jerzy Kasenberg 077437b3dc Add non standard request handling in class
For some reason bluetooth stack implementations send class requests
to device instead of interface.
To implement HCI interface over USB non device addressed requests
for class need to be handled.
2020-05-28 10:11:37 +02:00
hathach e340404968
changing usbd driver open() return type, add max_len
only done with cdc and msc, push this interim for feedback first
2020-05-27 19:01:59 +07:00
hathach d4bf777c94 try to get synopsys work with OTG HS + external PHY 2020-05-27 11:01:33 +07:00
Reinhard Panhuber 9be2f1bf3d Add basic UAC2 structure - untested 2020-05-22 12:09:34 +02:00
hathach 88a455a9b9 added tud_task_event_ready()
to check if there is pending events in the tud task without executing
it. Useful to check before entering low power mode with WFI/WFE
2020-05-20 14:31:45 +07:00
hathach 6f4b6a1d03 remove the use of TU_VERIFY_HDLR 2020-04-29 11:31:27 +07:00
hathach c14c0cfc9f support class drivers implemented by application 2020-04-29 10:49:58 +07:00
Ha Thach d4511186a2
Merge pull request #383 from kasjer/kasjer/fox-busy-flag-race-condition
Fix endpoint busy flag race condition
2020-04-29 10:12:31 +07:00
Jerzy Kasenberg 63cefb7615 Fix endpoint busy flag race condition
Busy flag was set to true after call to dcd_edpt_xfer().
In some cased it was possible that transfer finished before function
ended.
In this case busy flag could be set to false before it was set to
true.
Then setting it to true after dcd_edpt_xfer() made edpoint busy forever.

This change marks endpoint as busy before transfer is started to
avoid race condition.
2020-04-27 16:42:35 +02:00
hathach a1c599f4b6 clean up log message 2020-04-26 22:02:49 +07:00
hathach 017c95037f add usbd edpt open
- RTT mode is blocking to prevent log lost
- Improve logging message
2020-04-26 14:51:44 +07:00
Nathan Conrad 0ec69de77c sof is optional, revert other changes but remove unneeded check. 2020-04-21 10:06:17 -04:00
Nathan Conrad d1656c0b8d tu_verify for getting descriptors 2020-04-20 16:09:15 -04:00
hathach 05476d9ad7 Merge branch 'master' into remove-dcd-set-config 2020-04-17 13:38:22 +07:00
Ha Thach 33610751d7
Merge pull request #336 from pigrew/edpt_close
> If you notice my chain of events above, the bulk transfer was started BEFORE the SET_INTERFACE call. The USB device hardware swaps the order of them being delivered. On STM32, it gives priority to the lower-numbered EP index.

It shouldn't be a matter, control is 2+ stage, before sending the setup. Host should stop all communication to the endpoint that It wants to close.
2020-04-16 23:10:36 +07:00
Nathan Conrad 2994d100cd Remove transfer queue filtering. May need to be revisited later. 2020-04-16 09:59:40 -04:00
hathach 2eed58d096
per review 2020-04-16 11:13:54 +07:00
hathach 0ddbda08cb
always response if GET_INTERFACE even if class driver does not support alt interface 2020-04-15 23:08:49 +07:00
hathach caa1dceed9
implement alternate setInterface() request
mostly forward these request (recipient = interface) to class driver.
2020-04-15 17:51:02 +07:00
hathach d315393fbb
use IAD to assign itf2drv mapping correctly
merge net_data back into net driver
2020-04-15 16:18:24 +07:00
hathach 93ffe317b2
clean up 2020-04-15 13:53:50 +07:00
hathach 3bfb402d8c
clean up 2020-04-15 11:44:12 +07:00
hathach 1faa3b2768
tested usbnet, completely remove class code 2020-04-15 11:41:26 +07:00
hathach c74f7e708e
remove class_code/subclass/protocol from driver structure, add name for logging 2020-04-15 11:06:35 +07:00
hathach f1a6f92fab
Merge branch 'master' into class-driver-id 2020-04-15 10:47:49 +07:00
Peter Lawrence 7fa8d87291 usbnet: remove CDC-EEM 2020-04-14 21:10:43 -05:00
hathach 3ef6e33533
use class driver open() for interface support detection
tested with dfu_runtime
2020-04-15 01:00:37 +07:00
hathach ae60146274 use explicit all_subclass and all_protocol since 0xFF is stil valid 2020-04-14 22:35:34 +07:00
Nathan Conrad 16f65890eb Merge branch 'master' into edpt_close 2020-04-14 10:22:03 -04:00
hathach b90b00d43b
complete adding subclass and protocol to driver id 2020-04-14 18:35:50 +07:00
hathach 593fe154ec
adding subclass & protocol to class driver structure 2020-04-14 18:00:59 +07:00
Nathan Conrad de208b31cf edpt_close: Remove item from queue instead of modifying it. 2020-04-13 11:05:34 -04:00
Nathan Conrad f8e7487355 edpt_close: Updated based on feedback. 2020-04-13 09:51:46 -04:00
hathach f4df829399 lpc17xx move set configdevice into set address
for removing dcd_set_config()
2020-04-13 17:04:18 +07:00
Nathan Conrad 0eeaccaf46 Skeleton, and initial stm32fsdev implementation (that leaks memory) 2020-04-12 21:27:27 -04:00
Peter Lawrence bb3bbcc00b usbnet: OS-agnostic (Windows/Linux/macOS) network driver 2020-04-12 15:41:18 -05:00
Ha Thach 07809d03a7
Merge pull request #332 from pigrew/stm32fsdev-dcdconnect
stm32fsdev: Implement dcd_connect.
2020-04-11 13:20:31 +07:00
hathach 1b3d1b52c9 fix uint32_t format with log 2020-04-10 13:54:50 +07:00
Nathan Conrad 715c4dbbf8 stm32fsdev: Implement dcd_connect. 2020-04-09 17:03:12 -04:00
hathach c026236824 house keeping 2020-04-06 16:33:04 +07:00
hathach 4f871063fd Merge branch 'master' into cr1901-msp430f5529 2020-03-22 17:19:57 +07:00
hathach 7aa5a53652 fix log printf 2020-03-08 13:26:36 +07:00
Peter Lawrence fee79d7466 add CDC-ECM/RNDIS/CDC-EEM network device class with example 2020-03-02 21:15:01 -06:00
Chang Feng b8ea0f0a6b
Add langid support to descriptor string callback.
Signed-off-by: Chang Feng <chang_196700@hotmail.com>
2020-02-26 13:07:15 +08:00
Nathan Conrad 25c1bea782 Normalize line endings 2020-01-15 14:47:43 -05:00
Ha Thach d6a8d42bd6
Merge pull request #254 from majbthrd/multi-setconfig
gracefully handle multiple SET_CONFIGURATION requests
2020-01-05 17:48:55 +07:00
Jeremy Herbert db24b2f372 Let device respond to endpoint requests on EP0 (#251)
Since endpoint 0 is used for control requests, it doesn't have a class driver attached to it. As such, the corresponding `_usbd_dev.ep2drv` entry points to driver `0xFF`, which is invalid and this makes the `TU_ASSERT(drvid < USBD_CLASS_DRIVER_COUNT);` line fail, and eventually causes an endpoint stall. So as-is the stack cannot respond to any endpoint requests on endpoint 0.

However, standard requests on endpoint 0 do not need a class driver to produce a valid response. This commit changes the order of execution so that the assert is only checked if the endpoint is not 0.
2019-12-30 10:58:06 +07:00
Peter Lawrence e7bf66b29e gracefully handle multiple SET_CONFIGURATION requests 2019-12-28 16:49:52 -06:00
hathach bbada1d3e6 adding lookup table for debugging
add msc scsi command list
2019-12-23 18:54:06 +07:00
hathach 050fa2fd39
able to response to scsi inquiry, but failed to response to test unit ready 2019-12-21 19:33:41 +07:00
hathach d7558e8a0f use dcd_edpt0_status_complete() to set address without blocking for samd21/samd51/stm32_fsdev 2019-11-28 13:39:29 +07:00
hathach 5dc04887e2 get passed set address 2019-11-28 11:48:08 +07:00
hathach 40b454cf28 get passed first get device descriptor 2019-11-27 23:20:48 +07:00
hathach 8a1b6327ba extract code to invoke_class_control()
- also rename usbd_class_drivers to _usbd_driver
2019-11-27 12:12:52 +07:00
hathach 1ab3a1035c Merge branch 'master' into cr1901-msp430f5529 2019-11-05 10:17:36 +07:00
hathach 3c49ff153e
Merge pull request #149 from pigrew/ZLP_Request2
Zlp request2
2019-11-05 00:05:21 +07:00
Nathan Conrad 8d0fa158d7 Change one more TU_ASSERT to TU_VERIFY in usbd. 2019-11-04 11:33:14 -05:00
hathach 2727983a2d fix #211 2019-11-04 22:52:29 +07:00
Nathan Conrad a94fe05ecb usbd: Change TU_ASSERT to TU_VERIFY as the assertion can be hit when bad data is sent from host. 2019-11-04 08:59:29 -05:00
hathach 62f8c14fae add a bit of log1 for debugging 2019-11-03 14:08:38 +07:00
hathach 1b51b78eaf hack the request length for the first get device descriptor if EP0 size =8 or 16
to prevent usbd control send out ZLP
2019-11-03 00:17:17 +07:00
hathach a0cffdc843 Merge branch 'pigrew-ZLP_Request2' into cr1901-msp430f5529 2019-11-02 23:29:35 +07:00
hathach cacbb80a90
zlp should work with control in, tested with Unity framework 2019-10-31 21:14:06 +07:00
hathach 6de9eb4b1a
add more tests, fix an issue with tud_descriptor_configuration_cb() return NULL 2019-10-31 13:06:57 +07:00
hathach 4d329d46cc
Merge pull request #206 from hathach/develop
Added a couple of unit testing with Ceedling/Cmock/Unity
2019-10-31 08:29:11 +07:00
hathach a0002cc709
rename usbd_init() to tud_init() 2019-10-30 23:26:34 +07:00
hathach 880ac1e398 move dcd event helper to be dcd.h as inline function 2019-10-30 11:35:25 +07:00
hathach f6a65720e5 should fix #184
only response up to EP0 size with get device descriptor if not
addressed.
2019-10-29 16:25:32 +07:00
hathach 78523301bb
Merge pull request #202 from smunaut/dfu-rt
Add support for DFU Runtime class for devices
2019-10-28 22:56:14 +07:00
Sylvain Munaut ec4ecfa817 Add support for DFU Runtime class for devices
This is really just a few descriptors and then answering to the
request from the host to reboot into DFU mode.

That latter part is delegated to the app since this is platform
specific.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2019-10-28 16:11:08 +01:00
hathach 6ab0663c1a adding more log 2019-10-24 12:00:06 +07:00
hathach 661515a807 adding debug log function 2019-10-23 21:18:46 +07:00
hathach 204791b3e7 2nd attempt to fix #161 2019-10-01 22:19:04 +07:00
hathach 12609f818b fix #161 added volatile for ep_busy_map/ep_stall_map 2019-10-01 14:43:34 +07:00
Nathan Conrad 2aa10daf26 Merge branch 'clear_feature_ordering' into usbtmc 2019-09-21 21:39:25 -04:00
Nathan Conrad 9498adef71 Changing the bitwise to a logical OR created a huge hard to find bug. It shortcutted the call to the class function,
so, lets use shortcutting anyway?
2019-09-21 19:29:57 -04:00
Nathan Conrad fbb8520acd logical or. 2019-09-21 14:34:29 -04:00
Nathan Conrad 37b52e354f Correct wording of comment on handling EP requests. 2019-09-21 12:17:17 -04:00
Nathan Conrad a187f0268c When unstalling, EP must be marked as not busy. Also, mark EP as busy when stalling as xfer requests should fail. 2019-09-21 12:05:57 -04:00
Nathan Conrad be28a05409 Make type casting explicit 2019-09-21 12:05:46 -04:00
Nathan Conrad 55abb3d717 Calling EP open with bad parameters should be considered a bug. 2019-09-21 12:02:52 -04:00
Nathan Conrad aebecf169a Reorder handling of EP control requests, 2019-09-21 12:02:06 -04:00
Nathan Conrad 2a7ca15e2c Rename functions to include tud_ and _cb 2019-09-19 20:43:49 -04:00
Nathan Conrad 7e0490bbf3 Move descriptors to usbd.h 2019-09-19 19:51:37 -04:00
Nathan Conrad ac2c9ff02f Merge branch 'master' into usbtmc 2019-09-17 13:31:53 -04:00
hathach 9c5ae0369b follow up to suggestion to pr 155 2019-09-16 11:13:17 +07:00
Nathan Conrad 1cae96951f Add usbtmc class driver. 2019-09-14 13:35:08 -04:00
hathach ac8c343fef fix #154 forward all endpoint recipeint request to class driver
fix typo
remove magic number 0xff of driver id
2019-09-13 22:16:24 +07:00
hathach 064adebbd0 fix #152, potential memory issue 2019-09-13 14:03:59 +07:00
hathach c3598f0301 fix #139, correct usbd request intepreting, Non-STD request to Interface must be forward to class driver 2019-09-13 13:03:11 +07:00
hathach cdaf455461 fix stall response with SET_INTERFACE/GET_INTERFACE
webusb work with linux & macos
2019-07-26 20:14:56 +07:00
hathach d2b60b6755 webusb work great with linux 2019-07-26 11:36:30 +07:00
hathach 2a543c0e79 update vendor device similar to cdc read/write
maybe refactor later
2019-07-24 23:07:30 +07:00
hathach c63f2b30cb rename tud_control_vendor_request_cb/complete_cb to tud_vendor_control_request_cb/complete_cb 2019-07-24 09:45:32 +07:00
hathach 33de35504a more house keeping 2019-07-19 20:20:13 +07:00
hathach ae5dc435cb house keeping 2019-07-19 16:49:04 +07:00
hathach b0678e1050 rename CFG_TUD_CUSTOM_CLASS to CFG_TUD_VENDOR 2019-07-19 16:23:56 +07:00
hathach 036e858543 add tud_control_vendor_request_cb()/tud_control_vendor_complete_cb(), expose usbd control transfer
rename usbd_control_transfer/status to tud_control_transfer/status
2019-07-16 18:14:47 +07:00
hathach cb4e6837e9 clean up, rename internal driver control_request_complete to simply control_complete 2019-07-12 22:03:40 +07:00
hathach 164b26ee6b change TUD_HID_INOUT_DESCRIPTOR epout & epin order
clean up, adding template for BOS & BOS platform descriptor
2019-07-12 14:53:11 +07:00
hathach e74aa41552 added tud_descriptor_bos_cb(), add support for BOS get descriptor 2019-07-12 00:12:14 +07:00
hathach 7156bfb54d
fix build error with midi, use usbd_edpt_xfer/busy for midi to replace dcd_* 2019-06-10 18:46:00 +07:00
hathach 13e01c7dca
add TU_ prefix to compiler ATTR to prevent name conflict with application 2019-06-06 10:39:37 +07:00
hathach a0307bafda added usbd_edpt_xfer/usbd_edpt_busy to replace dcd_edpt_transfer/dcd_edpt_busy()
- improve fifo write/read_n with only one lock
- use usbd_edpt_xfer/usbd_edpt_busy for hid/cdc/msc class driver
- replace cdc read's pending_read_from_host by usbd_edpt_busy()
2019-05-29 16:55:15 +07:00
hathach 8ccecde18e
lpc1769 work with makefile 2019-05-15 12:57:31 +07:00
hathach 3e6d911ce9
more clean up use inline bit funciton instead of macros 2019-05-14 12:54:29 +07:00
hathach 61ec407752
update license year to 2019 2019-05-14 11:48:05 +07:00