void test_step_get_desc(UINT32 base_addr) { UINT8 cmd_get_dev_desc[]={0x80,0x06,0x00,0x01,0x00,0x00,0x12,0x00 }; unsigned long i; volatile unsigned long j; //delay 15s USB_LOGO_PRINTF("delay 15s!\n"); osal_task_sleep(5000); osal_task_sleep(5000); osal_task_sleep(5000); if(ep0_setup(base_addr,cmd_get_dev_desc,8) != RET_SUCCESS) goto err; USB_LOGO_PRINTF("control SETUP phase OK!\n"); USB_LOGO_PRINTF("delay 5s!\n"); osal_task_sleep(5000); if(ep0_in_data(base_addr,((UINT8*)&test_device_descriptor),18) != RET_SUCCESS) goto err; USB_LOGO_PRINTF("control DATA phase OK!\n"); usb_test_show_hex("dev_desc:",((UINT8*)&test_device_descriptor),18); if(ep0_status(base_addr, B_TOKEN_OUT) != RET_SUCCESS) goto err; USB_LOGO_PRINTF("control STATUS phase OK!\n"); err: return; }
/******************************************** * get whole descriptor data by usb_test_start * *********************************************/ void test_get_dev_descriptor(UINT32 base_addr) { UINT8 cmd_get_dev_desc[]={0x80,0x06,0x00,0x01,0x00,0x00,0x12,0x00 }; // UINT8 device_descriptor_buff[18]; // usbd_get_descriptor() USB_LOGO_PRINTF("get dev descriptor!\n"); set_device_address(base_addr,2); if(ep0_setup(base_addr,cmd_get_dev_desc,8) != RET_SUCCESS) goto err; USB_LOGO_PRINTF("control SETUP phase OK!\n"); if(ep0_in_data(base_addr,((UINT8*)&test_device_descriptor),18) != RET_SUCCESS) goto err; USB_LOGO_PRINTF("control DATA phase OK!\n"); if(ep0_status(base_addr, B_TOKEN_OUT) != RET_SUCCESS) goto err; USB_LOGO_PRINTF("control STATUS phase OK!\n"); err: return; }
static void usb_udc_init(void) { DBG("\n************************\n"); DBG(" usb init start\n"); DBG("\n************************\n"); usb_phy_init(); usb_set_mode_device(); mxc_init_usb_qh(); usb_init_eps(); mxc_init_ep_struct(); ep0_setup(); }
void test_set_address(UINT32 base_addr) { UINT8 cmd_set_dev_addr[]={0x00,0x05,0x02,0x00,0x00,0x00,0x00,0x00 }; //addr: 0x02 UINT8 temp_buff[8]; // usbd_set_dev_address(new_dev) ; USB_LOGO_PRINTF("2.set_dev_address!\n"); if(ep0_setup(base_addr,cmd_set_dev_addr,8) != RET_SUCCESS) goto err; USB_LOGO_PRINTF("control SETUP phase OK!\n"); if(ep0_in_data(base_addr,temp_buff,0) != RET_SUCCESS) goto err; // if(ep0_status(base_addr, B_TOKEN_IN) != RET_SUCCESS) // goto err; USB_LOGO_PRINTF("control STATUS phase OK!\n"); err: return; }
void test_step_get_desc_data( UINT32 base_addr ) { UINT8 cmd_get_dev_desc[] = { 0x80, 0x06, 0x00, 0x01, 0x00, 0x00, 0x8, 0x00 }; unsigned long i; volatile unsigned long j; UINT8 bus_speed; usb_hw_init(base_addr); osal_task_sleep(2); *((volatile unsigned char *) (base_addr + 0x1e)) = 0x00; *((volatile unsigned char *) (base_addr + 0x1f)) = 0x00; *((volatile unsigned char *) (base_addr + 0x62)) = 0xFF; USB_LOGO_PRINTF("\n 1.reset usb bus!\n"); issue_reset_to_device(base_addr); if ( wait_bus_reset_finish(base_addr) != RET_SUCCESS ) { goto err; } osal_task_sleep(2000); USB_LOGO_PRINTF("get device speed"); bus_speed = get_device_speed(base_addr); if ( bus_speed & B_OPER_FS ) { USB_LOGO_PRINTF("Device is in FS mode!\n"); } else if ( bus_speed & B_OPER_LS ) { USB_LOGO_PRINTF("Device is in LS mode!\n"); } else { USB_LOGO_PRINTF("Device is in HS mode!\n"); } if ( ep0_setup(base_addr, cmd_get_dev_desc, 8) != RET_SUCCESS ) { goto err; } USB_LOGO_PRINTF("control SETUP phase OK!\n"); //delay 15s USB_LOGO_PRINTF("delay 15s!\n"); osal_task_sleep(5000); osal_task_sleep(5000); osal_task_sleep(5000); if ( ep0_in_data(base_addr, ((UINT8 *) &test_device_descriptor), 8) != RET_SUCCESS ) { goto err; } USB_LOGO_PRINTF("control DATA phase OK!\n"); // usb_if_test_info_close(); usb_test_show_hex("dev_desc:", ((UINT8 *) &test_device_descriptor), 8); if ( ep0_status(base_addr, B_TOKEN_OUT) != RET_SUCCESS ) { goto err; } USB_LOGO_PRINTF("control STATUS phase OK!\n"); err : return; }
RET_CODE usb_test_ui_enum(struct usb_device_descriptor *dev_descriptor ) { UINT32 ret = RET_SUCCESS; UINT8 cmd_set_dev_addr[]={0x00,0x05,0x02,0x00,0x00,0x00,0x00,0x00 }; //addr: 0x02 UINT8 cmd_get_dev_desc[]={0x80,0x06,0x00,0x01,0x00,0x00,0x12,0x00 }; UINT8 temp_buff[8]; UINT32 bus_speed; UINT32 base_addr = 0xb800F000; usb_if_test_flag = IF_TEST_PACKET; if (sys_ic_is_M3202())//(sys_ic_get_chip_id() == ALI_M3202) base_addr = HC_M3202_BASE_ADDR; else if( (sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()>=IC_REV_5)) base_addr = HC_S3329E5_BASE_ADDR; else if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()<IC_REV_5)) base_addr = HC_S3329E_BASE_ADDR; else if (sys_ic_get_chip_id() == ALI_S3602) base_addr = HC_S3602_BASE_ADDR; else if (sys_ic_get_chip_id() == ALI_S3602F) { if(s3602f_test_port == IF_FRONT_PROT) base_addr = HC_S3602F_BASE_ADDR; else if(s3602f_test_port == IF_REAR_PROT) base_addr = HC_S3602F_BASE_ADDR1; } else return !RET_SUCCESS; // usb invalid chip id //usb_test_show_txt("enumeration..."); usb_hw_init(base_addr); osal_task_sleep(2); // osal_delay(100); //disable int *((volatile unsigned char *)(base_addr+0x1E))= 0x00; *((volatile unsigned char *)(base_addr+0x1F))= 0x00; *((volatile unsigned char *)(base_addr+0x62))= 0xFF; //TX_DRIVING +10% if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()<IC_REV_5)) *((volatile unsigned char *)0xb800007C) = 0x03; //USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING - USB_LOGO_PRINTF("\n 1.reset usb bus!\n"); issue_reset_to_device(base_addr); if(wait_bus_reset_finish(base_addr) != RET_SUCCESS) { ret = !RET_SUCCESS; goto err; } osal_task_sleep(500); USB_LOGO_PRINTF("get device speed"); bus_speed = get_device_speed(base_addr); if (bus_speed & B_OPER_FS) { USB_LOGO_PRINTF("Device is in FS mode!\n"); } else if (bus_speed & B_OPER_LS) { USB_LOGO_PRINTF("Device is in LS mode!\n"); } else { USB_LOGO_PRINTF("Device is in HS mode!\n"); } osal_task_sleep(2000); // usbd_set_dev_address(new_dev) ; USB_LOGO_PRINTF("\n 2.set_dev_address!\n"); if(ep0_setup(base_addr,cmd_set_dev_addr,8) != RET_SUCCESS) { ret = !RET_SUCCESS; goto err; } USB_LOGO_PRINTF("control SETUP phase OK!\n"); if(ep0_in_data(base_addr,temp_buff,0) != RET_SUCCESS) { ret = !RET_SUCCESS; goto err; } // if(ep0_status(base_addr, B_TOKEN_IN) != RET_SUCCESS) // goto err; USB_LOGO_PRINTF("control STATUS phase OK!\n"); // usbd_get_descriptor() USB_LOGO_PRINTF("\n 3.get dev descriptor!\n"); set_device_address(base_addr,2); if(ep0_setup(base_addr,cmd_get_dev_desc,8) != RET_SUCCESS) { ret = !RET_SUCCESS; goto err; } USB_LOGO_PRINTF("control SETUP phase OK!\n"); if(ep0_in_data(base_addr,((UINT8*)&test_device_descriptor),18) != RET_SUCCESS) { ret = !RET_SUCCESS; goto err; } USB_LOGO_PRINTF("control DATA phase OK!\n"); if(ep0_status(base_addr, B_TOKEN_OUT) != RET_SUCCESS) { ret = !RET_SUCCESS; goto err; } USB_LOGO_PRINTF("control STATUS phase OK!\n"); MEMCPY(dev_descriptor , &test_device_descriptor ,18) ; err: if(ret != RET_SUCCESS) { usb_test_show_txt("Enum Fail , Please check usb port"); }else{ usb_test_show_txt("enumeration success"); } bus_enum_success = TRUE ; //usb_test_show_hex("dev_desc:",((UINT8*)&test_device_descriptor),18); return ret; }