예제 #1
0
/*----------------------------------------------------------------------------+
| Interrupt Sub-routines                                                      |
+----------------------------------------------------------------------------*/
BYTE SetupPacketInterruptHandler(VOID)
{
    BYTE bTemp;
    BYTE bWakeUp = FALSE;
    USBCTL |= FRSTE;      // Function Reset Connection Enable - set enable after first setup packet was received
    usbProcessNewSetupPacket:
    // copy the MSB of bmRequestType to DIR bit of USBCTL
    if((tSetupPacket.bmRequestType & USB_REQ_TYPE_INPUT) == USB_REQ_TYPE_INPUT)
    {
    	USBCTL |= DIR;
    }
    else
    {
    	USBCTL &= ~DIR;
    }
    bStatusAction = STATUS_ACTION_NOTHING;
    // clear out return data buffer
    for(bTemp=0; bTemp<USB_RETURN_DATA_LENGTH; bTemp++)
    {
    	abUsbRequestReturnData[bTemp] = 0x00;
    }
    // decode and process the request
    bWakeUp = usbDecodeAndProcessUsbRequest();
    // check if there is another setup packet pending
    // if it is, abandon current one by NAKing both data endpoint 0
    if((USBIFG & STPOWIFG) != 0x00)
    {
    	USBIFG &= ~(STPOWIFG | SETUPIFG);
    	goto usbProcessNewSetupPacket;
    }
    return bWakeUp;
}
예제 #2
0
VOID SetupPacketInterruptHandler(VOID)
{
    USBCTL |= FRSTE;                            // Function Reset Connection Enable

    // NAK both input and output endpoints
    tEndPoint0DescriptorBlock.bOEPBCNT = EPBCNT_NAK;

  usbProcessNewSetupPacket:

    bStatusAction = STATUS_ACTION_NOTHING;

    // clear out return data buffer
    abUsbRequestReturnData[0] = 0x00;
    abUsbRequestReturnData[1] = 0x00;

    // decode and process the request
    usbDecodeAndProcessUsbRequest();
    USBIFG &= ~SETUPIFG;                        // clear the interrupt bit

    // check if there is another setup packet pending
    // if it is, abandon current one by NAKing both data endpoint 0
    if((USBIFG & STPOWIFG) != 0x00)
    {
        USBIFG &= ~(STPOWIFG | SETUPIFG);
        goto usbProcessNewSetupPacket;
    }
}