ISO endpoints were not covered so far by the driver code.
This adds support for ISO IN and OUT endpoint handling.
Registers for ISO IN(OUT) endpoints are placed just after normal IN(OUT)
so in some cases common code could be used for handling all type of
transfers.
Generally code synchronizes ISO endpoint handling to SOF interrupt.
This code does not change the way of how non-ISO endpoints are treated.
Code uses strategy outlined in nRF52840 Produce Specification v1.0
sections 6.35.11.1 and 6.35.11.2.
Closing endpoints can be important when there are alternate
instances. This adds functionality of closing endpoints
similar to what exists in other drivers.
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.
Current implementation always sets odd/even bit for ISO transactions.
This is a good strategy only if interval is 1.
For ISO endpoint interval in (micro)frames is computed as
2^(interval-1), which means that odd/frame number should stay
same for interval values > 1.
With this change only when interval is 1 odd/even bit is modified.
dcd_edpt_close() no longer modifies FIFO distribution.
Code that that was commented out is removed along with
variables that are no longer used.
FIFO distribution among endpoints is handled upfront
and does not need to be modified in open and close endpoint
functions.
This allow to build with single FIFO for devices with multiple channels.
Having just one FIFO greatly reduces time needed to feed endpoint.
This change also allows to have one FIFO with 24 bit samples that
is not rounded up to 32 bit elements.
CFG_TUD_AUDIO_RX_ITEMSIZE and CFG_TUD_AUDIO_TX_ITEMSIZE can be manually
defined. This allows to use FIFO more efficiently when 24 bits samples
are already using 3 bytes, in this case there is no need to put them
into FIFO one by one.
For 8, 16, 32 bits samples size efficient FIFO access is always used
when single FIFO is selected.
This also changes FIFO element size to 1, FIFO usage was confusing
in some place it treated content as byte base in other it looked like
ITEM size is to be used. Also bufsize that in most (maybe all) cases
was really meaning item count.
bufsize now mean buffer size in bytes so there is no confusion.
Some API uses interface number as argument, some wants to have
rhport.
To accommodate need of rhport for functions that don't have it
rhport can be extracted from interface data.
Having just inline keyword for function specified in header
may not be enough to generate code for function.
Adding static solves this problem.
static inline is used in all other inline functions in TinyUSB.
Recommended FIFO allocation schema includes 2 maximum endpoint sizes.
Comment suggested that this is the case while it would work according
to this description only in checked endpoints were ascending sizes.
Also two same size endpoints would be counted as one.
That is fixed by way sz is filled.
Calculation used too much modulo operation while single division was enough
to account for odd FIFO sizes.
Extra space that is evenly distributed between Bulk and control endpoints
was incorrectly calculated it could prevent allocation of ISO endpoint FIFO
when bulk endpoints existed with smaller endpoint numbers.
Minimum endpoint FIFO size is 16 32bit words, FIFO space requirement is
now observed.
Operator < used in while condition was obviously incorrect.
Loop starts with checking if unsigned variable is less then 0.
This condition is always false.
This reverses condition to follow intention of of the code.
Fix a bug in writing SysEx messages.
At the start of a new USB packet (4 bytes), while in the middle of a SysEx, the code mistakenly
set the buffer length to 4, not the target length. As a consequence, the 3rd and 4th bytes from
the last packet were included, after every byte of the SysEx after the first packet of three.
The fix is simple, as it was just a typo, as can bee seen from the other branches in the same
section of if/else statements: At the start of a new packet, the code should set up the target
length... the buffer length should be left at 2 (as set on line 180).