Пример #1
0
 void get_status(gu::Status& status) const
 {
     for (CtxList::const_iterator i(down_context_.begin());
          i != down_context_.end(); ++i)
     {
         (*i)->get_status(status);
     }
     handle_get_status(status);
 }
Пример #2
0
/**
 * Looks into the SETUPDAT data and dispatches to the callback handlers.
 *
 * Note that this code will handshake the packet for all callbacks except
 * handle_vendorcommand(). This code *used* to handshake those too, but as it
 * is not required by the specification to do so (for packets with a DATA
 * segment) it doesn't do it anymore.
 */
void handle_setupdata() {
    BOOL handshake = TRUE;
    //printf ( "Handle setupdat: %02x\n", SETUPDAT[1] );

    switch ( SETUPDAT[1] ) {

        case GET_STATUS:
            if (!handle_get_status())
                STALLEP0();
            break;
        case CLEAR_FEATURE:
            if (!handle_clear_feature()) {
                STALLEP0();
            }
            break;
        case SET_FEATURE:
            if (!handle_set_feature()) {
                STALLEP0();
            }
            break;
        case GET_DESCRIPTOR:
            handle_get_descriptor();
            break;
        case GET_CONFIGURATION:            
            EP0BUF[0] = handle_get_configuration();
            EP0BCH=0;
            EP0BCL=1;
            break;
        case SET_CONFIGURATION:
            // user callback
            if( !handle_set_configuration(SETUPDAT[2])) {
                STALLEP0();
            }
            break;
        case GET_INTERFACE:
            {
                BYTE alt_ifc;
                if (!handle_get_interface(SETUPDAT[4],&alt_ifc)) {
                    STALLEP0();
                } else {
                 EP0BUF[0] = alt_ifc;
                 EP0BCH=0;
                 EP0BCL=1;
                }
            }
            break;
        case SET_INTERFACE:
            // user callback
            if ( !handle_set_interface(SETUPDAT[4],SETUPDAT[2])) {
                STALLEP0();
            }
            break;
        default:
            if (handle_vendorcommand(SETUPDAT[1])) {
                handshake = FALSE;
            } else {
                printf ( "Unhandled Vendor Command: %02x\n" , SETUPDAT[1] );
                STALLEP0();
            }
    }

    // do the handshake
    if(handshake) {
        EP0CS |= bmHSNAK;
    }
}