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

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

?? cdcdserialdriver.c

?? IAR5.2下 AT91SAM9260 ARM 對 MCP2515 控制源化碼
?? C
字號:
/* ----------------------------------------------------------------------------
 *         ATMEL Microcontroller Software Support 
 * ----------------------------------------------------------------------------
 * Copyright (c) 2008, Atmel Corporation
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the disclaimer below.
 *
 * Atmel's name may not be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * ----------------------------------------------------------------------------
 */

/*
    Title: CDCDSerialDriver implementation

    About: Purpose
        Implementation of the CDCDSerialDriver class methods.
*/

//------------------------------------------------------------------------------
//         Headers
//------------------------------------------------------------------------------

#include "CDCDSerialDriver.h"
#include "CDCDSerialDriverDescriptors.h"
#include <utility/trace.h>
#include <utility/assert.h>
#include <usb/device/core/USBDDriver.h>
#include <usb/common/cdc/CDCLineCoding.h>
#include <usb/common/cdc/CDCGenericRequest.h>
#include <usb/common/cdc/CDCSetControlLineStateRequest.h>

//------------------------------------------------------------------------------
//         Types
//------------------------------------------------------------------------------
/*
    Type: CDCDSerialDriver
        USB driver for a CDC class implementing a virtual COM serial connection.

    Variables:
        usbdDriver - Standard USBDDriver instance.
        lineCoding - Current line coding (baudrate, parity, stop bits).
        isCarrierActivated - Indicates if the RS232 carrier is active.
*/
typedef struct {

    USBDDriver usbdDriver;
    CDCLineCoding lineCoding;
    unsigned char isCarrierActivated;
    unsigned short serialState;

} CDCDSerialDriver;

//------------------------------------------------------------------------------
//         Internal variables
//------------------------------------------------------------------------------
/*
    Variable: cdcdSerialDriver
        Static instance of the CDC serial driver.
*/
static CDCDSerialDriver cdcdSerialDriver;

//------------------------------------------------------------------------------
//         Internal functions
//------------------------------------------------------------------------------
/*
    Function: CDCDSerialDriver_SetLineCodingCallback
        Callback function which should be invoked after the data of a
        SetLineCoding request has been retrieved. Sends a zero-length packet
        to the host for acknowledging the request.
*/
static void CDCDSerialDriver_SetLineCodingCallback()
{
    USBD_Write(0, 0, 0, 0, 0);
}

/*
    Function: CDCDSerialDriver_SetLineCoding
        Receives new line coding information from the USB host.
*/
static void CDCDSerialDriver_SetLineCoding()
{
    trace_LOG(trace_INFO, "sLineCoding ");

    USBD_Read(0,
              (void *) &(cdcdSerialDriver.lineCoding),
              sizeof(CDCLineCoding),
              (TransferCallback) CDCDSerialDriver_SetLineCodingCallback,
              0);
}

/*
    Function: CDCDSerialDriver_GetLineCoding
        Sends the current line coding information to the host through Control
        endpoint 0.
*/
static void CDCDSerialDriver_GetLineCoding()
{
    trace_LOG(trace_INFO, "gLineCoding ");

    USBD_Write(0,
               (void *) &(cdcdSerialDriver.lineCoding),
               sizeof(CDCLineCoding),
               0,
               0);
}

/*
    Function: CDCDSerialDriver_SetControlLineState
        Changes the state of the serial driver according to the information
        sent by the host via a SetControlLineState request, and acknowledges
        the request with a zero-length packet.
*/
static void CDCDSerialDriver_SetControlLineState(unsigned char activateCarrier,
                                                 unsigned char isDTEPresent)
{
    trace_LOG(trace_INFO,
              "sControlLineState(%d, %d) ",
              activateCarrier,
              isDTEPresent);

    cdcdSerialDriver.isCarrierActivated = activateCarrier;
    USBD_Write(0, 0, 0, 0, 0);
}

//------------------------------------------------------------------------------
//         Optional RequestReceived() callback re-implementation
//------------------------------------------------------------------------------
#if !defined(NOAUTOCALLBACK)

void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
{
    CDCDSerialDriver_RequestHandler(request);
}

#endif

//------------------------------------------------------------------------------
//         Exported functions
//------------------------------------------------------------------------------
/*
    Function: CDCDSerialDriver_Initialize
        Initializes the USB device CDC serial driver.
*/
void CDCDSerialDriver_Initialize()
{
    trace_LOG(trace_INFO, "CDCDSerialDriver_Initialize\n\r");
    
    // Initialize Abstract Control Model attributes
    CDCLineCoding_Initialize(&(cdcdSerialDriver.lineCoding),
                             115200,
                             CDCLineCoding_ONESTOPBIT,
                             CDCLineCoding_NOPARITY,
                             8);
    cdcdSerialDriver.isCarrierActivated = 0;
    cdcdSerialDriver.serialState = 0;

    // Initialize the standard driver
    USBDDriver_Initialize(&(cdcdSerialDriver.usbdDriver),
                          &cdcdSerialDriverDescriptors,
                          0); // Multiple settings for interfaces not supported

    // Initialize the USB driver
    USBD_Init();
}

/*
    Function: CDCDSerialDriver_RequestHandler
        Handles CDC-specific SETUP requests. Should be called from a
        re-implementation of USBDCallbacks_RequestReceived() method.

    Parameters:
        request - Pointer to a USBGenericRequest instance.
*/
void CDCDSerialDriver_RequestHandler(const USBGenericRequest *request)
{
    trace_LOG(trace_INFO, "NewReq ");

    // Handle the request
    switch (USBGenericRequest_GetRequest(request)) {

        case CDCGenericRequest_SETLINECODING:
            
            CDCDSerialDriver_SetLineCoding();
            break;

        case CDCGenericRequest_GETLINECODING:

            CDCDSerialDriver_GetLineCoding();
            break;

        case CDCGenericRequest_SETCONTROLLINESTATE:

            CDCDSerialDriver_SetControlLineState(
                CDCSetControlLineStateRequest_ActivateCarrier(request),
                CDCSetControlLineStateRequest_IsDtePresent(request));

            break;

        default:

            USBDDriver_RequestHandler(&(cdcdSerialDriver.usbdDriver), request);
            break;
    }
}

/*
    Function: CDCDSerialDriver_Read
        Receives data from the host through the virtual COM port created by
        the CDC device serial driver. This function behaves like <USBD_Read>.

    Parameters:
        data - Pointer to the data buffer to send.
        size - Size of the data buffer in bytes.
        callback - Optional callback function to invoke when the transfer
            finishes.
        argument - Optional argument to the callback function.

    Returns:
        <USBD_STATUS_SUCCESS> if the read operation has been started normally;
        otherwise, the corresponding error code.
*/
unsigned char CDCDSerialDriver_Read(void *data,
                                    unsigned int size,
                                    TransferCallback callback,
                                    void *argument)
{
    return USBD_Read(CDCDSerialDriverDescriptors_DATAOUT,
                     data,
                     size,
                     callback,
                     argument);
}

/*
    Function: CDCDSerialDriver_Write
        Sends a data buffer through the virtual COM port created by the CDC
        device serial driver. This function behaves exactly like <USBD_Write>.

    Parameters:
        data - Pointer to the data buffer to send.
        size - Size of the data buffer in bytes.
        callback - Optional callback function to invoke when the transfer
            finishes.
        argument - Optional argument to the callback function.

    Returns:
        <USBD_STATUS_SUCCESS> if the write operation has been started normally;
        otherwise, the corresponding error code.
*/
unsigned char CDCDSerialDriver_Write(void *data,
                                     unsigned int size,
                                     TransferCallback callback,
                                     void *argument)
{
    return USBD_Write(CDCDSerialDriverDescriptors_DATAIN,
                      data,
                      size,
                      callback,
                      argument);
}

//------------------------------------------------------------------------------
/// Returns the current status of the RS-232 line.
//------------------------------------------------------------------------------
unsigned short CDCDSerialDriver_GetSerialState()
{
    return cdcdSerialDriver.serialState;
}

//------------------------------------------------------------------------------
/// Sets the current serial state of the device to the given value.
/// \param serialState  New device state.
//------------------------------------------------------------------------------
void CDCDSerialDriver_SetSerialState(unsigned short serialState)
{
    ASSERT((serialState & 0xFF80) == 0,
           "CDCDSerialDriver_SetSerialState: Bits D7-D15 are reserved for future use\n\r");

    // If new state is different from previous one, send a notification to the
    // host
    if (cdcdSerialDriver.serialState != serialState) {

        cdcdSerialDriver.serialState = serialState;
        USBD_Write(CDCDSerialDriverDescriptors_NOTIFICATION,
                   &(cdcdSerialDriver.serialState),
                   2,
                   0,
                   0);

        // Reset one-time flags
        cdcdSerialDriver.serialState &= ~(CDCDSerialDriver_STATE_OVERRUN
                                          | CDCDSerialDriver_STATE_PARITY
                                          | CDCDSerialDriver_STATE_FRAMING
                                          | CDCDSerialDriver_STATE_RINGSIGNAL
                                          | CDCDSerialDriver_STATE_BREAK);
    }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美吞精做爰啪啪高潮| 精品国产乱码久久久久久浪潮| av在线不卡免费看| 欧美亚洲国产一卡| 日韩一卡二卡三卡国产欧美| 久久久久久毛片| 一区二区三区四区五区视频在线观看| 亚洲综合久久久| 狠狠色综合播放一区二区| 国产suv一区二区三区88区| 欧美中文字幕亚洲一区二区va在线| 欧美理论片在线| 中文字幕不卡在线播放| 亚洲超碰97人人做人人爱| 国产成人h网站| 欧美老肥妇做.爰bbww| 欧美高清在线视频| 秋霞av亚洲一区二区三| 波多野结衣中文字幕一区| 日韩视频一区二区三区在线播放| 欧美国产激情二区三区| 狠狠色丁香久久婷婷综合丁香| 色综合久久综合网欧美综合网| 日韩欧美国产高清| 天堂久久一区二区三区| 99久久国产免费看| 国产精品三级久久久久三级| 日本午夜精品视频在线观看| 粉嫩一区二区三区在线看| www欧美成人18+| 久久成人麻豆午夜电影| 日韩视频中午一区| 亚洲成av人片在线| 欧美日韩中文字幕一区| 亚洲国产综合91精品麻豆| 不卡在线视频中文字幕| 国产色爱av资源综合区| 黑人精品欧美一区二区蜜桃| 91精品福利视频| 亚洲欧美偷拍三级| 99国产欧美另类久久久精品| 久久久亚洲综合| 紧缚捆绑精品一区二区| 精品91自产拍在线观看一区| 久久国产人妖系列| 久久久久久久久久久久久久久99 | 亚洲国产成人av网| 色国产综合视频| 一区二区国产盗摄色噜噜| 欧美日韩在线免费视频| 奇米在线7777在线精品| 日韩一区二区三区四区| 国产精品资源网| 中文字幕一区二区三中文字幕| 在线中文字幕一区| 青青草97国产精品免费观看无弹窗版| 欧美一级高清大全免费观看| 国产中文字幕一区| 自拍偷自拍亚洲精品播放| 91麻豆精品在线观看| 日本系列欧美系列| 中文字幕一区二区三区视频| 欧美亚洲综合色| 极品美女销魂一区二区三区免费| 国产精品高潮呻吟| 欧美日韩在线播放三区四区| 极品少妇xxxx偷拍精品少妇| 国产精品成人一区二区艾草 | 亚洲人成7777| 欧美一二三区在线| 成人国产精品免费观看视频| 日韩不卡免费视频| 国产欧美精品一区二区三区四区| 欧美日韩一二三| 欧美一区二区在线不卡| 成人免费黄色大片| 蜜桃久久精品一区二区| 亚洲精品国产视频| 国产精品三级av| 久久综合久久鬼色| 日韩亚洲欧美在线观看| 在线中文字幕一区| 色久优优欧美色久优优| 成人激情校园春色| 国产91在线观看| 成人久久视频在线观看| www.色精品| 色噜噜夜夜夜综合网| 欧美日免费三级在线| 欧美二区三区的天堂| 日韩免费看网站| 中文字幕不卡的av| 亚洲一区在线免费观看| 三级欧美韩日大片在线看| 免费高清不卡av| 风间由美一区二区三区在线观看 | 激情综合色综合久久综合| 国产真实精品久久二三区| 国产一区二区网址| 99精品国产91久久久久久| 欧美美女喷水视频| 欧美日韩免费观看一区三区| 91精品国产全国免费观看| 精品国产一区二区亚洲人成毛片 | 亚洲区小说区图片区qvod| 中文字幕一区在线观看视频| 亚洲黄色片在线观看| 日韩国产精品久久久久久亚洲| 麻豆极品一区二区三区| 国产精品911| 国产精品三级久久久久三级| 亚洲一区二区三区四区在线免费观看 | 精品一二三四区| 日韩午夜在线观看| 26uuu亚洲| 一区二区不卡在线播放| 蜜臀av一区二区在线免费观看 | 成人性生交大片免费| 欧美欧美欧美欧美| 亚洲国产精品激情在线观看| 不卡影院免费观看| 日韩视频中午一区| 一区二区三区在线视频观看58| 国产综合一区二区| 欧美一区二区精品在线| 一区二区三区在线观看视频| 韩国女主播成人在线| 正在播放一区二区| 亚洲免费观看高清完整版在线观看熊| 久久99热狠狠色一区二区| 欧美在线色视频| 亚洲视频一区在线观看| 国产在线精品一区二区夜色| 欧美日韩精品高清| 亚洲色图第一区| 99re亚洲国产精品| 日本一区二区三区国色天香 | 欧美经典一区二区| 久久99久久久久| 日韩午夜电影在线观看| 亚洲成人手机在线| 欧美精品精品一区| 亚洲成va人在线观看| 欧美另类变人与禽xxxxx| 婷婷成人激情在线网| 欧美老年两性高潮| 免费观看久久久4p| 久久综合网色—综合色88| 国产剧情一区在线| 亚洲人成人一区二区在线观看| 色综合久久久久综合99| 一区二区三区欧美在线观看| 91小宝寻花一区二区三区| 一区二区三区久久| 91精品国产91久久综合桃花| 麻豆国产一区二区| 国产亚洲欧美色| 不卡电影免费在线播放一区| 国产精品国产三级国产a| 欧美综合久久久| 久久精品国产网站| 国产精品久久二区二区| 在线欧美日韩精品| 精品亚洲国产成人av制服丝袜| 国产精品视频线看| 欧美日韩国产综合视频在线观看| 久久精品国产精品青草| 中文av一区特黄| 欧美群妇大交群中文字幕| 国产一区二区电影| 亚洲在线观看免费| 精品国精品自拍自在线| 99久久99久久综合| 国产在线精品免费| 亚洲福利视频导航| 国产精品久久看| 久久久另类综合| 欧美丰满一区二区免费视频| 成人性生交大片免费看视频在线 | 亚洲一二三区在线观看| 国产午夜亚洲精品理论片色戒| 精品视频在线视频| 99国产精品久| 粉嫩av一区二区三区在线播放 | 久久亚洲春色中文字幕久久久| 在线中文字幕不卡| 99国产精品久久久久久久久久| 久久se精品一区精品二区| 亚洲一区二区三区四区在线| 亚洲国产精品高清| 久久人人超碰精品| 欧美大片国产精品| 88在线观看91蜜桃国自产| 91麻豆高清视频| 99久久99久久久精品齐齐| 成人影视亚洲图片在线| 国产老肥熟一区二区三区| 美国毛片一区二区| 麻豆91在线观看| 精品一区二区三区久久|