|
Structure describing a user defined isochronous transfer. More...
#include <lusbk_shared.h>
Data Fields | |
KISO_FLAG | Flags |
Additional ISO transfer flags. See KISO_FLAG. | |
UINT | StartFrame |
Specifies the frame number that the transfer should begin on (0 for ASAP). More... | |
SHORT | ErrorCount |
Contains the number of packets that completed with an error condition on return from the host controller driver. More... | |
SHORT | NumberOfPackets |
Specifies the number of packets that are described by the variable-length array member IsoPacket . | |
UINT | UrbHdrStatus |
Contains the URB Hdr.Status value on return from the host controller driver. More... | |
KISO_PACKET | IsoPackets [0] |
Contains a variable-length array of KISO_PACKET structures that describe the isochronous transfer packets to be transferred on the USB bus. | |
Structure describing a user defined isochronous transfer.
[Fixed structure size of 16 bytes]
The KISO_CONTEXT::StartFrame member of the KISO_CONTEXT specifies the starting USB frame number for the transaction. The driver can use UsbK_GetCurrentFrameNumber to request the current frame number.
In full-speed transmissions, the frame number for any particular packet will be the sum of the start frame number and the packet index. For instance, the fourth packet in the KISO_CONTEXT has an index of 3, so its frame number will be StartFrame + 3. In a write transfer, the port driver loads this frame with the buffer data at the data buffer offset specified by IsoPacket[3].Offset.
When the driver processes the KISO_CONTEXT, it discards all packets in the KISO_CONTEXT whose frame numbers are lower than the current frame number. The port driver sets the Status member of the packet descriptor for each discarded packet to USBD_STATUS_ISO_NA_LATE_USBPORT, USBD_STATUS_ISO_NOT_ACCESSED_BY_HW or USBD_STATUS_ISO_NOT_ACCESSED_LATE. Even if it discards some packets, the port driver attempts to transmit those packets in the KISO_CONTEXT whose frame numbers are higher than the current frame number.
The check for a valid StartFrame member is slightly more complicated in high-speed transmissions because the port driver loads each packet into a high-speed microframe; however, the value in StartFrame refers to the 1 millisecond (full-speed) frame number, not the microframe. For example, if the StartFrame value recorded in the KISO_CONTEXT is one less than the current frame, the port driver will discard as many as eight packets. The exact number of packets that the port driver discards depends on the period associated with the isochronous pipe.
High-speed isochronous pipes can have periods of 1, 2, 4, or 8. The period number specifies the frequency with which the port driver inserts packets into the data stream. If the period is 2, for example, the port driver will insert a packet into the data stream every two microframes. This means that it will only use four of the eight microframes available within each 1-millisecond frame for isochronous data transmission.
In general, the higher the period, the fewer packets the port driver will discard when a KISO_CONTEXT arrives late. Assume the period on an isochronous pipe is 2. With a period of 2, each 1-millisecond speed frame will carry four packets of isochronous data for that pipe. So, for example, if CurrentFrame - StartFrame = 3, the port driver will discard 3 * 4 = 12 packets. On the other hand, if the period is 4, each 1-millisecond frame carries only two packets of isochronous data for the pipe. Therefore, if the KISO_CONTEXT arrives three 1-millisecond frames late, as in the previous example, the port driver will discard 3 * 2 = 6 packets, instead of 12 packets.
For all types of isochronous pipe, the distance between the current frame and the StartFrame value specified in the KISO_CONTEXT must be less than USBD_ISO_START_FRAME_RANGE. If StartFrame is not within the proper range, the driver sets the Status member of the KISO_PACKET USBD_STATUS_BAD_START_FRAME
and discards the entire KISO_CONTEXT. The following code example shows the precise check that the port driver does on the KISO_CONTEXT start frame:
UINT StartFrame |
Specifies the frame number that the transfer should begin on (0 for ASAP).
This variable must be within a system-defined range of the current frame. The range is specified by the constant USBD_ISO_START_FRAME_RANGE.
If /ref KISO_FLAG_SET_START_FRAME was specified, this member contains the frame number that the transfer should begin on. When the request is returned by the host controller driver, this member is updated to reflect the frame number this transfer did begin on.
SHORT ErrorCount |
Contains the number of packets that completed with an error condition on return from the host controller driver.
UINT UrbHdrStatus |
Contains the URB Hdr.Status value on return from the host controller driver.
The USB bus driver always returns a value of USBD_STATUS_SUCCESS in Hdr.Status, unless every packet in the transfer generated an error or the request was not well-formed and could not be executed at all. The following table includes possible error codes returned in Hdr.Status: