⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chap_9.lst

📁 usbhost 开发码
💻 LST
📖 第 1 页 / 共 2 页
字号:
 217   2      		D12_WriteEndpoint(1,EP0_PACKET_SIZE,ControlData.pData);
 218   2      		ControlData.wCount +=EP0_PACKET_SIZE;
 219   2      		DISABLE;
 220   2      		bEPPflags.bits.control_state = USB_TRANSMIT;
 221   2      		ENABLE;
 222   2      	}
 223   1      	else{
 224   2      		D12_WriteEndpoint(1,ControlData.wLength,pRomData);
 225   2      		ControlData.wCount += ControlData.wLength;
 226   2      		DISABLE;
 227   2      		bEPPflags.bits.control_state = USB_IDLE;
 228   2      		ENABLE;
 229   2      	}
 230   1      }
 231          ///////////////////////////****************///////////////////////////////////////////////
 232          
 233          void get_status(void)
 234          {
 235   1      	unsigned char endp, txdat[2];
 236   1      	unsigned char bRecipient = ControlData.DeviceRequest.bmRequestType & USB_RECIPIENT;
 237   1      	unsigned char c;
 238   1      	dispinfo(2,"get status    ");
 239   1      	disphex(setupcounter++);
 240   1      	loadmsg("get state\r\n",20);
 241   1      	if (bRecipient == USB_RECIPIENT_DEVICE) {
C51 COMPILER V6.12  CHAP_9                                                                 07/30/2003 21:27:45 PAGE 5   

 242   2      		if(bEPPflags.bits.remote_wakeup == 1)
 243   2      			txdat[0] = 3;
 244   2      		else
 245   2      			txdat[0] = 1;
 246   2      		txdat[1]=0;
 247   2      		single_transmit(txdat, 2);
 248   2      	} else if (bRecipient == USB_RECIPIENT_INTERFACE) {
 249   2      		txdat[0]=0;
 250   2      		txdat[1]=0;
 251   2      		single_transmit(txdat, 2);
 252   2      	} else if (bRecipient == USB_RECIPIENT_ENDPOINT) {
 253   2      		endp = (unsigned char)(ControlData.DeviceRequest.wIndex & MAX_ENDPOINTS);
 254   2      		if (ControlData.DeviceRequest.wIndex & (unsigned char)USB_ENDPOINT_DIRECTION_MASK)
 255   2      			c = D12_SelectEndpoint(endp*2 + 1);	/* Control-in */
 256   2      		else
 257   2      			c = D12_SelectEndpoint(endp*2);	/* Control-out */
 258   2      		if(c & D12_STALL)
 259   2      			txdat[0] = 1;
 260   2      		else
 261   2      			txdat[0] = 0;
 262   2      		txdat[1] = 0;
 263   2      		single_transmit(txdat, 2);
 264   2      	} else
 265   1      		stall_ep0();
 266   1      }
 267          
 268          void clear_feature(void)
 269          {
 270   1      	unsigned char endp;
 271   1      	unsigned char bRecipient = ControlData.DeviceRequest.bmRequestType & USB_RECIPIENT;
 272   1      	dispinfo(2,"clearfeature  ");
 273   1      	disphex(setupcounter++);
 274   1      	loadmsg("clearfeature\r\n",20);
 275   1      	if (bRecipient == USB_RECIPIENT_DEVICE
 276   1      		&& ControlData.DeviceRequest.wValue == USB_FEATURE_REMOTE_WAKEUP) {
 277   2      		DISABLE;
 278   2      		bEPPflags.bits.remote_wakeup = 0;
 279   2      		ENABLE;
 280   2      		single_transmit(0, 0);
 281   2      	}
 282   1      	else if (bRecipient == USB_RECIPIENT_ENDPOINT
 283   1      		&& ControlData.DeviceRequest.wValue == USB_FEATURE_ENDPOINT_STALL) {
 284   2      		endp = (unsigned char)(ControlData.DeviceRequest.wIndex & MAX_ENDPOINTS);
 285   2      		if (ControlData.DeviceRequest.wIndex & (unsigned char)USB_ENDPOINT_DIRECTION_MASK)
 286   2      			/* clear TX stall for IN on EPn. */
 287   2      			D12_SetEndpointStatus(endp*2 + 1, 0);
 288   2      		else
 289   2      			/* clear RX stall for OUT on EPn. */
 290   2      			D12_SetEndpointStatus(endp*2, 0);
 291   2      		single_transmit(0, 0);
 292   2      	} else
 293   1      		stall_ep0();
 294   1      }
 295          
 296          void set_feature(void)
 297          {
 298   1      	unsigned char endp;
 299   1      	unsigned char bRecipient = ControlData.DeviceRequest.bmRequestType & USB_RECIPIENT;
 300   1      	dispinfo(2,"set feature   ");
 301   1      	disphex(setupcounter++);
 302   1      	loadmsg("set feature\r\n",20);
 303   1      	if (bRecipient == USB_RECIPIENT_DEVICE
C51 COMPILER V6.12  CHAP_9                                                                 07/30/2003 21:27:45 PAGE 6   

 304   1      		&& ControlData.DeviceRequest.wValue == USB_FEATURE_REMOTE_WAKEUP) {
 305   2      		DISABLE;
 306   2      		bEPPflags.bits.remote_wakeup = 1;
 307   2      		ENABLE;
 308   2      		single_transmit(0, 0);
 309   2      	}
 310   1      	else if (bRecipient == USB_RECIPIENT_ENDPOINT
 311   1      		&& ControlData.DeviceRequest.wValue == USB_FEATURE_ENDPOINT_STALL) {
 312   2      		endp = (unsigned char)(ControlData.DeviceRequest.wIndex & MAX_ENDPOINTS);
 313   2      		if (ControlData.DeviceRequest.wIndex & (unsigned char)USB_ENDPOINT_DIRECTION_MASK)
 314   2      			/* clear TX stall for IN on EPn. */
 315   2      			D12_SetEndpointStatus(endp*2 + 1, 1);
 316   2      		else
 317   2      			/* clear RX stall for OUT on EPn. */
 318   2      			D12_SetEndpointStatus(endp*2, 1);
 319   2      		single_transmit(0, 0);
 320   2      	} else
 321   1      		stall_ep0();
 322   1      }
 323          
 324          void set_address(void)
 325          {
 326   1      	dispinfo(2,"set address   ");
 327   1      	disphex(setupcounter++);
 328   1      	loadmsg("set address\r\n",20);
 329   1      	D12_SetAddressEnable((unsigned char)(ControlData.DeviceRequest.wValue &
 330   1      		DEVICE_ADDRESS_MASK), 1);
 331   1      	single_transmit(0, 0);
 332   1      }
 333          
 334          void get_descriptor(void)
 335          {
 336   1      	uchar chh,chl;
 337   1      	unsigned char bDescriptor = MSB(ControlData.DeviceRequest.wValue);
 338   1      	dispinfo(1,"des:");
 339   1      	disphex(setupcounter++);
 340   1      	dispinfo(0," X:");
 341   1      	htoc(bDescriptor,&chh,&chl);
 342   1      	loadmsg("get descriptor Index:",30);
 343   1      	loadmsg(&chh,1);
 344   1      	loadmsg(&chl,1);
 345   1      	loadmsg(" Long:",20);
 346   1      	writedispdata(chh);
 347   1      	writedispdata(chl);
 348   1      	htoc(ControlData.DeviceRequest.wLength,&chh,&chl);
 349   1      	loadmsg(&chh,1);
 350   1      	loadmsg(&chl,1);
 351   1      	loadmsg("\r\n",2);
 352   1      	dispinfo(0," L:");
 353   1      	writedispdata(chh);
 354   1      	writedispdata(chl);
 355   1      	if (bDescriptor == USB_DEVICE_DESCRIPTOR_TYPE) {
 356   2      		code_transmit((unsigned char code *)&DeviceDescr, sizeof(USB_DEVICE_DESCRIPTOR));
 357   2      	} else if (bDescriptor == USB_CONFIGURATION_DESCRIPTOR_TYPE) {
 358   2      		code_transmit((unsigned char code *)&ConfigDescr, CONFIG_DESCRIPTOR_LENGTH);
 359   2      	} else if(bDescriptor == 0x22){
 360   2      		code_transmit((uchar code *)MyReportDescriptor,sizeof(MyReportDescriptor));	
 361   2      	} else
 362   1      		stall_ep0();
 363   1      }
 364          
 365          void get_configuration(void)
C51 COMPILER V6.12  CHAP_9                                                                 07/30/2003 21:27:45 PAGE 7   

 366          {
 367   1      	unsigned char c = bEPPflags.bits.configuration;
 368   1      	dispinfo(2,"get config    ");
 369   1      	disphex(setupcounter++);
 370   1      	loadmsg("get configur\r\n",20);
 371   1      	single_transmit(&c, 1);
 372   1      }
 373          
 374          void set_configuration(void)
 375          {
 376   1      	dispinfo(2,"set config    ");
 377   1      	disphex(setupcounter++);
 378   1      	loadmsg("set config\r\n",20);
 379   1      	if (ControlData.DeviceRequest.wValue == 0) {
 380   2      		/* put device in unconfigured state */
 381   2      		single_transmit(0, 0);
 382   2      		DISABLE;
 383   2      		bEPPflags.bits.configuration = 0;
 384   2      		ENABLE;
 385   2      		init_unconfig();
 386   2      	} else if (ControlData.DeviceRequest.wValue == 1) {
 387   2      		/* Configure device */
 388   2      		single_transmit(0, 0);
 389   2      
 390   2      		init_unconfig();
 391   2      		init_config();
 392   2      		
 393   2      		DISABLE;
 394   2      		bEPPflags.bits.configuration = 1;
 395   2      		ENABLE;
 396   2      	} else
 397   1      		stall_ep0();
 398   1      }
 399          
 400          void get_interface(void)
 401          {
 402   1      
 403   1      	unsigned char txdat = 0;        /* Only/Current interface = 0 */
 404   1      	dispinfo(2,"get interface ");
 405   1      	disphex(setupcounter++);
 406   1      	loadmsg("get interface\r\n",20);
 407   1      	single_transmit(&txdat, 1);
 408   1      }
 409          
 410          void set_interface(void)
 411          {
 412   1      	dispinfo(2,"set interface ");
 413   1      	disphex(setupcounter++);
 414   1      	loadmsg("set interface\r\n",20);
 415   1      	if (ControlData.DeviceRequest.wValue == 0 && ControlData.DeviceRequest.wIndex == 0)
 416   1      		single_transmit(0, 0);
 417   1      	else
 418   1      		stall_ep0();
 419   1      }
 420          
 421          
 422          
 423          
 424          


MODULE INFORMATION:   STATIC OVERLAYABLE
C51 COMPILER V6.12  CHAP_9                                                                 07/30/2003 21:27:45 PAGE 8   

   CODE SIZE        =   1394    ----
   CONSTANT SIZE    =    464    ----
   XDATA SIZE       =     24      18
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -