亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? usb.c

?? 一個簡單的helloworld編程
?? C
?? 第 1 頁 / 共 4 頁
字號:
    USBWriteCommand(USB_COMMAND_SET_MODE);
    USBWriteData(USB_CONFIG1_NO_LAZY_CLOCK | USB_CONFIG1_CLOCK_RUNNING |
                 USB_CONFIG1_SOFT_CONNECT);
    USBWriteData(USB_CONFIG2_SET_TO_ONE | USB_CONFIG2_CLOCK_12M);
    Uart_Printf("USB ON\n");
    Uart_Printf("Your PC will add the new USB\n");
    Uart_Printf("Press any key ,close USB and exit\n");
    USBEnable();
    do{
    	USBISRPOLLING(0);
    }
    while(!Uart_GetKey());
    USBOFF();
    rSYSCFG=saveSyscfg;
}

void USBOFF(void)
{
    USBWriteCommand(USB_COMMAND_SEND_RESUME);
    Delay(10000);
    USBWriteCommand(USB_COMMAND_SET_ADDRESS_ENABLE);
    USBWriteData(0);
    
    USBWriteCommand(USB_COMMAND_SET_ENDPOINT_ENABLE);
    USBWriteData(0);
    //
    // Enable the interrupts for the bulk endpoints.
    //
    USBWriteCommand(USB_COMMAND_SET_DMA);
    USBWriteData(USB_DMA_ENDP4_INT_ENABLE | USB_DMA_ENDP5_INT_ENABLE);
     
    USBWriteCommand(USB_COMMAND_SET_MODE);
    USBWriteData(0);
    USBWriteData(USB_CONFIG2_SET_TO_ONE | USB_CONFIG2_CLOCK_12M);
 }

//****************************************************************************
//
// USBISR is the interrupt handler routine for the USB.
//
//****************************************************************************
void __irq USBISR(void)
{
    unsigned long ulIntStatus, ulTransactionStatus, ulLength,uSize;
    U8 *pucChar;

    
    // Read the PDIUSBD12 interrupt register.
    rI_ISPC=BIT_EINT0;	//clear pending_bit
    USBWriteCommand(USB_COMMAND_READ_INTERRUPT);
    ulIntStatus = USBReadData();
    ulIntStatus |= USBReadData() << 8;

    // Do nothing if there was a bus reset.
      if(ulIntStatus & USB_INT1_BUS_RESET)
    {
    	return;
    }
    // Handle an interrupt on the bulk out endpoint.
     if(ulIntStatus & USB_INT1_ENDPOINT2_OUT)
    {
       //Uart_Printf("Occur USB_INT1_ENDPOINT2_OUT interrupt\n");
        // Read the status of the last transaction on the bulk out endpoint.
         USBWriteCommand(USB_COMMAND_READ_LAST_XACTION_STATUS +
                        USB_ENDPOINT_BULK_OUT);
        ulTransactionStatus = USBReadData();
        //Uart_Printf("Status: %u\n",ulTransactionStatus);

        // Was a packet of data received successfully?
        if(ulTransactionStatus & USB_XACTION_STATUS_DATA_RX_TX_SUCCESS)
        {
       // If there is a buffer to read this data into, then read the data into that buffer.
       // Read the packet.
        	uSize=USBReadEndpoint(USB_ENDPOINT_BULK_OUT, &sUSB.pucBulkOut, &sUSB.ulBulkOutCount);
        	//Uart_Printf("Size: %u\n",uSize);
        	Uart_Printf("usbbuffer0: %s\n",usbbuffer0);
        	Uart_Printf("usbbuffer1: %s\n",usbbuffer1);
        	Uart_Printf("usbbuffer2: %s\n",usbbuffer2);
         }
    }
    // Handle an interrupt on the control out endpoint.
    if(ulIntStatus & USB_INT1_CONTROL_OUT)
    {
        //Uart_Printf("Occur USB_INT1_CONTROL_OUT interrupt\n");
        // Read the status of the last transaction on the control out endpoint.
       USBWriteCommand(USB_COMMAND_READ_LAST_XACTION_STATUS +  USB_ENDPOINT_CONTROL_OUT);
        ulTransactionStatus = USBReadData();
        // Was a setup packet received?
        if(ulTransactionStatus & USB_XACTION_STATUS_SETUP_PACKET)
        {
        // Read the packet.
            pucChar = (U8 *)&sUSB.sControlOut;
            ulLength = sizeof(ControlTransfer);
            if(USBReadEndpoint(USB_ENDPOINT_CONTROL_OUT, &pucChar,
                               &ulLength) != sizeof(ControlTransfer))
            {
          // The size of the setup packet is incorrect, so stall both of the control endpoints.
                USBStallEndpoint(USB_ENDPOINT_CONTROL_OUT, 1);
                USBStallEndpoint(USB_ENDPOINT_CONTROL_IN, 1);
            }
            else
            {
             // Acknowledge both the control in and control out endpoints,
             // and send a clear buffer command to the control out endpoint.
                USBWriteCommand(USB_COMMAND_SELECT_ENDPOINT + USB_ENDPOINT_CONTROL_OUT);
                USBWriteCommand(USB_COMMAND_ACKNOWLEDGE_ENDPOINT);
                USBWriteCommand(USB_COMMAND_CLEAR_BUFFER);
                USBWriteCommand(USB_COMMAND_SELECT_ENDPOINT + USB_ENDPOINT_CONTROL_IN);
                USBWriteCommand(USB_COMMAND_ACKNOWLEDGE_ENDPOINT);

            // Process the command in the setup packet.
            if(((sUSB.sControlOut.bmRequestType & USB_RT_TYPE_MASK) ==
                    USB_RT_TYPE_STANDARD) && (sUSB.sControlOut.bRequest < 16))
                {
            // This is a standard request, so call the appropriate routine.
              (*USBStandardDeviceRequest[sUSB.sControlOut.bRequest])();
                }
                else
                {
            // All other requests are treated as reserved requests.
                    USBReserved();
                }
            }
        }
        else
        {  // The packet was not a setup packet, so ignore it.  Send a clear
            // buffer command to the control out endpoint so it will receive new packets.
            //
            USBWriteCommand(USB_COMMAND_SELECT_ENDPOINT +
                            USB_ENDPOINT_CONTROL_OUT);
            USBWriteCommand(USB_COMMAND_CLEAR_BUFFER);
            // Acknowledge both the control in and control out endpoints.
            USBWriteCommand(USB_COMMAND_ACKNOWLEDGE_ENDPOINT);
            USBWriteCommand(USB_COMMAND_SELECT_ENDPOINT + USB_ENDPOINT_CONTROL_IN);
            USBWriteCommand(USB_COMMAND_ACKNOWLEDGE_ENDPOINT);
        }
    }
    // Handle an interrupt on the control in endpoint.
    if(ulIntStatus & USB_INT1_CONTROL_IN)
    {
        //Uart_Printf("Occur USB_INT1_CONTROL_IN interrupt\n");
        // Read the status of the last transaction on the control in endpoint.
        USBWriteCommand(USB_COMMAND_READ_LAST_XACTION_STATUS + USB_ENDPOINT_CONTROL_IN);
        USBReadData();

        // Was this the last block of data to be sent back to the host?
         if(sUSB.ulControlInCount != 0)
        {
            // Send the next packet of data to the host.
        USBWriteEndpoint(USB_ENDPOINT_CONTROL_IN, &sUSB.pucControlIn,&sUSB.ulControlInCount);
        }
        else
        {  // There is no more data to send, so send an empty packet.
            ulLength = 0;
            USBWriteEndpoint(USB_ENDPOINT_CONTROL_IN, 0, &ulLength);
        }
    }
    // Handle an interrupt on the bulk in endpoint.
    if(ulIntStatus & USB_INT1_ENDPOINT2_IN)
    {
        //Uart_Printf("Occur USB_INT1_ENDPOINT2_IN interrupt\n");
        // Read the status of the last transaction on the bulk in endpoint.
        USBWriteCommand(USB_COMMAND_READ_LAST_XACTION_STATUS + USB_ENDPOINT_BULK_IN);
        USBReadData();

        // Was this the last block of data to be sent back to the host?
        if(sUSB.ulBulkInCount != 0)
        {// Send the next packet of data to the host.
         USBWriteEndpoint(USB_ENDPOINT_BULK_IN, &sUSB.pucBulkIn, &sUSB.ulBulkInCount);
        }
    }
}

//****************************************************************************
//
// USBReadData will read a  value from the data register of the PDIUSBD12.
//
//****************************************************************************
unsigned char USBReadData(void)
{
    unsigned char * volatile dataregister = (unsigned char*)(unsigned char *)(Usb_Base_Address + Usb_Data_Address);
    int delay;
    U8 datavalue;

    // Write the value to the data register.
    datavalue = * dataregister;
    for(delay = 0; delay < 24; delay++)
    {
    }
    return(datavalue);
}

//****************************************************************************
//
// USBWriteEndpoint writes data to the specified endpoint.
//
//****************************************************************************
void USBWriteEndpoint(unsigned long ulEndpoint, const unsigned char **ppucData,unsigned long *pulLength)
{
    U32 ulIdx, ulLength;

    // Determine the size of the packet to be sent based on the endpoint.
    if(ulEndpoint == USB_ENDPOINT_CONTROL_IN)
    {
        // The maximum packet size for the control endpoint is 16.
        ulLength = (*pulLength > 16) ? 16 : *pulLength;
    }
    else
    {
        // The maxmium packet size for the bulk endpoint is 64.
         ulLength = (*pulLength > 64) ? 64 : *pulLength;
    }
    // Select the appropriate endpoint.
    USBWriteCommand(USB_COMMAND_SELECT_ENDPOINT + ulEndpoint);

    // Send the write buffer command.
    USBWriteCommand(USB_COMMAND_WRITE_BUFFER);

    // Write the reserved byte to the buffer.
    USBWriteData(0);

    // Write the length of the data packet.
    USBWriteData(ulLength);

    // Write the data into the transmit buffer.
    for(ulIdx = 0; ulIdx < ulLength; ulIdx++)
    {
        USBWriteData(*(*ppucData)++);
    }

    //
    // Decrement the count of bytes to write.
    *pulLength -= ulLength;


    // Send the validate buffer command so that the endpoint will transmit the packet.
    USBWriteCommand(USB_COMMAND_VALIDATE_BUFFER);
}

//****************************************************************************
//
// USBReadEndpoint reads data from the specified endpoint.
//
//****************************************************************************
unsigned long
USBReadEndpoint(unsigned long ulEndpoint,unsigned char **ppucData,unsigned long *pulLength)
{
    U32 ulIdx, ulLength;
     
    // Select the appropriate endpoint.
    USBWriteCommand(USB_COMMAND_SELECT_ENDPOINT + ulEndpoint);

    // Is there buffer space to fill with this data or should we throw the data away?
    if(*pulLength)
    {    // Send the read buffer command.
       USBWriteCommand(USB_COMMAND_READ_BUFFER);
        // Throw away the reserved byte from the beginning of the buffer.

        USBReadData();
        // Read the length of the data buffer.
        ulLength = USBReadData();
        // Read the data into the receive buffer.
        for(ulIdx = 0; (ulIdx < ulLength) && (ulIdx < *pulLength); ulIdx++)
        {
            *(*ppucData)++ = USBReadData();
        }

        // Decrement the count of bytes to read.
        *pulLength -= ulIdx;
    }  
    // Send the clear buffer command so that the endpoint can receive another packet.
    USBWriteCommand(USB_COMMAND_CLEAR_BUFFER);

    // Return the size of the packet received.
    return(ulLength);
}

//****************************************************************************
//
// USBSendACK transmits a block of data back to the host via the bulk
// endpoint 1.
//
//****************************************************************************
unsigned long
USBSendACK(const unsigned char *pucData, unsigned long ulLength)
{
    // If a block is already being transmitted, then return a failure.
     if(sUSB.ulACKInCount)
    {
        return(0);
    }
    // Prepare to transmit this block back to the host.
    sUSB.pucACKIn = pucData;
    sUSB.ulACKInCount = ulLength;

    // Send the first packet of this block back to the host.
    USBWriteEndpoint(USB_ENDPOINT_ACK_IN, &sUSB.pucACKIn,&sUSB.ulACKInCount);
    return(1);
}

//****************************************************************************
//
// USBReserved handles device requests which are not supported by this USB
// device implementation.
//
//****************************************************************************
void USBReserved(void)
{
    // Stall both control endpoints.
    USBStallEndpoint(USB_ENDPOINT_CONTROL_OUT, 1);
    USBStallEndpoint(USB_ENDPOINT_CONTROL_IN, 1);
}

//****************************************************************************
//
// USBStallEndpoint stalls or un-stalls the specified endpoint.
//
//****************************************************************************
void USBStallEndpoint(unsigned long ulEndpoint, unsigned long bStall)
{
    //
    // Send the appropriate set endpoint status command to the PDIUSBD12.
    //
    USBWriteCommand(USB_COMMAND_SET_ENDPOINT_STATUS + ulEndpoint);
    USBWriteData(bStall ? 1 : 0);
}

//****************************************************************************
//
// USBGetStatus implements the USB Get_Status device request.
//
//****************************************************************************
void USBGetStatus(void)
{
    U8 ucStatus[2];
    U32 ulEndpoint;
    // Determine how to handle this request based on the recipient.

    switch(sUSB.sControlOut.bmRequestType & USB_RT_RECIPIENT_MASK)
    {
        // If the recipient is a device, return the state of the device's
        // remote wakeup and self powered states.
         case USB_RT_RECIPIENT_DEVICE:
        {
            // The player is self powered and does not support remote wakeup.
            ucStatus[0] = USB_DEVICE_STATUS_SELF_POWERED;
            ucStatus[1] = 0;

            // Send our response back to the host.
            USBSendControl(ucStatus, 2);

            // We're done handling this request.
             break;
        }
        // If the recipient is a device interface, return a value of
        // 0x00 as required by the USB spec.
        case USB_RT_RECIPIENT_INTERFACE:
        {
       // The USB spec. requires a GetStatus request for an interface return a pair of zero bytes.
            ucStatus[0] = 0;
            ucStatus[1] = 0;
            // Send our response back to the host.
            USBSendControl(ucStatus, 2);

            // We're done handling this request.
            break;
        }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人在线影院 | 欧美不卡视频一区| 欧美日高清视频| 欧美综合亚洲图片综合区| 在线中文字幕不卡| 91福利小视频| 欧美精品在线观看播放| 欧美精品丝袜久久久中文字幕| 欧美日本乱大交xxxxx| 在线成人免费视频| 精品入口麻豆88视频| 亚洲精品在线三区| 国产精品天美传媒| 亚洲啪啪综合av一区二区三区| 亚洲精品国产第一综合99久久| 一区二区在线电影| 天天色 色综合| 久国产精品韩国三级视频| 激情综合色播激情啊| 高清国产一区二区三区| 91麻豆精品视频| 欧美视频你懂的| 欧美大白屁股肥臀xxxxxx| 欧美精品一区二区在线播放| 国产欧美1区2区3区| 一区二区三区自拍| 日韩国产欧美三级| 国产精品一色哟哟哟| 91视频一区二区| 欧美日韩国产欧美日美国产精品| 精品国产不卡一区二区三区| 国产精品久久久久久久浪潮网站| 亚洲国产乱码最新视频| 久久国产成人午夜av影院| 播五月开心婷婷综合| 欧美日本一区二区三区四区| 久久久久亚洲蜜桃| 亚洲理论在线观看| 韩国av一区二区三区四区| 成人一区二区三区视频在线观看| 在线亚洲一区二区| 精品国产免费人成电影在线观看四季 | 久久激五月天综合精品| 粗大黑人巨茎大战欧美成人| 欧美三级日韩在线| 久久久久久电影| 亚洲动漫第一页| 国产成人亚洲综合色影视| 欧美色中文字幕| 久久久青草青青国产亚洲免观| 亚洲综合精品自拍| 国产一区二区免费视频| 欧美少妇一区二区| 中文一区二区在线观看| 日韩国产欧美在线播放| 91最新地址在线播放| 精品播放一区二区| 亚洲18影院在线观看| 不卡一区中文字幕| 精品欧美一区二区在线观看| 一片黄亚洲嫩模| 成人动漫在线一区| 欧美成人精品3d动漫h| 亚洲综合色网站| 成人免费视频网站在线观看| 精品伦理精品一区| 五月婷婷欧美视频| 91免费精品国自产拍在线不卡| 精品人在线二区三区| 图片区小说区国产精品视频| 91女人视频在线观看| 国产欧美一区视频| 久久电影网电视剧免费观看| 欧美专区在线观看一区| 日韩美女啊v在线免费观看| 国产一区不卡在线| 欧美成人精精品一区二区频| 爽爽淫人综合网网站| 在线观看不卡视频| 亚洲欧美日韩国产一区二区三区 | 日韩一区二区三区免费看| 亚洲乱码中文字幕| av男人天堂一区| 亚洲国产精品二十页| 国产一区二区在线视频| 精品国产不卡一区二区三区| 蜜臀av一区二区在线观看| 欧美日韩视频在线第一区 | 亚洲香蕉伊在人在线观| 成人av免费在线| 中文字幕第一区二区| 国产黄人亚洲片| www精品美女久久久tv| 久久国产精品无码网站| 日韩午夜三级在线| 日韩**一区毛片| 91麻豆精品国产| 爽好久久久欧美精品| 欧美精品在线观看一区二区| 婷婷中文字幕一区三区| 制服丝袜亚洲播放| 日韩av在线免费观看不卡| 91精品国产综合久久精品 | 91麻豆精品国产综合久久久久久| 亚洲va国产天堂va久久en| 欧美在线色视频| 亚洲超丰满肉感bbw| 91麻豆精品国产自产在线观看一区 | 蜜桃视频在线观看一区二区| 日韩一区二区三区高清免费看看| 美腿丝袜亚洲一区| 精品国产三级电影在线观看| 国产在线播放一区三区四| 国产欧美一区二区在线观看| 波多野结衣在线aⅴ中文字幕不卡| 日本一区二区成人在线| 色综合久久久久综合体桃花网| 亚洲欧美视频在线观看视频| 欧美性极品少妇| 蜜桃一区二区三区在线观看| 久久久噜噜噜久久中文字幕色伊伊| 国产不卡视频一区| 一区二区三区在线视频免费| 69av一区二区三区| 国模少妇一区二区三区| 中文字幕亚洲区| 欧美亚洲国产一区二区三区| 美女一区二区视频| 国产欧美精品在线观看| 欧美在线观看一二区| 久久激情综合网| 欧美激情一区不卡| 欧美日韩一区二区在线视频| 黄页视频在线91| 亚洲欧洲日产国产综合网| 欧美日韩免费高清一区色橹橹 | 成人午夜激情在线| 一区二区三区.www| 精品入口麻豆88视频| www.欧美日韩国产在线| 亚洲成人午夜影院| 国产天堂亚洲国产碰碰| 色噜噜狠狠色综合中国| 美女视频一区在线观看| 日韩毛片一二三区| 日韩欧美www| 色欧美片视频在线观看| 麻豆成人久久精品二区三区小说| 国产精品丝袜黑色高跟| 欧美放荡的少妇| av在线不卡免费看| 蜜臀91精品一区二区三区| 日韩一区在线免费观看| 日韩欧美国产综合一区| 色综合久久综合中文综合网| 狠狠色丁香九九婷婷综合五月| 亚洲激情第一区| 国产丝袜美腿一区二区三区| 欧美日韩国产综合久久| www.欧美日韩| 久久av中文字幕片| 亚洲成人三级小说| 国产精品久久久久久久久果冻传媒| 欧美一区二区在线看| 91免费国产在线观看| 狠狠色丁香婷综合久久| 亚洲成人激情社区| 综合欧美亚洲日本| 久久影院午夜论| 欧美一区二区在线观看| 日本国产一区二区| 成人性生交大片免费看中文 | 日本久久电影网| 国产成人精品一区二区三区四区 | 奇米影视一区二区三区| 亚洲人成人一区二区在线观看| 久久久亚洲精品一区二区三区| 欧美久久一区二区| 91激情五月电影| 99精品偷自拍| 成人精品视频.| 国产成人精品网址| 国产综合色在线| 免费高清在线一区| 丝瓜av网站精品一区二区| 亚洲国产婷婷综合在线精品| 亚洲三级免费观看| 亚洲欧洲精品一区二区三区| 欧美国产一区二区在线观看| 久久久亚洲精品石原莉奈| 精品国产乱子伦一区| 日韩亚洲欧美中文三级| 91麻豆精品国产91久久久使用方法| 在线免费av一区| 91免费观看视频在线| 99r精品视频| 91影院在线免费观看| 91免费观看国产| 色噜噜夜夜夜综合网| 色哟哟在线观看一区二区三区|