我用ch376芯片来获得打印机的设备描述符老师获不得,我换U盘就可以获得设备描述符,在获得打印机设备描述符时中断返回的状态时20.下面是我写的获得打印机设备描述符的代码,谢谢大家
void ch376_GET_DESCR(void) //3
{
char *buf;
char lenth;
int i = 0;
int status = 0;
CS_LOW;
spi_ReadSend_byte(GET_DESCR);
spi_ReadSend_byte(1);
CS_HIGH;
for( i = 0; i < 100*1000; i++)
{
delay_us(1);
status = ch376_get_status();
if( status == USB_INT_SUCCESS )
{
u3_printf("%02x\r\n", 22);
break;
}
}
if(i>=100*1000)
{
u3_printf("%02x\r\n", 8);
//return;
}
u3_printf("recv interrupt");
//return;
delay_ms(10);
u3_printf("%x\r\n",ch376_get_status());
ch376_write(RD_USB_DATA0);
lenth = ch376_read();
buf = &lenth;
u3_printf("%x\r\n",lenth);
for(int i = lenth;i > 0;i--)
{
*buf = ch376_read();
u3_printf("%x\r\n",*buf);
buf++;
}
}