keil_examples/USBHostLite/UsbHost/Host/usbhost_lpc17xx.c
/*
**************************************************************************************************************
*                                     PROCESS TRANSFER DESCRIPTOR
*
* Description: This function processes the transfer descriptor
*
* Arguments  : ed            Endpoint descriptor that contains this transfer descriptor
*              token         SETUP, IN, OUT
*              buffer        Current Buffer Pointer of the transfer descriptor
*              buffer_len    Length of the buffer
*
* Returns    : OK       if TD submission is successful
*              ERROR    if TD submission fails
*
**************************************************************************************************************
*/
PROCESS TRANSFER DESCRIPTOR
Description: This function processes the transfer descriptor

Arguments  : ed            Endpoint descriptor that contains this transfer descriptor
token         SETUP, IN, OUT
buffer        Current Buffer Pointer of the transfer descriptor
buffer_len    Length of the buffer


PROCESS TRANSFER DESCRIPTOR Description : This function processes the transfer descriptor Arguments : ed Endpoint descriptor that contains this transfer descriptor token SETUP IN OUT buffer Current Buffer Pointer of the transfer descriptor buffer_len Length of the buffer
int32_t  Host_ProcessTD (volatile  HCED       *ed,
                            volatile  uint32_t  token,
                            volatile  uint8_t *buffer,
                                      uint32_t  buffer_len)
{
    volatile  uint32_t   td_toggle;
    if (ed == EDCtrl) {
        if (token == TD_SETUP) {
            td_toggle = TD_TOGGLE_0;
        } else {
            td_toggle = TD_TOGGLE_1;
        }
    } else {
        td_toggle = 0;
    }
    TDHead->Control = (TD_ROUNDING    |
                      token           |
                      TD_DELAY_INT(0) |                           
                      td_toggle       |
                      TD_CC);
    TDTail->Control = 0;
    TDHead->CurrBufPtr   = (uint32_t) buffer;
    TDTail->CurrBufPtr   = 0;
    TDHead->Next         = (uint32_t) TDTail;
    TDTail->Next         = 0;
    TDHead->BufEnd       = (uint32_t)(buffer + (buffer_len - 1));
    TDTail->BufEnd       = 0;
    ed->HeadTd  = (uint32_t)TDHead | ((ed->HeadTd) & 0x00000002);
    ed->TailTd  = (uint32_t)TDTail;
    ed->Next    = 0;
    if (ed == EDCtrl) {
        LPC_USB->ControlHeadED  = (uint32_t)ed;
        LPC_USB->CommandStatus |= OR_CMD_STATUS_CLF;
        LPC_USB->Control       |= OR_CONTROL_CLE;
    } else {
        LPC_USB->BulkHeadED     = (uint32_t)ed;
        LPC_USB->CommandStatus |= OR_CMD_STATUS_BLF;
        LPC_USB->Control       |= OR_CONTROL_BLE;
    }    
    Host_WDHWait();
	if (!HOST_TDControlStatus) {
        return (OK);
    } else {      
        return (ERR_TD_FAIL);
    }
}
int32_t Host_ProcessTD ( volatile HCED * ed , volatile uint32_t token , volatile uint8_t * buffer , uint32_t buffer_len ) { volatile uint32_t td_toggle ; if ( ed == EDCtrl ) { if ( token == TD_SETUP ) { td_toggle = TD_TOGGLE_0 ; } else { td_toggle = TD_TOGGLE_1 ; } } else { td_toggle = 0 ; } TDHead -> Control = ( TD_ROUNDING | token | TD_DELAY_INT ( 0 ) | td_toggle | TD_CC ) ; TDTail -> Control = 0 ; TDHead -> CurrBufPtr = ( uint32_t ) buffer ; TDTail -> CurrBufPtr = 0 ; TDHead -> Next = ( uint32_t ) TDTail ; TDTail -> Next = 0 ; TDHead -> BufEnd = ( uint32_t ) ( buffer + ( buffer_len - 1 ) ) ; TDTail -> BufEnd = 0 ; ed -> HeadTd = ( uint32_t ) TDHead | ( ( ed -> HeadTd ) & 0x00000002 ) ; ed -> TailTd = ( uint32_t ) TDTail ; ed -> Next = 0 ; if ( ed == EDCtrl ) { LPC_USB -> ControlHeadED = ( uint32_t ) ed ; LPC_USB -> CommandStatus |= OR_CMD_STATUS_CLF ; LPC_USB -> Control |= OR_CONTROL_CLE ; } else { LPC_USB -> BulkHeadED = ( uint32_t ) ed ; LPC_USB -> CommandStatus |= OR_CMD_STATUS_BLF ; LPC_USB -> Control |= OR_CONTROL_BLE ; } Host_WDHWait ( ) ; if ( ! HOST_TDControlStatus ) { return ( OK ) ; } else { return ( ERR_TD_FAIL ) ; } }
PROCESS TRANSFER DESCRIPTOR
Description: This function processes the transfer descriptor
PROCESS TRANSFER DESCRIPTOR Description : This function processes the transfer descriptor
//    if (!(TDHead->Control & 0xF0000000)) {