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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? usbd_udp.c

?? AT91SAM9263的USB Device端口驅動
?? C
?? 第 1 頁 / 共 3 頁
字號:
    Parameters:
        eptnum - Endpoint number.
        data - Pointer to a buffer with the data to send.
        size - Size of the data buffer.
        callback - Optional callback function to invoke when the transfer is
                   complete.
        argument - Optional argument to the callback function.

    Returns:
        USBD_STATUS_SUCCESS if the transfer has been started; otherwise, the
        corresponding error status code.
*/
char USBD_Write(unsigned char eptnum,
                const void *data,
                unsigned int size,
                TransferCallback callback,
                void *argument)
{
    Endpoint *endpoint = &(endpoints[eptnum]);
    Transfer *transfer = &(endpoint->transfer);

    // Check that the endpoint is in Idle state
    if (endpoint->state != UDP_ENDPOINT_IDLE) {

        return USBD_STATUS_LOCKED;
    }

    trace_LOG(trace_INFO, "Write%d(%d) ", eptnum, size);

    // Setup the transfer descriptor
    transfer->data = (void *) data;
    transfer->remaining = size;
    transfer->buffered = 0;
    transfer->transferred = 0;
    transfer->callback = callback;
    transfer->argument = argument;

    // Send the first packet
    endpoint->state = UDP_ENDPOINT_SENDING;
    UDP_WritePayload(eptnum);
    SET_CSR(eptnum, AT91C_UDP_TXPKTRDY);

    // If double buffering is enabled and there is data remaining,
    // prepare another packet
    if ((BOARD_USB_ENDPOINTS_BANKS(eptnum) > 1) && (transfer->remaining > 0)) {

        UDP_WritePayload(eptnum);
    }

    // Enable interrupt on endpoint
    AT91C_BASE_UDP->UDP_IER |= 1 << eptnum;

    return USBD_STATUS_SUCCESS;
}

/*
    Function: USBD_Read
        Reads incoming data on an USB endpoint This methods sets the transfer
        descriptor and activate the endpoint interrupt. The actual transfer is
        then carried out by the endpoint interrupt handler. The Read operation
        finishes either when the buffer is full, or a short packet (inferior to
        endpoint maximum  size) is received.

        *The buffer must be kept allocated until the transfer is finished*.

    Parameters:
        eptnum - Endpoint number.
        data - Pointer to a data buffer.
        size - Size of the data buffer in bytes.
        callback - Optional end-of-transfer callback function.
        argument - Optional argument to the callback function.

    Returns:
        USBD_STATUS_SUCCESS if the read operation has been started; otherwise,
        the corresponding error code.
*/
char USBD_Read(unsigned char eptnum,
               void *data,
               unsigned int size,
               TransferCallback callback,
               void *argument)
{
    Endpoint *endpoint = &(endpoints[eptnum]);
    Transfer *transfer = &(endpoint->transfer);

    // Return if the endpoint is not in IDLE state
    if (endpoint->state != UDP_ENDPOINT_IDLE) {

        return USBD_STATUS_LOCKED;
    }

    trace_LOG(trace_INFO, "Read%d(%d) ", eptnum, size);

    // Endpoint enters Receiving state
    endpoint->state = UDP_ENDPOINT_RECEIVING;

    // Set the transfer descriptor
    transfer->data = data;
    transfer->remaining = size;
    transfer->buffered = 0;
    transfer->transferred = 0;
    transfer->callback = callback;
    transfer->argument = argument;

    // Enable interrupt on endpoint
    AT91C_BASE_UDP->UDP_IER |= 1 << eptnum;

    return USBD_STATUS_SUCCESS;
}

/*
    Function: USBD_Halt
        Sets the HALT feature on the given endpoint (if not already in this
        state).

    Parameters:
        eptnum - Endpoint number.
*/
void USBD_Halt(unsigned char eptnum)
{
    Endpoint *endpoint = &(endpoints[eptnum]);
    
    // Check that endpoint is enabled and not already in Halt state
    if ((endpoint->state != UDP_ENDPOINT_DISABLED)
        && (endpoint->state != UDP_ENDPOINT_HALTED)) {

        trace_LOG(trace_INFO, "Halt%d ", eptnum);

        // Abort the current transfer if necessary
        UDP_EndOfTransfer(eptnum, USBD_STATUS_ABORTED);

        // Put endpoint into Halt state
        SET_CSR(eptnum, AT91C_UDP_FORCESTALL);
        endpoint->state = UDP_ENDPOINT_HALTED;

        // Enable the endpoint interrupt
        AT91C_BASE_UDP->UDP_IER |= 1 << eptnum;
    }
}

/*
    Function: USBD_Unhalt
        Clears the Halt feature on the given endpoint.

    Parameters:
        eptnum - Endpoint number.
*/
void USBD_Unhalt(unsigned char eptnum)
{
    Endpoint *endpoint = &(endpoints[eptnum]);

    // Check if the endpoint is enabled
    if (endpoint->state != UDP_ENDPOINT_DISABLED) {

        trace_LOG(trace_INFO, "Unhalt%d ", eptnum);

        // Return endpoint to Idle state
        endpoint->state = UDP_ENDPOINT_IDLE;

        // Clear FORCESTALL flag
        CLEAR_CSR(eptnum, AT91C_UDP_FORCESTALL);

        // Reset Endpoint Fifos, beware this is a 2 steps operation
        AT91C_BASE_UDP->UDP_RSTEP |= 1 << eptnum;
        AT91C_BASE_UDP->UDP_RSTEP &= ~(1 << eptnum);
    }
}
    
/*
    Function: USBD_IsHalted
        Returns the current Halt status of an endpoint.

    Parameters:
        eptnum - Endpoint number.

    Returns:
        1 if the endpoint is currently halted; otherwise 0.
*/
unsigned char USBD_IsHalted(unsigned char eptnum)
{
    Endpoint *endpoint = &(endpoints[eptnum]);
    if (endpoint->state == UDP_ENDPOINT_HALTED) {

        return 1;
    }
    else {

        return 0;
    }
}

/*
    Function: USBD_Stall
        Causes the given endpoint to acknowledge the next packet it receives
        with a STALL handshake.

    Parameters:
        eptnum - Endpoint number.

    Returns:
        USBD_STATUS_SUCCESS or USBD_STATUS_LOCKED.
*/
unsigned char USBD_Stall(unsigned char eptnum)
{
    Endpoint *endpoint = &(endpoints[eptnum]);

    // Check that endpoint is in Idle state
    if (endpoint->state != UDP_ENDPOINT_IDLE) {

        trace_LOG(trace_WARNING, "USBD_Stall: Endpoint%d locked\n\r", eptnum);
        return USBD_STATUS_LOCKED;
    }

    trace_LOG(trace_INFO, "Stall%d ", eptnum);
    SET_CSR(eptnum, AT91C_UDP_FORCESTALL);

    return USBD_STATUS_SUCCESS;
}

/*
    Function: USBD_RemoteWakeUp
        Starts a remote wake-up procedure.
*/
void USBD_RemoteWakeUp()
{
    UDP_EnablePeripheralClock();
    UDP_EnableUsbClock();
    UDP_EnableTransceiver();

    trace_LOG(trace_INFO, "RWUp ");

    // Activates a remote wakeup (edge on ESR), then clear ESR
    AT91C_BASE_UDP->UDP_GLBSTATE |= AT91C_UDP_ESR;
    AT91C_BASE_UDP->UDP_GLBSTATE &= ~AT91C_UDP_ESR;
}

/*
    Function: USBD_SetAddress
        Sets the device address to the given value.

    Parameters:
        address - New device address.
*/
void USBD_SetAddress(unsigned char address)
{
    trace_LOG(trace_INFO, "SetAddr(%d) ", address);

    // Set address
    AT91C_BASE_UDP->UDP_FADDR = AT91C_UDP_FEN | address;

    // If the address is 0, the device returns to the Default state
    if (address == 0) {

        AT91C_BASE_UDP->UDP_GLBSTATE = 0;
        deviceState = USBD_STATE_DEFAULT;
    }
    // If the address is non-zero, the device enters the Address state
    else {

        AT91C_BASE_UDP->UDP_GLBSTATE = AT91C_UDP_FADDEN;
        deviceState = USBD_STATE_ADDRESS;
    }
}

/*
    Function: USBD_SetConfiguration
        Sets the current device configuration.

    Parameters:
        cfgnum - Configuration number to set.
*/
void USBD_SetConfiguration(unsigned char cfgnum)
{
    trace_LOG(trace_INFO, "SetCfg(%d) ", cfgnum);

    // If the configuration number if non-zero, the device enters the
    // Configured state
    if (cfgnum != 0) {

        deviceState = USBD_STATE_CONFIGURED;
        AT91C_BASE_UDP->UDP_GLBSTATE |= AT91C_UDP_CONFG;
    }
    // If the configuration number is zero, the device goes back to the Address
    // state
    else {

        deviceState = USBD_STATE_ADDRESS;
        AT91C_BASE_UDP->UDP_GLBSTATE = AT91C_UDP_FADDEN;

        // Abort all transfers
        UDP_DisableEndpoints();
    }
}

/*
    Function: USBD_Connect
        Connects the pull-up on the D+ line of the USB.
*/
void USBD_Connect()
{
    trace_LOG(trace_DEBUG, "Conn ");

#if defined(BOARD_USB_PULLUP_EXTERNAL)
    const Pin pinPullUp = PIN_USB_PULLUP;
    if (pinPullUp.attribute == PIO_OUTPUT_0) {

        PIO_Set(&pinPullUp);
    }
    else {

        PIO_Clear(&pinPullUp);
    }
#elif defined(BOARD_USB_PULLUP_INTERNAL)
    AT91C_BASE_UDP->UDP_TXVC |= AT91C_UDP_PUON;
#elif defined(BOARD_USB_PULLUP_MATRIX)
    AT91C_BASE_MATRIX->MATRIX_USBPCR |= AT91C_MATRIX_USBPCR_PUON;
#elif !defined(BOARD_USB_PULLUP_ALWAYSON)
    #error Unsupported pull-up type.
#endif
}

/*
    Function: USBD_Disconnect
        Disconnects the pull-up from the D+ line of the USB.
*/
void USBD_Disconnect()
{
    trace_LOG(trace_DEBUG, "Disc ");

#if defined(BOARD_USB_PULLUP_EXTERNAL)
    const Pin pinPullUp = PIN_USB_PULLUP;
    if (pinPullUp.attribute == PIO_OUTPUT_0) {

        PIO_Clear(&pinPullUp);
    }
    else {

        PIO_Set(&pinPullUp);
    }
#elif defined(BOARD_USB_PULLUP_INTERNAL)
    AT91C_BASE_UDP->UDP_TXVC &= ~AT91C_UDP_PUON;
#elif defined(BOARD_USB_PULLUP_MATRIX)
    AT91C_BASE_MATRIX->MATRIX_USBPCR &= ~AT91C_MATRIX_USBPCR_PUON;
#elif !defined(BOARD_USB_PULLUP_ALWAYSON)
    #error Unsupported pull-up type.
#endif

    // Device returns to the Powered state
    if (deviceState > USBD_STATE_POWERED) {
    
        deviceState = USBD_STATE_POWERED;
    }
}

/*
    Function: USBD_Init
        Initializes the USB driver.
*/
void USBD_Init()
{
    trace_LOG(trace_INFO, "USBD_Init\n\r");

    // Reset endpoint structures
    UDP_ResetEndpoints();

    // Configure the pull-up on D+ and disconnect it
#if defined(BOARD_USB_PULLUP_EXTERNAL)
    const Pin pinPullUp = PIN_USB_PULLUP;
    PIO_Configure(&pinPullUp, 1);
#elif defined(BOARD_USB_PULLUP_INTERNAL)
    AT91C_BASE_UDP->UDP_TXVC &= ~AT91C_UDP_PUON;
#elif defined(BOARD_USB_PULLUP_MATRIX)
    AT91C_BASE_MATRIX->MATRIX_USBPCR &= ~AT91C_MATRIX_USBPCR_PUON;
#elif !defined(BOARD_USB_PULLUP_ALWAYSON)
    #error Missing pull-up definition.
#endif

    // Device is in the Attached state
    deviceState = USBD_STATE_SUSPENDED;
    previousDeviceState = USBD_STATE_POWERED;
    UDP_EnablePeripheralClock();
    UDP_EnableUsbClock();
    AT91C_BASE_UDP->UDP_IER = AT91C_UDP_WAKEUP;

    // Configure interrupts
    USBDCallbacks_Initialized();
}

/*
    Function: USBD_GetState
        Returns the current state of the USB device.

    Returns:
        Device current state.
*/
unsigned char USBD_GetState()
{
    return deviceState;
}

//------------------------------------------------------------------------------
/// Indicates if the device is running in high or full-speed. Always returns 0
/// since UDP does not support high-speed mode.
//------------------------------------------------------------------------------
unsigned char USBD_IsHighSpeed(void)
{
    return 0;
}


#endif //#if defined(BOARD_USB_UDP)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本道在线观看一区二区| 国产一本一道久久香蕉| 中文字幕一区二区三区色视频| 日韩你懂的在线播放| 欧美久久久久中文字幕| 欧美亚洲综合一区| 欧美视频一区二区三区四区| 欧美色图一区二区三区| 欧日韩精品视频| 欧美久久高跟鞋激| 日韩欧美中文字幕公布| 精品免费99久久| 久久久精品综合| 自拍偷拍亚洲欧美日韩| 亚洲精品免费在线观看| 亚洲妇女屁股眼交7| 日韩成人av影视| 久久草av在线| 国产aⅴ综合色| 色综合欧美在线视频区| 欧美日韩国产精品成人| 欧美v国产在线一区二区三区| 久久久国产午夜精品| 亚洲人午夜精品天堂一二香蕉| 亚洲一区二区三区四区中文字幕| 天天操天天色综合| 国产乱子伦一区二区三区国色天香| 夫妻av一区二区| 色国产综合视频| 亚洲精品在线免费播放| 亚洲人成伊人成综合网小说| 日本女人一区二区三区| 岛国av在线一区| 欧美精品1区2区| 国产精品人人做人人爽人人添| 亚洲国产综合视频在线观看| 激情综合色综合久久综合| 91在线视频在线| 日韩精品一区二区三区中文不卡| 中文字幕一区av| 蜜桃视频一区二区三区在线观看| 99国产精品视频免费观看| 日韩一区二区影院| 亚洲精品成人a在线观看| 国产在线日韩欧美| 欧美日韩一区二区三区四区五区| 国产亚洲欧美日韩在线一区| 香蕉久久夜色精品国产使用方法| 国产成人免费网站| 日韩三级高清在线| 亚洲综合精品自拍| 99久久99久久综合| 久久久久久亚洲综合| 图片区小说区国产精品视频| 99精品视频在线免费观看| 久久伊99综合婷婷久久伊| 日韩国产在线一| 一本色道久久综合亚洲aⅴ蜜桃 | 精品一区二区在线看| 色婷婷综合久久久久中文 | 欧美男女性生活在线直播观看| 日本一区二区综合亚洲| 国内精品视频一区二区三区八戒| 欧美三级在线看| 亚洲精品写真福利| 一本色道a无线码一区v| 亚洲色图都市小说| 99久久精品99国产精品| 中文字幕在线观看一区| 豆国产96在线|亚洲| 久久久精品tv| 国产激情偷乱视频一区二区三区| 久久综合精品国产一区二区三区 | 成人小视频免费在线观看| 久久久av毛片精品| 国产一区二区不卡在线| 久久久精品免费免费| 国产精品资源网| 久久久国产精品不卡| 成人黄色国产精品网站大全在线免费观看| 久久综合久色欧美综合狠狠| 韩国av一区二区三区| 久久久久久久网| 成人激情开心网| 亚洲美女在线一区| 欧美日韩中文字幕一区| 首页国产欧美久久| 精品国产一区二区三区av性色 | 午夜精品福利一区二区三区蜜桃| 欧美中文字幕一区二区三区亚洲| 亚洲成av人片在线观看| 91精品国产综合久久小美女| 精品一区二区三区欧美| 国产精品视频看| 欧洲中文字幕精品| 日本91福利区| 国产亚洲1区2区3区| 91亚洲男人天堂| 亚洲成国产人片在线观看| 欧美sm美女调教| 成人av片在线观看| 亚洲第一成年网| 国产亚洲欧美日韩俺去了| 色综合久久久久久久久久久| 日韩一区欧美二区| 国产日韩精品视频一区| 色婷婷精品大在线视频 | 国产女人18毛片水真多成人如厕 | 亚洲一区自拍偷拍| 精品国产百合女同互慰| 色婷婷综合久久久久中文 | 亚洲欧美乱综合| 欧美一区二区三区四区在线观看 | 欧美精品久久一区二区三区| 国产精品中文有码| 一区二区三区在线免费视频| 精品国产乱码久久久久久图片| 99re亚洲国产精品| 精品在线观看免费| 一区二区三区**美女毛片| 精品成人一区二区三区四区| 色噜噜狠狠一区二区三区果冻| 国内精品第一页| 午夜精品一区在线观看| 亚洲婷婷综合色高清在线| 欧美成人一区二区| 欧美精品xxxxbbbb| 色久优优欧美色久优优| 成人教育av在线| 国产精品一区三区| 免费观看久久久4p| 亚洲成人免费视| 一区二区三区国产精华| 国产精品免费视频观看| 久久综合成人精品亚洲另类欧美 | 国产一二三精品| 伦理电影国产精品| 日本伊人色综合网| 午夜日韩在线观看| 亚洲卡通欧美制服中文| 中文字幕一区二区三区av| 日本一区二区成人| 精品国产乱码久久久久久闺蜜| 91福利在线导航| 色欧美日韩亚洲| 99久久精品免费| 成人av电影观看| 粉嫩av一区二区三区| 成人免费高清在线| 不卡电影一区二区三区| 国产成人免费视频一区| 高清不卡一区二区| 成人18视频日本| 99精品视频一区二区| www.日韩大片| 91小宝寻花一区二区三区| 99久久精品国产一区二区三区 | 欧美区在线观看| 欧美日韩国产首页| 91精品国产高清一区二区三区| 5月丁香婷婷综合| 欧美不卡激情三级在线观看| 欧美mv日韩mv国产| 欧美激情一区二区三区在线| 中文字幕在线不卡| 亚洲一二三四在线观看| 无码av免费一区二区三区试看 | 日韩国产欧美三级| 老司机精品视频在线| 国产在线一区观看| 97久久超碰精品国产| 在线国产电影不卡| 在线综合+亚洲+欧美中文字幕| 日韩欧美电影在线| 国产农村妇女精品| 亚洲一区二区三区在线| 日本va欧美va精品| 丁香啪啪综合成人亚洲小说| 欧美影院精品一区| 精品国产乱码91久久久久久网站| 中文字幕欧美国产| 亚洲第一久久影院| 国产成都精品91一区二区三| 91成人看片片| 精品日产卡一卡二卡麻豆| 中文字幕一区二区三区在线播放 | 日韩亚洲欧美在线观看| 国产精品久久久久桃色tv| 亚洲摸摸操操av| 久久精品国产一区二区| 91首页免费视频| 日韩欧美国产午夜精品| 亚洲欧美日韩在线不卡| 国产在线播放一区| 在线观看日产精品| 日本一区二区三区在线观看| 五月天精品一区二区三区| 不卡一区二区三区四区| 欧美mv日韩mv| 亚洲国产精品一区二区尤物区|