T_uezError Host_SetAddress(void *aWorkspace, TUInt8 aAddress)
{
    T_uezError error;

    error = Host_CtrlSend(
            aWorkspace,
            0,
            0,
            USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE,
            SET_ADDRESS,
            aAddress,
            0,
            0,
            TIMEOUT_STANDARD);

    if (error != UEZ_ERROR_NONE)
        return error;

    // Wait a little bit (2 ms)
    UEZBSPDelayMS(2);

    // Change the control to go to the address
    EDCtrl->Control = (EDCtrl->Control & (~0x7F)) | aAddress;

    return error;
}
예제 #2
0
/*******************************************************************************
* Function Name  : main
* Description    : Main program
* Input          : None
* Output         : None
* Return         : None
* Attention		 : None
*******************************************************************************/
int main (void) {
	uint32_t n;
	uint32_t ret;

	SysTick_Config(SystemCoreClock / 1000);
	#ifdef CFG_SDCARD
  	/* Setup SD Card/FATFS */
  	SDInit();
	#endif
	debug_frmwrk_init();
	printf("\r\n hello");
	//for (n = 0; n < MSC_ImageSize; n++) {     /* Copy Initial Disk Image */
	//	Memory[n] = DiskImage[n];             /* from Flash to RAM */
	//}
	
	if(!KEY1_PIN)
	{
		UsbMode = 0;
		while(!KEY1_PIN);
		delay(100000);
		while(!KEY1_PIN);
		
	}
	if(UsbMode == 0){
		USB_Init();                               /* USB Initialization */
		USB_Connect(TRUE);                        /* USB Connect */
	}
	else{
		
	
	    Host_Init();               // Initialize the lpc17xx host controller                                    
	
		if( Host_EnumDev() == 0 )	/* Enumerate the device connected                                            */
	    {
		  printf("-- USB device detected OK \r\n");
	    }
	    else
	    {
	      printf("-- Please connect a USB device \r\n");
	      while( Host_EnumDev() == 0 );
	      printf("-- USB device connection detected \r\n");
		  Delay(0x00ffff);
	    }
	}

	while (1){
		if(!KEY1_PIN)
		{
			ret = Host_CtrlSend(0x40, 0x50, 0, 0, 0, NULL);
			printf("\r\n sent switch cmd,ret= %x ",ret);
			delay(100);
			NVIC_SystemReset();
		}
	}
}
T_uezError Host_SetConfiguration(
            void *aWorkspace,
            TUInt8 aDeviceAddress,
            TUInt32 aConfigurationNum)
{
    return Host_CtrlSend(
            aWorkspace,
            0,
            aDeviceAddress,
            USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE,
            SET_CONFIGURATION,
            aConfigurationNum,
            0,
            0,
            TIMEOUT_STANDARD);
}