Commit Graph

29 Commits

Author SHA1 Message Date
hathach 43b255f413 more typos 2022-12-04 19:44:01 +07:00
hathach 606f932d92 added dcd_sof_enable() stubs for all other ports 2022-03-07 23:05:05 +07:00
hathach d10326cb4e rename TUSB_OPT_DEVICE_ENABLED to CFG_TUD_ENABLED
TUSB_OPT_DEVICE_ENABLED still usable for backward compatible
2022-02-25 18:35:21 +07:00
Jerzy Kasenberg 7b078367e8 dcd_da1469x: Re-enable RX after resume
Going to suspend states disable reception on non-0 RX endpoints.

Now when USB resume condition is detected, all RX endpoints
with pending transfers are resumed.
2022-01-20 16:28:09 +01:00
Jerzy Kasenberg ae4d901d83 dcd_da1469x: Fix over-run/under-run mask
Bit mask enabling/disabling over-run/unde-run was shifted
by one nibble, so interrupt was never enabled.
It did not force any issue as this situation could only
happen on ISO endpoints without DMA.
2022-01-20 10:01:18 +01:00
hathach 109b7a6661 more wMaxPacketSize 2021-10-24 14:39:02 +07:00
hathach 5af989384b remove ep descriptor wMaxPacketSize bitfield due to endian issue 2021-10-24 13:11:21 +07:00
Ha Thach 311c05b401
Merge branch 'master' into fix-warnings 2021-10-23 21:23:56 +07:00
hathach 099d3b377f add volatile to EPx_REGS for -Wcast-qual
since gcc does difference between volatile struct and member when
casting pointer
2021-10-17 17:33:14 +07:00
Jerzy Kasenberg bf4b133084 dcd_da146xx: Drop unexpected data
USB3CV tool verifies MSC device by sending too short or
too long packets.
In case of too long packets (msc_device requested 31 bytes
but incoming data had 32 bytes) extra byte(s) were left in
FIFO resulting in some data mismatch later on.

Now if more data is received in packet that expected extra
bytes are just dropped.
2021-10-15 12:02:15 +02:00
Jerzy Kasenberg 49aa0b72a8 dcd_da146xx: Fix EPIN stall notification handling
Normal TX handler for IN non-0 endpoints is called during
outgoing transfer or just after it was finished.
It may need to fill TX fifo with same data if TX_DONE is present
but ACK_STAT is not.
It may need to fill more data when called during transfer.
But it may also be called when STALL was sent.
In this case TX_DONE is set ACK_STAT is not, just like for packets
that were sent but no ACK was received.
Code was trying to send something again. There was nothing to send
so empty ZLP was scheduled for stalled endpoint.
This ZLP was later send to host where valid response was required.

This change checks if notification was for STALL endpoint and
does not try to fill TX FIFO in that case.
2021-10-15 12:02:15 +02:00
Ha Thach 9da234cd7c
Merge pull request #1101 from kasjer/kasjer/da146xx-bus-reset-sleep
da146xx bus reset and sleep reworked
2021-10-13 16:33:54 +07:00
Ha Thach 1c17cb1c45
Merge pull request #1103 from kasjer/kasjer/da146xx-close-cleanup
dcd_da146xx: Remove registers pointer from xfer_ctl_t
2021-09-24 20:55:16 +07:00
Jerzy Kasenberg fbac58e3e4 dcd_da146xx: Implement dcd_edpt_close_all()
Unconditionally disables all endpoints except EP0.
2021-09-24 10:46:16 +02:00
Jerzy Kasenberg 1503955860 dcd_da146xx: Clear transfer data on dcd_edpt_close
Closing endpoint clears data in affected xfer_ctl_t
2021-09-24 09:28:51 +02:00
Jerzy Kasenberg f172c5ee13 dcd_da146xx: Remove registers pointer from xfer_ctl_t
Note: this commit does not change any logic.

xfer_ctl_t structure keeps all dynamic data connected with transfer.
It used to have pointer to register set that was constant and was there
for convenience only.
Removing register pointer from structure makes cleanup easier as whole
structure can be erased with memset like function.

In many cases functions were using local variable regs and xfer->regs which
were same, that could be confusing so this part is unified.

Few macros were added for easy conversion between epnum, xfer, and regs.
2021-09-24 09:28:51 +02:00
Jerzy Kasenberg 428eedcd04 dcd_da146xx: Update bus handling
So far bus reset was handled (with some holes in it).
Sleep and remote wakeup were not really tested and did not work.

With this change:
- bus reset is reworked
- remote wakeup works
- bus signal sleep is handled
2021-09-23 14:12:50 +02:00
Jerzy Kasenberg c427712449 dcd_da146xx: Handle only enabled interrupts
Not much of an improvement but handle only interrupts
that were enabled and are expected.
2021-09-23 14:12:50 +02:00
Jerzy Kasenberg 6d8677a78a dcd_da146xx: Add VBUS handling
DA146xx are Bluetooth devices that may be battery
powered and when not connected to USB host there
is no need for USB peripheral to be running.

This change allows to enable USB peripheral when
VBUS is present otherwise USB is down reducing
power consumption.

tud_vsub_changed() function must be called
whenever VBUS change was detected.
For bus-powered devices this function should be called
at startup since VBUS must be present while device
is working.
2021-09-17 12:10:17 +02:00
hathach 71e77e47fa
add dcd_edpt_close_all() for clear existing configured state
correctly responded to TD 9.13 Set Configuration Test
2021-08-26 17:07:03 +07:00
Jerzy Kasenberg cde607338d da1469x: Fix no VBUS startup
For self powered device if device started without VBUS present
it would not be correctly attached to USB bus even if tusb_vbus_changed()
was later called.

This modifies dcd_init() so it starts USB state machine without checking
if VBUS is present or not, like all others drivers do.
tusb_vbus_changed() function is also removed its content was moved to dcd_init.
2021-08-12 09:12:25 +02:00
Jerzy Kasenberg 2c7bb540b4 dcd_da1469x: Use mcu.h instead of MCU specific header
dcd_da1469x can work with broader range of MCUs that
share same USB core.
Specific header file that was used DA1469xAB.h now it is changed
to mcu/mcu.h which includes actual MCU specific register file.
2021-08-10 20:26:51 +02:00
hathach 6e6e6265e4 use dcd_event_bus_reset() with speed to replace bus_signal 2021-01-08 22:34:36 +07:00
Jerzy Kasenberg d36bfddc30 DA146xx: Allow transmitting of packets larger then 64 bytes
FIFO is limited to 64 bytes yet MCU is capable of transmitting
larger packets provided that FIFO will be filled on the fly
and USB_USB_TXCx_REG_USB_LAST_Msk bit is set after FIFO is
filled with all the data that should be transmitted.

This change allows to use FIFO level warning interrupt to fill
FIFO. When DMA is available it will be used instead of interrupts.
Some function names were changed to better reflect what each function
does.
2020-10-08 13:20:58 +02:00
Jerzy Kasenberg 33a5081bd1 DA146xx: Add support for ISO endpoints
Few changes were needed to have working ISO endpoints.
2020-10-08 13:20:58 +02:00
Jerzy Kasenberg 6615dd9062 DA146xx: Add dcd_edpt_close
Closing endpoints can be important when there are alternate
instances. This adds functionality of closing endpoints
similar to what exists in other drivers.
2020-10-08 13:20:58 +02:00
Jerzy Kasenberg 9edf4334c4 DA146xx: Allow receiving of packets larger then 64 bytes
Internal FIFO for each endpoint is limited to 64 bytes.
It is possible to have longer packets if respective FIFO
is read during actual packet transmission.
This change updates receive data path to allow packets (and
endpoint size) larger then 64 bytes.
If DMA is not used yet DMA is setup for reception of big packets.
If DMA is already assigned to some transfer, code enables FIFO level
warning interrupts and tries to read data before FIFO is filled up.
2020-10-08 13:20:58 +02:00
hathach acde49ccc9
enable pull-up in dcd_init() instead of usbd 2020-08-01 20:14:58 +07:00
Jerzy Kasenberg 0635bafe0a Add DCD for Dialog DA1469x MCU
Dialog Semiconductor's BLE MCU DA1469x comes with full speed USB.
It's base on National Semiconductor discrete USB controller USBN9603/4.

This adds support for:
- control/interrupt/bulk endpoints (up to 64 bytes)
- ISO endpoint were not tested and may not work correctly
- reset/sleep/wakeup are handled
- code for VBUS changes is provided
2020-06-09 15:55:46 +02:00