int MeUsb::probeDevice() { int c; if(!usb_online){ USB_WR( CMD_CHECK_EXIST ); USB_WR( 0x5A); c = USB_RD(); // should return 0xA5 Serial.println(c); if(c!=0xA5) return 0; usb_online = true; resetBus(); } c = getIrq(); if(c!=USB_INT_CONNECT) return 0; resetBus(); // reset bus and wait the device online again c=0; while(c!=USB_INT_CONNECT){ delay(500); // some device may need long time to get ready c = getIrq(); Serial.print("waiting:"); Serial.println(c,HEX); } if( initHIDDevice()==1) device_online=true; }
int16_t MeUSBHost::probeDevice() { int16_t c; if(!ch375_online){ CH375_WR( CMD_CHECK_EXIST ); CH375_WR( 0x5A); c = CH375_RD(); // should return 0xA5 if(c!=0xA5) return 0; ch375_online = true; resetBus(); } c = getIrq(); if(c!=USB_INT_CONNECT) return 0; resetBus(); // reset bus and wait the device online again c=0; while(c!=USB_INT_CONNECT){ delay(500); // some device may need long time to get ready c = getIrq(); #ifdef CH375_DBG Serial.print("waiting:"); Serial.println(c,HEX); #endif } if( initHIDDevice()==1) device_online=true; }
unsigned char MeUsb::clr_stall6(void) { USB_WR( CMD_CLR_STALL ); USB_WR( endp_out_addr | 0x80 ); endp6_mode=0x80; return getIrq(); }
uint8_t MeUSBHost::clr_stall6(void) { CH375_WR( CMD_CLR_STALL ); CH375_WR( endp_out_addr | 0x80 ); endp6_mode=0x80; return getIrq(); }
uint8_t MeUSBHost::issue_token( uint8_t endp_and_pid ) { CH375_WR( CMD_ISSUE_TOKEN ); CH375_WR( endp_and_pid ); /* Bit7~4 for EndPoint No, Bit3~0 for Token PID */ #ifdef CH375_DBG Serial.printf("issue token %x\r\n",endp_and_pid); #endif delay(2); return getIrq(); }
unsigned char MeUsb::issue_token( unsigned char endp_and_pid ) { USB_WR( CMD_ISSUE_TOKEN ); USB_WR( endp_and_pid ); /* Bit7~4 for EndPoint No, Bit3~0 for Token PID */ #ifdef USB_DBG Serial.print("issue token:"); Serial.println(endp_and_pid,HEX); #endif delay(2); return getIrq(); }
unsigned char MeUsb::set_addr( unsigned char addr ) { unsigned char irq; USB_WR(CMD_SET_ADDRESS); USB_WR(addr); irq = getIrq(); if(irq==USB_INT_SUCCESS){ USB_WR(CMD_SET_USB_ADDR); USB_WR(addr); } return irq; }
uint8_t MeUSBHost::set_addr( uint8_t addr ) { uint8_t irq; CH375_WR(CMD_SET_ADDRESS); CH375_WR(addr); irq = getIrq(); if(irq==USB_INT_SUCCESS){ CH375_WR(CMD_SET_USB_ADDR); CH375_WR(addr); } return irq; }
unsigned char MeUsb::get_desr(unsigned char type) { USB_WR( CMD_GET_DESCR ); USB_WR( type ); /* description type, only 1(device) or 2(config) */ return getIrq(); }
unsigned char MeUsb::set_config(unsigned char cfg){ endp6_mode=endp7_mode=0x80; // reset the sync flags USB_WR(CMD_SET_CONFIG); USB_WR(cfg); return getIrq(); }
uint8_t MeUSBHost::get_desr(uint8_t type) { CH375_WR( CMD_GET_DESCR ); CH375_WR( type ); /* description type, only 1(device) or 2(config) */ return getIrq(); }
uint8_t MeUSBHost::set_config(uint8_t cfg){ endp6_mode=endp7_mode=0x80; // reset the sync flags CH375_WR(CMD_SET_CONFIG); CH375_WR(cfg); return getIrq(); }