📄 usbd.h
字号:
//------------------------------------------------------------------------------
//
// Copyright (C) 2005-2006, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
//
// File: usbd.h
//
// The header file for USB function driver.
//
//-----------------------------------------------------------------------------
#ifndef USBD_H
#define USBD_H
#define USBD_EP_COUNT 16
#define USBD_PORT_NUM 0
typedef struct _USBD_dTD
{
unsigned int T:1; // Terminate (T).
// 1=pointer is invalid. 0=Pointer is valid (points to a valid Transfer Element Descriptor). This bit indicates to the Device Controller that there are no more valid entries in the queue.
unsigned int r4:4; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int next_dtd:27;// Next Transfer Element Pointer.
// This field contains the physical memory address of the next dTD to be processed. The field corresponds to memory address signals [31:5], respectively.
unsigned int status:8; // This field is used by the Device Controller to communicate individual command execution states back to the Device Controller software. This field
// contains the status of the last transaction performed on this qTD. The bit encodings are:
// 7 Active.
// 6 Halted.
// 5 Data Buffer Error.
// 3 Transaction Error.
// 4,2,0Reserved.
unsigned int r5:2; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int MultO:2; // Multiplier Override (MultO). This field can be used for transmit ISO's (ie.ISO-IN) to override the multiplier in the QH. This field must be zero for all packet types that are not transmit-ISO.
// Example:
// if QH.multiplier = 3; Maximum packet size = 8; Total Bytes = 15; MultiO = 0
// [default]
// Three packets are sent: {Data2(8); Data1(7); Data0(0)}
// if QH.multiplier = 3; Maximum packet size = 8; Total Bytes = 15; MultiO = 2
// Two packets are sent: {Data1(8); Data0(7)}
// For maximal efficiency, software should compute MultO = greatest integer of
// (Total Bytes / Max. Packet Size) except for the case when Total Bytes = 0; then
// MultO should be 1.
// Note: Non-ISO and Non-TX endpoints must set MultO=”00”.
unsigned int r6:3; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int ioc:1; // Interrupt On Complete (IOC). This bit is used to indicate if USBINT is to be set in response to device controller being finished with this dTD.
unsigned int tb:15; // Total Bytes.
// This field specifies the total number of bytes to be moved with this transfer descriptor. This field is decremented by the number of bytes actually
// moved during the transaction and only on the successful completion of the transaction.
// The maximum value software may store in the field is 5*4K(5000H). This is the maximum number of bytes 5 page pointers can access. Although it is possible to
// create a transfer up to 20K this assumes the 1st offset into the first page is 0. When the offset cannot be predetermined, crossing past the 5th page can be
// guaranteed by limiting the total bytes to 16K**. Therefore, the maximum recommended transfer is 16K(4000H).
// If the value of the field is zero when the host controller fetches this transfer descriptor (and the active bit is set), the device controller executes a zero-length
// transaction and retires the transfer descriptor.
// It is not a requirement for IN transfers that Total Bytes To Transfer be an even multiple of Maximum Packet Length. If software builds such a transfer descriptor
// for an IN transfer, the last transaction will always be less that Maximum Packet Length.
unsigned int r7:1; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int curr_off:12;// Current Offset. Offset into the 4kb buffer where the packet is to begin.
unsigned int bp0:20; // Buffer Pointer.
// Selects the page offset in memory for the packet buffer. Non virtual memory systems will typically set the buffer pointers to a series of incrementing integers.
unsigned int fn:11; // Frame Number.
// Written by the device controller to indicate the frame number in which a packet finishes. This is typically be used to correlate relative completion times of packets on an ISO endpoint.
unsigned int r8:1; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int bp1:20;
unsigned int r9:12; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int bp2:20;
unsigned int r10:12; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int bp3:20;
unsigned int r11:12; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int bp4:20;
} USBD_dTD_T, *PUSBD_dTD_T;
typedef struct _USBD_dTD_R
{
unsigned int T:1; // Terminate (T).
// 1=pointer is invalid. 0=Pointer is valid (points to a valid Transfer Element Descriptor). This bit indicates to the Device Controller that there are no more valid entries in the queue.
unsigned int r4:4; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int next_dtd:27;// Next Transfer Element Pointer.
// This field contains the physical memory address of the next dTD to be processed. The field corresponds to memory address signals [31:5], respectively.
unsigned int status:8; // This field is used by the Device Controller to communicate individual command execution states back to the Device Controller software. This field
// contains the status of the last transaction performed on this qTD. The bit encodings are:
// 7 Active.
// 6 Halted.
// 5 Data Buffer Error.
// 3 Transaction Error.
// 4,2,0Reserved.
unsigned int r5:2; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int MultO:2; // Multiplier Override (MultO). This field can be used for transmit ISO's (ie.ISO-IN) to override the multiplier in the QH. This field must be zero for all packet types that are not transmit-ISO.
// Example:
// if QH.multiplier = 3; Maximum packet size = 8; Total Bytes = 15; MultiO = 0
// [default]
// Three packets are sent: {Data2(8); Data1(7); Data0(0)}
// if QH.multiplier = 3; Maximum packet size = 8; Total Bytes = 15; MultiO = 2
// Two packets are sent: {Data1(8); Data0(7)}
// For maximal efficiency, software should compute MultO = greatest integer of
// (Total Bytes / Max. Packet Size) except for the case when Total Bytes = 0; then
// MultO should be 1.
// Note: Non-ISO and Non-TX endpoints must set MultO=”00”.
unsigned int r6:3; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int ioc:1; // Interrupt On Complete (IOC). This bit is used to indicate if USBINT is to be set in response to device controller being finished with this dTD.
unsigned int tb:15; // Total Bytes.
// This field specifies the total number of bytes to be moved with this transfer descriptor. This field is decremented by the number of bytes actually
// moved during the transaction and only on the successful completion of the transaction.
// The maximum value software may store in the field is 5*4K(5000H). This is the maximum number of bytes 5 page pointers can access. Although it is possible to
// create a transfer up to 20K this assumes the 1st offset into the first page is 0. When the offset cannot be predetermined, crossing past the 5th page can be
// guaranteed by limiting the total bytes to 16K**. Therefore, the maximum recommended transfer is 16K(4000H).
// If the value of the field is zero when the host controller fetches this transfer descriptor (and the active bit is set), the device controller executes a zero-length
// transaction and retires the transfer descriptor.
// It is not a requirement for IN transfers that Total Bytes To Transfer be an even multiple of Maximum Packet Length. If software builds such a transfer descriptor
// for an IN transfer, the last transaction will always be less that Maximum Packet Length.
unsigned int r7:1; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int curr_off:12;// Current Offset. Offset into the 4kb buffer where the packet is to begin.
unsigned int bp0:20; // Buffer Pointer.
// Selects the page offset in memory for the packet buffer. Non virtual memory systems will typically set the buffer pointers to a series of incrementing integers.
unsigned int fn:11; // Frame Number.
// Written by the device controller to indicate the frame number in which a packet finishes. This is typically be used to correlate relative completion times of packets on an ISO endpoint.
unsigned int r8:1; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int bp1:20;
unsigned int r9:12; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int bp2:20;
unsigned int r10:12; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int bp3:20;
unsigned int r11:12; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int bp4:20;
unsigned int r12[9]; // Reserved. Bits reserved for future use and should be set to zero.
} USBD_dTD_R_T, *PUSBD_dTD_R_T;
typedef struct _USBD_dQH
{
unsigned int r1:15; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int ios:1; // Interrupt On Setup (IOS). This bit is used on control type endpoints to indicate if USBINT is set in response to a setup being received.
unsigned int mpl:11; // Maximum Packet Length.
// This directly corresponds to the maximum packet size of the associated endpoint (wMaxPacketSize). The maximum value this field may contain is 0x400 (1024).
unsigned int r2:2; // Reserved. Bits reserved for future use and should be set to zero.
unsigned int zlt:1; // Zero Length Termination Select.
// This bit is used to indicate when a zero length packet is used to terminate transfers where to total transfer length is a multiple .
// This bit is not relevant for Isochronous
// 0 – Enable zero length packet to terminate transfers equal to a multiple of the Maximum Packet Length. (default).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -