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

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

?? usb.c

?? bdm源代碼. coldfire處理器用
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
    Turbo BDM Light ColdFire - USB stack
    Copyright (C) 2005  Daniel Malik

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include "hidef.h"
#include "MC68HC908JB16.h"
#include "commands.h"
#include "usb.h"
#include "cmd_processing.h"
#include "main.h"

/* Data transfer format: two possibilities exist 

1. Bulk transfer over EP2 (non standard for low speed devices!) - read block commands do not work properly for bulk transfers at the moment as command_size is wrong in that case

Data format:  1 byte: size (of cmd+data)
              1 byte: cmd
              size-1 bytes: data
              
Returns at least one packet with status, but possibly more data depending on command executed.
When the data is returned the command has finished.
Start of transfer of another message into EP2 will discard any data ready to be transmitted back out of EP2

Performance: ~20kB/s, roundtrip (8B IN & 8B OUT) ~ 4ms

2. Control transfer over EP0 (standard approach and the only standard option for JB8/16)

Data format:  

  - Setup frame: bmRequestType = 0x41 if data is to be transfered to the device  
  							 bmRequestType = 0xC1 if data is to be transfered out of the device 
								 bRequest = cmd
								 wValue.lo = data0
								 wValue.hi = data1
								 wIndex.lo = data2
								 wIndex.hi = data3
								 wLength.hi = 0
								 wLength.lo = # of bytes in data stage
								 
  cmd, data0-3 is always transferred from host to device. 
  If the command parameters fit into 4 bytes, bmRequestType = 0xC1 can be used to read results of the command being transferred
  If more than 4 bytes of parameters are needed, bmRequestType = 0x41 is used and data5,... is transferred in data stage
  New setup frame will discard data ready to be transmitted out of the device stored at the beginning of the buffer

Performance: ~6.7kB/s, short command (5B IN, no data out) ~3ms, ave command (5B IN, 8B OUT) ~4ms, longer cmd (5B IN, 16B OUT) ~5ms

*/

/* global and static variables, buffers, etc. */

#pragma DATA_SEG Z_RAM
/* near variables (short addressing mode) */
static near unsigned char *usb_dptr;       /* pointer to first empty location in buffer (Rx) or to the first char to transmit (Tx) */
static near unsigned char usb_ep0_dcntT;   /* data count to transmit */
static near unsigned char usb_ep0_dcntR;   /* data count to receive */
static near unsigned char usb_ep2_dcntT;   /* data count to transmit */
static near unsigned char usb_ep2_dcntR;   /* data count to receive */
static near unsigned char usb_ep0_zeroterm=0;  /* when non-zero it tells the EP0 Tx routine to terminate transfers by zero-length packet because the host has requested more data than available */

#pragma DATA_SEG DEFAULT
unsigned char command_buffer[COMMAND_BUFFER_SIZE]; /* buffer for Rx and Tx of commands & results */
                                                   /* data is always received starting at command_buffer+1 and transmitted starting at command_buffer+0 */
                                                   /* this is to make sure that status of the last command is preserved when receving the next command from the host */
unsigned char command_size;                        /* this variable holds the number of bytes of results/parameters for the current command (i.e. excluding the command itself or the command status) */


static unsigned char USB_State = US_ATTACHED;

/* USB descriptors */

const device_descriptor DeviceDesc = {
	sizeof(device_descriptor),  /* size */
	DT_DEVICE,			            /* Descriptor Type (=1) */
	{0x10, 0x01},		            /* USB Spec Release Number in BCD = 1.10 */
	0xff,                       /* Device Class Code (vendor specific) */
	0xff,                       /* Device Subclass Code	(vendor specific) */
	0xff,                       /* Device Protocol Code (vendor specific) */
	8,					                /* Maximum Packet Size for EP0 */
	{0x25, 0x04},		            /* Vendor ID - it is a Freescale micro, so lets use Freescale ID :-) */
	{0x01, 0x10},		            /* Product ID */
	{0x01, 0x00},		            /* Device Release Number in BCD */
	1,					                /* Index of String Desc for Manufacturer */
	2,					                /* Index of String Desc for Product */
	2,					                /* Index of String Desc for SerNo */
	1					                  /* Number of possible Configurations */
};

/* Configuration: Control EP0, Bulk IN EP2 & Bulk OUT EP2 */
/* Bulk transfers are not allowed for low speed devices by the spec, but seem to work and much faster! */
/* There will be several transactions per frame and the throughput is very high */
/* There are 2 options: either to use Bulk EP2 or Contol EP0 (in case Bulk on EP2 does not work on the specific machine) */
const struct {
  configuration_descriptor ConfigDesc;  
  interface_descriptor InterfaceDesc0;
  endpoint_descriptor Endpoint2INDesc;
  endpoint_descriptor Endpoint2OUTDesc;
} config_data = {
  { /* configuration descriptor */
  	sizeof(configuration_descriptor),     /* size */
  	DT_CONFIGURATION,	                    /* Descriptor Type (=2) */
  	{sizeof(config_data),0x00},           /* Total Length of Data for this Configuration */
  	1,					                          /* Number of Interfaces supported by this Configuration */
  	1,					                          /* Designator Value for this Configuration */
  	2,					                          /* Index of String Desc for this Configuration */
  	0x80,				                          /* Bus powered, no wakeup */
  	150				                            /* Max. Power Consumption in this Configuration (in 2mA steps) = 250mA current for the target if needed... */
  },
  { /* interface 0 descriptor (EP0) */
  	sizeof(interface_descriptor), /* size */
  	DT_INTERFACE,		              /* Descriptor Type (=4) */
  	0,					                  /* Number of this Interface (0..) */
  	0,					                  /* Alternative for this Interface (if any) */
    2,					                  /* No of EPs used by this IF (excl. EP0) */
  	0xff,				                  /* IF Class Code */
  	0xff,               				  /* Interface Subclass Code */
  	0xff,				                  /* IF Protocol Code */
  	2					                    /* Index of String Desc for this Interface */
	},
	{ /* EP2 IN descriptor */
  	sizeof(endpoint_descriptor),  /* size */
  	DT_ENDPOINT,		              /* Descriptor Type (=5) */
  	0x82,				                  /* Endpoint Address (EP2) */
  	0x02,                 				/* Bulk IN endpoint */
  	{0x08, 0x00},		              /* Max. Endpoint Packet Size */
  	1	  				                  /* Polling Interval in frames/microframes */
	},
	{ /* EP2 OUT descriptor */
  	sizeof(endpoint_descriptor),  /* size */
  	DT_ENDPOINT,		              /* Descriptor Type (=5) */
  	0x02,				                  /* Endpoint Address (EP2) */
  	0x02,                 				/* Bulk OUT endpoint */
  	{0x08, 0x00},		              /* Max. Endpoint Packet Size */
  	1	  				                  /* Polling Interval in frames/microframes */
	}
};

const char StringDesc0[]={0x04,DT_STRING,0x08,0x04,0x00}; /* Lang ID: 0x08 0x04 = 0x0408 = English (UK) */
const char StringDesc1[]="Freescale";									    /* we are using Freescale VID so it is only fair to say that this is a Freescale product :-) */
const char StringDesc2[]="Turbo BDM Light ColdFire v0.4"; /* product version */
const char * far const StringDescTable[]={StringDesc0,StringDesc1,StringDesc2}; /* pointers to the descriptors */

/* Functions */

/* copies data from flash to the USB buffer */
void copy(unsigned char count, unsigned char * src, unsigned char * dest) {
  while(count--) *(dest++) = *(src++);  /* copy data while count lasts... */
}

/* Copies string from flash to the buffer */
unsigned char copystring(unsigned char index, unsigned char * dest) {
  unsigned char cnt=0;
  const unsigned char * src;
  if (index) {
    /* unicode copy */
    if (index<(sizeof(StringDescTable)/2)) {  /* if the string exists, copy it */
      unsigned char * dest_orig=dest;
      dest+=2;
      src = StringDescTable[index];
      while (*src) {
        *(dest++) = *(src++); /* copy byte */
        *(dest++) = 0;        /* unicode */
        cnt+=2;               /* increment count */
      }
      cnt+=2;                 /* account for the header */
      *(dest_orig++) = cnt;   /* create the header */
      *(dest_orig) = DT_STRING;
    }
  } else {
    /* plain copy (string 0), it has the header already */
    src = StringDescTable[0];
    while (*src) {
      *(dest++) = *(src++); /* copy byte */
      cnt++;                /* inrement count */
    }
  }
  return(cnt);
}

/* EP0 Tx */
void USB_ep0_tx(void) {
  UCR0_TX0E=0;      /* disable EP0 transmitter */
  UIR2_TXD0FR = 1;  /* clear the interrupt flag to make sure the packet transmits */
  if (usb_ep0_dcntT!=0xff) {
    /* transmit data from the buffer */
    UE0D0 = *(usb_dptr+0); /* copy all 8 bytes, packet might be shorter than 8 bytes */
    UE0D1 = *(usb_dptr+1);
    UE0D2 = *(usb_dptr+2);
    UE0D3 = *(usb_dptr+3);
    UE0D4 = *(usb_dptr+4);
    UE0D5 = *(usb_dptr+5);
    UE0D6 = *(usb_dptr+6);
    UE0D7 = *(usb_dptr+7);
    usb_dptr+=8;
    if ((usb_ep0_dcntT>8)||((usb_ep0_dcntT==8)&&(usb_ep0_zeroterm))) {
      UCR0 = ((UCR0^UCR0_T0SEQ_MASK)&UCR0_T0SEQ_MASK) | UCR0_TX0E_MASK | UCR0_RX0E_MASK + 8; /* enable transmission on EP0, toggle DATA0/1, length 8 (more data in buffer) */
      usb_ep0_dcntT-=8;
    } else {
      UCR0 = ((UCR0^UCR0_T0SEQ_MASK)&UCR0_T0SEQ_MASK) | UCR0_TX0E_MASK | UCR0_RX0E_MASK + usb_ep0_dcntT; /* enable transmission on EP0, toggle DATA0/1, length according to count */
      usb_ep0_dcntT = 0xff; /* no more transmission the next time */
      usb_ep0_zeroterm=0;   /* just finished transmission, switch zero-length termination off */      
    }
  } else {
    /* there is no data to transmit, but the interrupt occured anyway - this must be a special case or end of transmit condition */
    if ((USR0_SETUP)&&(((*(setup_packet*)&UE0D0).bmRequestType&0x60)==0)) {
      /* the special case is a Setup frame of standard request which was received previously, now detemine what to do */
      switch ((*(setup_packet*)&UE0D0).bRequest) {
        case SET_ADDRESS:
          UADDR = UADDR_USBEN_MASK | (*(setup_packet*)&UE0D0).wValue.lo;  /* set the new address (confirmation of reception was just transmitted) */
          if ((*(setup_packet*)&UE0D0).wValue.lo) USB_State = US_ADDRESSED; else USB_State = US_DEFAULT; 
        case CLEAR_FEATURE:
        case SET_CONFIGURATION:
        case GET_CONFIGURATION:
          break;
      }
    }
  }
}

/* EP2 Tx */
void USB_ep2_tx(void) {
  UCR2_TX2E=0;      /* disable EP2 transmitter */
  UIR2_TXD2FR = 1;  /* clear the interrupt flag to make sure the packet transmits */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产jizzjizz一区二区| 亚洲一区二区不卡免费| 成人av免费在线播放| 国产亚洲一区二区三区四区| 国产精品1区二区.| 国产精品成人免费在线| 色综合久久综合| 亚洲午夜久久久久久久久电影院| 欧美在线999| 美女高潮久久久| 欧美激情中文字幕| 午夜激情一区二区三区| 亚洲精品视频在线看| 亚洲免费资源在线播放| 一区二区在线免费观看| 免费日本视频一区| av不卡免费在线观看| 麻豆国产精品777777在线| 日本一二三四高清不卡| 久久99国内精品| 91免费精品国自产拍在线不卡| 欧美在线free| 亚洲一二三区视频在线观看| 欧美日本视频在线| 国产精品美女视频| 亚洲激情欧美激情| 国产欧美一区二区精品性色| 欧美大片在线观看一区| 精品1区2区在线观看| 天天综合天天综合色| 91在线视频18| 国产欧美日韩三区| 日韩成人一区二区三区在线观看| 久久超碰97中文字幕| 欧美猛男gaygay网站| 亚洲欧美色图小说| 日本亚洲视频在线| 成人免费看视频| 国产精品久久久久久久岛一牛影视| 亚洲成人免费av| 成人黄色免费短视频| 欧美日韩精品是欧美日韩精品| 国产女主播视频一区二区| 亚洲一区二区三区四区的| 欧美日韩精品一区二区三区| 国产亚洲短视频| 视频一区视频二区中文| 成人福利视频在线| 久久久久久综合| 国产成人免费网站| 制服视频三区第一页精品| 日韩成人精品视频| 97久久精品人人爽人人爽蜜臀| 自拍偷拍欧美激情| 精品国产免费人成在线观看| 日韩国产欧美在线观看| 欧美日韩一区二区三区四区五区 | 亚洲欧美一区二区三区久本道91| 成人晚上爱看视频| 欧美撒尿777hd撒尿| 日本欧美肥老太交大片| 亚洲在线观看免费| 亚洲欧洲韩国日本视频| 久久夜色精品国产噜噜av| 欧美日韩大陆在线| 欧美无砖专区一中文字| 97久久超碰国产精品| 成人天堂资源www在线| 国产在线不卡视频| 黄色精品一二区| 极品少妇一区二区三区精品视频| 日韩电影免费一区| 免费看日韩精品| 美女视频黄久久| 另类的小说在线视频另类成人小视频在线 | 日本一区二区三区在线观看| 日韩免费观看高清完整版在线观看| 91精品国产综合久久精品性色| 欧美剧情电影在线观看完整版免费励志电影| 91老师国产黑色丝袜在线| av网站一区二区三区| 成人av集中营| 91农村精品一区二区在线| 色激情天天射综合网| 欧美日韩一级片在线观看| 欧美日韩另类国产亚洲欧美一级| 欧美麻豆精品久久久久久| 91精品国产欧美一区二区成人| 日韩欧美国产三级电影视频| 日韩精品在线网站| 国产亚洲欧美中文| **网站欧美大片在线观看| 亚洲精品视频免费看| 午夜精品一区二区三区免费视频| 日韩综合在线视频| 极品少妇xxxx偷拍精品少妇| 国产99精品在线观看| 色视频欧美一区二区三区| 欧美视频一区二区| 精品国产污污免费网站入口 | 三级欧美韩日大片在线看| 日韩成人一级片| 国产福利精品一区二区| 91一区二区在线| 欧美人牲a欧美精品| 久久久一区二区三区捆绑**| 亚洲精品乱码久久久久久久久| 一区二区高清视频在线观看| 毛片不卡一区二区| 99久久精品国产观看| 欧美日韩国产欧美日美国产精品| 精品少妇一区二区三区视频免付费 | 国产aⅴ综合色| 色综合久久久久综合体| 日韩丝袜美女视频| 17c精品麻豆一区二区免费| 婷婷久久综合九色综合伊人色| 国产精选一区二区三区| 欧美中文字幕一二三区视频| 久久综合久久鬼色| 亚洲尤物在线视频观看| 国内精品免费在线观看| 欧美日韩在线电影| 中日韩免费视频中文字幕| 日韩电影免费在线看| 91在线小视频| 国产亚洲女人久久久久毛片| 午夜av一区二区| 国产白丝网站精品污在线入口| 欧美午夜精品免费| 成人欧美一区二区三区黑人麻豆 | 日本女人一区二区三区| 99视频一区二区| 久久久久久久久久久电影| 亚洲成人动漫在线观看| 不卡视频一二三四| 欧美一级免费观看| 一区二区不卡在线播放 | 91麻豆精品在线观看| 久久久久久久综合日本| 五月天婷婷综合| 91免费观看视频| 国产欧美精品一区| 精彩视频一区二区三区| 91精品蜜臀在线一区尤物| 亚洲精品国产a久久久久久 | 色综合久久久久综合体| 欧美经典一区二区三区| 久久 天天综合| 日韩午夜在线影院| 日本va欧美va瓶| 欧美男人的天堂一二区| 亚洲青青青在线视频| 成人爽a毛片一区二区免费| 久久影视一区二区| 久久丁香综合五月国产三级网站| 欧美一区二区三区四区久久| 亚洲超碰精品一区二区| 欧美影院一区二区| 亚洲一区二区三区视频在线 | 欧美精品日韩一区| 一个色妞综合视频在线观看| 91免费小视频| 亚洲精品国产无天堂网2021| 色天天综合色天天久久| 亚洲免费资源在线播放| 91国产免费观看| 性欧美疯狂xxxxbbbb| 欧美日本一区二区三区| 日韩经典一区二区| 91麻豆精品国产自产在线观看一区| 午夜电影一区二区三区| 日韩一级完整毛片| 看片的网站亚洲| 久久久噜噜噜久久中文字幕色伊伊 | 欧美色电影在线| 水野朝阳av一区二区三区| 欧美老年两性高潮| 美女网站色91| 国产日韩亚洲欧美综合| 91免费版在线| 日本少妇一区二区| 久久久精品一品道一区| 成人激情黄色小说| 亚洲精选视频免费看| 91精品午夜视频| 国产一区在线观看麻豆| 中文字幕一区二区三区四区| 欧美在线观看一区| 精品一区二区三区在线播放| 国产日韩精品一区二区三区| 91在线免费播放| 亚洲中国最大av网站| 日韩欧美在线123| 成人精品一区二区三区四区| 亚洲第一久久影院| 精品国产三级电影在线观看| 99视频热这里只有精品免费| 日韩成人免费看| 最新日韩在线视频|