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

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

?? usbdrv.c

?? ATmega8實現(xiàn)USB接口(采用USB的CDC類
?? C
?? 第 1 頁 / 共 2 頁
字號:
#include "iarcompat.h"#ifndef __IAR_SYSTEMS_ICC__#   include <avr/io.h>#   include <avr/pgmspace.h>#endif#include "usbdrv.h"#include "oddebug.h"/*General Description:This module implements the C-part of the USB driver. See usbdrv.h for adocumentation of the entire driver.*/#ifndef IAR_SECTION#define IAR_SECTION(arg)#define __no_init#endif/* The macro IAR_SECTION is a hack to allow IAR-cc compatibility. On gcc, it * is defined to nothing. __no_init is required on IAR. *//* ------------------------------------------------------------------------- *//* raw USB registers / interface to assembler code: *//* usbRxBuf MUST be in 1 byte addressable range (because usbInputBuf is only 1 byte) */__no_init uchar usbRxBuf[2][USB_BUFSIZE] __attribute__ ((section (USB_BUFFER_SECTION))) IAR_SECTION(USB_BUFFER_SECTION);/* raw RX buffer: PID, 8 bytes data, 2 bytes CRC */uchar       usbDeviceAddr;      /* assigned during enumeration, defaults to 0 */uchar       usbNewDeviceAddr;   /* device ID which should be set after status phase */uchar       usbConfiguration;   /* currently selected configuration. Administered by driver, but not used */uchar       usbInputBuf;        /* ptr to raw buffer used for receiving */uchar       usbAppBuf;          /* ptr to raw buffer passed to app for processing */volatile schar usbRxLen;        /* = 0; number of bytes in usbAppBuf; 0 means free */uchar       usbCurrentTok;      /* last token received, if more than 1 rx endpoint: MSb=endpoint */uchar       usbRxToken;         /* token for data we received; if more than 1 rx endpoint: MSb=endpoint */uchar       usbMsgLen = 0xff;   /* remaining number of bytes, no msg to send if -1 (see usbMsgPtr) */volatile uchar usbTxLen = USBPID_NAK;   /* number of bytes to transmit with next IN token or handshake token */uchar       usbTxBuf[USB_BUFSIZE];/* data to transmit with next IN, free if usbTxLen contains handshake token */#if USB_CFG_HAVE_INTRIN_ENDPOINTvolatile uchar usbTxLen1 = USBPID_NAK;  /* TX count for endpoint 1 */uchar       usbTxBuf1[USB_BUFSIZE];     /* TX data for endpoint 1 */#if USB_CFG_HAVE_INTRIN_ENDPOINT3volatile uchar usbTxLen3 = USBPID_NAK;  /* TX count for endpoint 1 */uchar       usbTxBuf3[USB_BUFSIZE];     /* TX data for endpoint 1 */#endif#endif/* USB status registers / not shared with asm code */uchar           *usbMsgPtr;     /* data to transmit next -- ROM or RAM address */static uchar    usbMsgFlags;    /* flag values see below */static uchar    usbIsReset;     /* = 0; USB bus is in reset phase */#define USB_FLG_TX_PACKET       (1<<0)/* Leave free 6 bits after TX_PACKET. This way we can increment usbMsgFlags to toggle TX_PACKET */#define USB_FLG_MSGPTR_IS_ROM   (1<<6)#define USB_FLG_USE_DEFAULT_RW  (1<<7)/*optimizing hints:- do not post/pre inc/dec integer values in operations- assign value of PRG_RDB() to register variables and don't use side effects in arg- use narrow scope for variables which should be in X/Y/Z register- assign char sized expressions to variables to force 8 bit arithmetics*//* ------------------------------------------------------------------------- */#if USB_CFG_DESCR_PROPS_STRINGS == 0#if USB_CFG_DESCR_PROPS_STRING_0 == 0#undef USB_CFG_DESCR_PROPS_STRING_0#define USB_CFG_DESCR_PROPS_STRING_0    sizeof(usbDescriptorString0)PROGMEM char usbDescriptorString0[] = { /* language descriptor */    4,          /* sizeof(usbDescriptorString0): length of descriptor in bytes */    3,          /* descriptor type */    0x09, 0x04, /* language index (0x0409 = US-English) */};#endif#if USB_CFG_DESCR_PROPS_STRING_VENDOR == 0 && USB_CFG_VENDOR_NAME_LEN#undef USB_CFG_DESCR_PROPS_STRING_VENDOR#define USB_CFG_DESCR_PROPS_STRING_VENDOR   sizeof(usbDescriptorStringVendor)PROGMEM int  usbDescriptorStringVendor[] = {    USB_STRING_DESCRIPTOR_HEADER(USB_CFG_VENDOR_NAME_LEN),    USB_CFG_VENDOR_NAME};#endif#if USB_CFG_DESCR_PROPS_STRING_DEVICE == 0 && USB_CFG_DEVICE_NAME_LEN#undef USB_CFG_DESCR_PROPS_STRING_DEVICE#define USB_CFG_DESCR_PROPS_STRING_DEVICE   sizeof(usbDescriptorStringDevice)PROGMEM int  usbDescriptorStringDevice[] = {    USB_STRING_DESCRIPTOR_HEADER(USB_CFG_DEVICE_NAME_LEN),    USB_CFG_DEVICE_NAME};#endif#if USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER == 0 && USB_CFG_SERIAL_NUMBER_LEN#undef USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER    sizeof(usbDescriptorStringSerialNumber)PROGMEM int usbDescriptorStringSerialNumber[] = {    USB_STRING_DESCRIPTOR_HEADER(USB_CFG_SERIAL_NUMBER_LEN),    USB_CFG_SERIAL_NUMBER};#endif#endif  /* USB_CFG_DESCR_PROPS_STRINGS == 0 */#if USB_CFG_DESCR_PROPS_DEVICE == 0#undef USB_CFG_DESCR_PROPS_DEVICE#define USB_CFG_DESCR_PROPS_DEVICE  sizeof(usbDescriptorDevice)PROGMEM char usbDescriptorDevice[] = {    /* USB device descriptor */    18,         /* sizeof(usbDescriptorDevice): length of descriptor in bytes */    USBDESCR_DEVICE,        /* descriptor type */    0x01, 0x01,             /* USB version supported */    USB_CFG_DEVICE_CLASS,    USB_CFG_DEVICE_SUBCLASS,    0,                      /* protocol */    8,                      /* max packet size */    USB_CFG_VENDOR_ID,      /* 2 bytes */    USB_CFG_DEVICE_ID,      /* 2 bytes */    USB_CFG_DEVICE_VERSION, /* 2 bytes */    USB_CFG_DESCR_PROPS_STRING_VENDOR != 0 ? 1 : 0,         /* manufacturer string index */    USB_CFG_DESCR_PROPS_STRING_DEVICE != 0 ? 2 : 0,         /* product string index */    USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER != 0 ? 3 : 0,  /* serial number string index */    1,          /* number of configurations */};#endif#if USB_CFG_DESCR_PROPS_HID_REPORT != 0 && USB_CFG_DESCR_PROPS_HID == 0#undef USB_CFG_DESCR_PROPS_HID#define USB_CFG_DESCR_PROPS_HID     9   /* length of HID descriptor in config descriptor below */#endif#if USB_CFG_DESCR_PROPS_CONFIGURATION == 0#undef USB_CFG_DESCR_PROPS_CONFIGURATION#define USB_CFG_DESCR_PROPS_CONFIGURATION   sizeof(usbDescriptorConfiguration)PROGMEM char usbDescriptorConfiguration[] = {    /* USB configuration descriptor */    9,          /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */    USBDESCR_CONFIG,    /* descriptor type */    18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + (USB_CFG_DESCR_PROPS_HID & 0xff), 0,                /* total length of data returned (including inlined descriptors) */    1,          /* number of interfaces in this configuration */    1,          /* index of this configuration */    0,          /* configuration name string index */#if USB_CFG_IS_SELF_POWERED    USBATTR_SELFPOWER,  /* attributes */#else    USBATTR_BUSPOWER,   /* attributes */#endif    USB_CFG_MAX_BUS_POWER/2,            /* max USB current in 2mA units *//* interface descriptor follows inline: */    9,          /* sizeof(usbDescrInterface): length of descriptor in bytes */    USBDESCR_INTERFACE, /* descriptor type */    0,          /* index of this interface */    0,          /* alternate setting for this interface */    USB_CFG_HAVE_INTRIN_ENDPOINT,   /* endpoints excl 0: number of endpoint descriptors to follow */    USB_CFG_INTERFACE_CLASS,    USB_CFG_INTERFACE_SUBCLASS,    USB_CFG_INTERFACE_PROTOCOL,    0,          /* string index for interface */#if (USB_CFG_DESCR_PROPS_HID & 0xff)    /* HID descriptor */    9,          /* sizeof(usbDescrHID): length of descriptor in bytes */    USBDESCR_HID,   /* descriptor type: HID */    0x01, 0x01, /* BCD representation of HID version */    0x00,       /* target country code */    0x01,       /* number of HID Report (or other HID class) Descriptor infos to follow */    0x22,       /* descriptor type: report */    USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH, 0,  /* total length of report descriptor */#endif#if USB_CFG_HAVE_INTRIN_ENDPOINT    /* endpoint descriptor for endpoint 1 */    7,          /* sizeof(usbDescrEndpoint) */    USBDESCR_ENDPOINT,  /* descriptor type = endpoint */    0x81,       /* IN endpoint number 1 */    0x03,       /* attrib: Interrupt endpoint */    8, 0,       /* maximum packet size */    USB_CFG_INTR_POLL_INTERVAL, /* in ms */#endif};#endif/* We don't use prog_int or prog_int16_t for compatibility with various libc * versions. Here's an other compatibility hack: */#ifndef PRG_RDB#define PRG_RDB(addr)   pgm_read_byte(addr)#endiftypedef union{    unsigned    word;    uchar       *ptr;    uchar       bytes[2];}converter_t;/* We use this union to do type conversions. This is better optimized than * type casts in gcc 3.4.3 and much better than using bit shifts to build * ints from chars. Byte ordering is not a problem on an 8 bit platform. *//* ------------------------------------------------------------------------- */#if USB_CFG_HAVE_INTRIN_ENDPOINTuchar   usbTxPacketCnt1;void    usbSetInterrupt(uchar *data, uchar len){uchar       *p, i;#if USB_CFG_IMPLEMENT_HALT    if(usbTxLen1 == USBPID_STALL)        return;#endif#if 0   /* No runtime checks! Caller is responsible for valid data! */    if(len > 8) /* interrupt transfers are limited to 8 bytes */        len = 8;#endif    i = USBPID_DATA1;    if(usbTxPacketCnt1 & 1)        i = USBPID_DATA0;    if(usbTxLen1 & 0x10){       /* packet buffer was empty */        usbTxPacketCnt1++;    }else{        usbTxLen1 = USBPID_NAK; /* avoid sending incomplete interrupt data */    }    p = usbTxBuf1;    *p++ = i;    for(i=len;i--;)        *p++ = *data++;    usbCrc16Append(&usbTxBuf1[1], len);    usbTxLen1 = len + 4;    /* len must be given including sync byte */    DBG2(0x21, usbTxBuf1, len + 3);}#endif#if USB_CFG_HAVE_INTRIN_ENDPOINT3uchar   usbTxPacketCnt3;void    usbSetInterrupt3(uchar *data, uchar len){uchar       *p, i;    i = USBPID_DATA1;    if(usbTxPacketCnt3 & 1)        i = USBPID_DATA0;    if(usbTxLen3 & 0x10){       /* packet buffer was empty */        usbTxPacketCnt3++;    }else{        usbTxLen3 = USBPID_NAK; /* avoid sending incomplete interrupt data */    }    p = usbTxBuf3;    *p++ = i;    for(i=len;i--;)        *p++ = *data++;    usbCrc16Append(&usbTxBuf3[1], len);    usbTxLen3 = len + 4;    /* len must be given including sync byte */    DBG2(0x23, usbTxBuf3, len + 3);}#endifstatic uchar    usbRead(uchar *data, uchar len){#if USB_CFG_IMPLEMENT_FN_READ    if(usbMsgFlags & USB_FLG_USE_DEFAULT_RW){#endif        uchar i = len, *r = usbMsgPtr;        if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){    /* ROM data */            while(i--){                uchar c = PRG_RDB(r);    /* assign to char size variable to enforce byte ops */                *data++ = c;                r++;            }        }else{                  /* RAM data */            while(i--)                *data++ = *r++;        }        usbMsgPtr = r;        return len;#if USB_CFG_IMPLEMENT_FN_READ    }else{        if(len != 0)    /* don't bother app with 0 sized reads */            return usbFunctionRead(data, len);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
高清久久久久久| 色婷婷av一区| 一区二区三区欧美激情| 欧美sm美女调教| 亚洲精品一区在线观看| 色综合久久精品| 国产精品影视网| 日本欧美大码aⅴ在线播放| 国产精品初高中害羞小美女文| 欧美日韩国产影片| 91亚洲国产成人精品一区二三| 精品在线亚洲视频| 午夜成人免费电影| 亚洲综合视频网| 亚洲欧洲日产国码二区| 337p日本欧洲亚洲大胆色噜噜| 欧美精品123区| 欧洲亚洲精品在线| www.欧美色图| 成人教育av在线| 成人综合激情网| 国产高清不卡一区二区| 久久国产生活片100| 日韩国产在线一| 无码av免费一区二区三区试看| 亚洲影院理伦片| 亚洲精品国产a久久久久久| 日韩久久一区二区| 国产精品色眯眯| 国产精品午夜免费| 国产精品网站在线观看| 欧美国产一区二区| 国产精品免费免费| 国产精品人妖ts系列视频| 中文字幕不卡在线观看| 国产农村妇女毛片精品久久麻豆 | 欧美精品99久久久**| 色诱亚洲精品久久久久久| 91免费国产在线| 一本大道av伊人久久综合| 91看片淫黄大片一级在线观看| 成人精品鲁一区一区二区| 高清成人在线观看| 不卡的电影网站| 97久久超碰国产精品| aaa欧美大片| 91在线一区二区| 日本高清不卡视频| 欧美日韩亚洲综合一区| 538在线一区二区精品国产| 91精品国产黑色紧身裤美女| 欧美日韩三级一区二区| 在线不卡免费欧美| 日韩精品综合一本久道在线视频| 欧美大尺度电影在线| 久久精品视频网| 18欧美乱大交hd1984| 一区二区三区四区不卡视频| 午夜视频在线观看一区| 蜜臀av性久久久久av蜜臀妖精 | 日本精品一级二级| 欧美精品三级在线观看| 91精品国产综合久久精品图片| 日韩一区国产二区欧美三区| 精品99999| 国产精品久久久久9999吃药| 亚洲午夜免费视频| 麻豆成人av在线| 成人国产精品免费网站| 日本高清不卡aⅴ免费网站| 6080午夜不卡| 亚洲国产精品av| 日韩理论片中文av| 日本欧美一区二区三区乱码| 国产suv一区二区三区88区| 91久久奴性调教| 日韩精品一区二区在线观看| 国产精品嫩草久久久久| 午夜激情久久久| 国产成人精品影视| 欧美午夜一区二区| 2022国产精品视频| 亚洲美女电影在线| 久久精品国产精品青草| 色综合婷婷久久| 日韩午夜精品视频| 亚洲精品日日夜夜| 国产一二精品视频| 欧美日韩免费视频| 中文幕一区二区三区久久蜜桃| 天天色综合天天| av高清久久久| 2023国产精品自拍| 丝袜美腿高跟呻吟高潮一区| jlzzjlzz欧美大全| 亚洲精品在线免费观看视频| 亚洲综合av网| 成人免费高清在线| 日韩女同互慰一区二区| 亚洲男帅同性gay1069| 国产精品综合av一区二区国产馆| 欧美亚洲日本国产| 中文字幕一区二区三区在线不卡| 蜜乳av一区二区| 日本丰满少妇一区二区三区| 国产欧美日韩在线| 久久国产福利国产秒拍| 欧洲人成人精品| 国产欧美日本一区视频| 欧美aaa在线| 欧美猛男gaygay网站| 亚洲同性同志一二三专区| 国产在线精品一区二区| 欧美一区二区成人| 亚洲国产乱码最新视频| av电影在线观看一区| 久久―日本道色综合久久| 日韩成人免费电影| 欧美日韩日日夜夜| 亚洲一区二区在线观看视频| 一本一道久久a久久精品综合蜜臀| 久久这里只有精品视频网| 男女男精品网站| 欧美日韩成人综合| 午夜精品久久久久久久久| 91成人在线精品| 一区二区三区在线高清| 99视频在线精品| 日韩一区日韩二区| 99久久国产免费看| 综合中文字幕亚洲| 日韩天堂在线观看| 日韩电影网1区2区| 8v天堂国产在线一区二区| 五月天中文字幕一区二区| 欧美日韩精品系列| 婷婷中文字幕一区三区| 欧美在线看片a免费观看| 亚洲综合免费观看高清完整版在线 | 亚洲欧美日韩中文播放| 不卡免费追剧大全电视剧网站| 中文字幕精品一区二区三区精品| 国产成人精品免费视频网站| 国产亚洲成年网址在线观看| 国产乱码一区二区三区| 国产色产综合色产在线视频| 国产成人av资源| 国产精品女上位| 一本大道av伊人久久综合| 亚洲自拍与偷拍| 91精品黄色片免费大全| 久久精品国产77777蜜臀| 精品成人私密视频| 国产凹凸在线观看一区二区| 国产精品区一区二区三| 色偷偷成人一区二区三区91| 亚洲一区在线播放| 欧美一区二区视频在线观看2022 | 日韩成人精品在线| 精品国产髙清在线看国产毛片| 精品亚洲欧美一区| 中文字幕乱码亚洲精品一区| 99久久综合狠狠综合久久| 亚洲一区日韩精品中文字幕| 91精品国产欧美一区二区成人| 精品一区二区三区免费观看| 国产精品美日韩| 欧美视频一区二| 久久精品噜噜噜成人av农村| 久久精品一区二区| 色94色欧美sute亚洲线路一久| 午夜欧美视频在线观看| 精品对白一区国产伦| av亚洲精华国产精华精华| 亚洲成人免费视| 久久一日本道色综合| 在线亚洲免费视频| 美女脱光内衣内裤视频久久影院| 亚洲午夜一二三区视频| 欧美成人一区二区三区| 色婷婷久久久亚洲一区二区三区| 日本不卡1234视频| 国产精品热久久久久夜色精品三区 | 亚洲国产中文字幕在线视频综合 | av在线不卡免费看| 日本欧美一区二区三区乱码| 国产精品久久久久久久久久久免费看| 欧美日韩一区中文字幕| 国产精品一区2区| 亚洲国产视频a| 中文一区在线播放| 日韩午夜小视频| 色婷婷久久久久swag精品| 国产一区二区在线免费观看| 一区二区三区在线高清| 国产亚洲一区二区三区四区| 在线观看中文字幕不卡| 成人福利电影精品一区二区在线观看| 日韩不卡手机在线v区| 亚洲天堂2014|