BOOL handle_set_interface(BYTE ifc, BYTE alt_ifc) { /* We only support interface 0, alternate interface 0. */ if (ifc != 0 || alt_ifc != 0) return FALSE; /* Perform procedure from TRM, section 2.3.7: */ /* (1) TODO. */ /* (2) Reset data toggles of the EPs in the interface. */ /* Note: RESETTOGGLE() gets the EP number WITH bit 7 set/cleared. */ RESETTOGGLE(0x82); /* (3) Restore EPs to their default conditions. */ /* Note: RESETFIFO() gets the EP number WITHOUT bit 7 set/cleared. */ RESETFIFO(0x02); RESETTOGGLE(0x86); RESETFIFO(0x06); /* TODO */ /* (4) Clear the HSNAK bit. Not needed, fx2lib does this. */ return TRUE; }
// Called when a Set Interface command is received // uint8 handle_set_interface(uint8 ifc, uint8 alt) { if ( ifc == 0 && alt == 0 ) { RESETTOGGLE(0x01); RESETTOGGLE(0x81); RESETTOGGLE(0x02); RESETTOGGLE(0x86); return true; } else { return false; } }
BOOL handle_set_interface(BYTE interface, BYTE alt_interface) { if (interface != 0 || alt_interface != 0) return FALSE; RESETTOGGLE(0x01); /* ep1 out */ RESETTOGGLE(0x81); /* ep1 in */ RESETTOGGLE(0x82); /* ep2 in */ RESETTOGGLE(0x06); /* ep6 out */ RESETFIFO(2); return TRUE; }
BOOL handle_set_interface(BYTE ifc, BYTE alt_ifc) { printf ( "Set interface %d to alt: %d\n" , ifc, alt_ifc ); if (ifc==0&&alt_ifc==0) { // SEE TRM 2.3.7 // reset toggles RESETTOGGLE(0x02); RESETTOGGLE(0x86); // restore endpoints to default condition RESETFIFO(0x02); EP2BCL=0x80; SYNCDELAY(); EP2BCL=0X80; SYNCDELAY(); RESETFIFO(0x86); return TRUE; } else return FALSE; }
BOOL handle_set_feature() { printf ( "Set Feature %02x\n", SETUPDAT[0] ); switch ( SETUPDAT[0] ) { case GF_DEVICE: if (SETUPDAT[2] == 2) break; // this is TEST_MODE and we simply need to return the handshake if (SETUPDAT[2] == 1) { remote_wakeup_allowed=TRUE; break; } return FALSE; case GF_ENDPOINT: if ( SETUPDAT[2] == 0 ) { // ep stall feature // set TRM 2.3.2 // stall and endpoint xdata BYTE* pep = ep_addr(SETUPDAT[4]); printf ( "Stall ep %d\n", SETUPDAT[4] ); if (!pep) { return FALSE; } *pep |= bmEPSTALL; // should now reset data toggles // write ep+dir to TOGCTL RESETTOGGLE(SETUPDAT[4]); // restore stalled ep to default condition // NOTE //handle_reset_ep(SETUPDAT[4]); } else { printf ( "unsupported ep feature %02x\n", SETUPDAT[2] ); return FALSE; } break; default: return handle_vendorcommand(SETUPDAT[1]); } return TRUE; }