#define DCD_QTD_PER_QHD_MAX 2 // maximum number of qtd that are linked into one queue head at a time
#define QTD_NEXT_INVALID 0x01
/*---------- ENDPTCTRL ----------*/
enum{
ENDPTCTRL_MASK_STALL=BIT_(0),
ENDPTCTRL_MASK_TOGGLE_INHIBIT=BIT_(5),///< used for test only
ENDPTCTRL_MASK_TOGGLE_RESET=BIT_(6),
ENDPTCTRL_MASK_ENABLE=BIT_(7)
};
/*---------- USBCMD ----------*/
enum{
USBCMD_MASK_RUN_STOP=BIT_(0),
USBCMD_MASK_RESET=BIT_(1),
USBCMD_MASK_SETUP_TRIPWIRE=BIT_(13),
USBCMD_MASK_ADD_QTD_TRIPWIRE=BIT_(14)///< This bit is used as a semaphore to ensure the to proper addition of a new dTD to an active (primed) endpoint’s linked list. This bit is set and cleared by software during the process of adding a new dTD
};
// Interrupt Threshold bit 23:16
/*---------- USBSTS, USBINTR ----------*/
enum{
INT_MASK_USB=BIT_(0),
INT_MASK_ERROR=BIT_(1),
INT_MASK_PORT_CHANGE=BIT_(2),
INT_MASK_RESET=BIT_(6),
INT_MASK_SOF=BIT_(7),
INT_MASK_SUSPEND=BIT_(8),
INT_MASK_NAK=BIT_(16)
};
//------------- PORTSC -------------//
enum{
PORTSC_CURRENT_CONNECT_STATUS_MASK=BIT_(0),
PORTSC_FORCE_PORT_RESUME_MASK=BIT_(6),
PORTSC_SUSPEND_MASK=BIT_(7)
};
typedefstruct{
// Word 0: Next QTD Pointer
uint32_tnext;///< Next link pointer This field contains the physical memory address of the next dTD to be processed
// Word 1: qTQ Token
uint32_t:3;
volatileuint32_txact_err:1;
uint32_t:1;
volatileuint32_tbuffer_err:1;
volatileuint32_thalted:1;
volatileuint32_tactive:1;
uint32_t:2;
uint32_tiso_mult_override:2;///< This field can be used for transmit ISOs to override the MULT field in the dQH. This field must be zero for all packet types that are not transmit-ISO.
uint32_t:3;
uint32_tint_on_complete:1;
volatileuint32_ttotal_bytes:15;
uint32_t:0;
// Word 2-6: Buffer Page Pointer List, Each element in the list is a 4K page aligned, physical memory address. The lower 12 bits in each pointer are reserved (except for the first one) as each memory pointer must reference the start of a 4K page
uint32_tbuffer[5];///< buffer1 has frame_n for TODO Isochronous
//------------- DCD Area -------------//
uint16_texpected_bytes;
uint8_tused;
uint8_treserved;
}dcd_qtd_t;
STATIC_ASSERT(sizeof(dcd_qtd_t)==32,"size is not correct");
typedefstructATTR_ALIGNED(64){
// Word 0: Capabilities and Characteristics
uint32_t:15;///< Number of packets executed per transaction descriptor 00 - Execute N transactions as demonstrated by the USB variable length protocol where N is computed using Max_packet_length and the Total_bytes field in the dTD. 01 - Execute one transaction 10 - Execute two transactions 11 - Execute three transactions Remark: Non-isochronous endpoints must set MULT = 00. Remark: Isochronous endpoints must set MULT = 01, 10, or 11 as needed.
uint32_tint_on_setup:1;///< Interrupt on setup This bit is used on control type endpoints to indicate if USBINT is set in response to a setup being received.
uint32_tmax_package_size:11;///< This directly corresponds to the maximum packet size of the associated endpoint (wMaxPacketSize)
uint32_t:2;
uint32_tzero_length_termination:1;///< This bit is used for non-isochronous endpoints to indicate when a zero-length packet is received to terminate transfers in case the total transfer length is “multiple”. 0 - Enable zero-length packet to terminate transfers equal to a multiple of Max_packet_length (default). 1 - Disable zero-length packet on transfers that are equal in length to a multiple Max_packet_length.