Exemplo n.º 1
0
void usb_handler(void) {

    if (USB_IDLE_FLAG) {
        /* Idle - suspend */
        USBSuspend(); // // Must be defined in user code.
        ClearUsbInterruptFlag(USB_IDLE);
    }

    if (USB_RESET_FLAG) {
        usb_handle_reset();
        ClearUsbInterruptFlag(USB_URST);
    }
    if (USB_ERROR_FLAG) {
        //     usb_handle_error();
        ClearAllUsbErrorInterruptFlags();
        ClearUsbInterruptFlag(USB_UERR);
    }
    if (USB_STALL_FLAG) {
        ClearUsbInterruptFlag(USB_STALL);
    }
    if (USB_SOF_FLAG) {
        /* Start-of-frame */
        if (sof_handler) sof_handler();
        ClearUsbInterruptFlag(USB_SOF);
    }

    if (USB_TRANSACTION_FLAG) {
        if (!USB_STAT2EP(GetUsbTransaction()))
            usb_handle_transaction(); // Only handle EP0 transactions.
        ClearUsbInterruptFlag(USB_TRN); // JTR Missing! This is why Ian was only getting one interrupt??
    } // Side effect: advance USTAT Fifo
}
Exemplo n.º 2
0
BYTE FAST_usb_handler(void) {
    if (TestGlobalUsbInterruptFlag()) {
        if (USB_RESET_FLAG) {
            usb_handle_reset();
            ClearUsbInterruptFlag(USB_URST);
            return 0xFF;
        }
        if (USB_TRANSACTION_FLAG) {
            trn_status = GetUsbTransaction();
            if (USB_STAT2EP(trn_status)) {
                usb_handle_transaction();
                ClearUsbInterruptFlag(USB_TRN); // non-EP0 only
                return 0xFF;
            } else {
                ClearUsbInterruptFlag(USB_TRN); // non-EP0 only
            }
        }
        ClearGlobalUsbInterruptFlag();
    }
    return 0;
}
Exemplo n.º 3
0
void usb_handler(void) {
    if (USB_RESET_FLAG) {
        usb_handle_reset();
        ClearUsbInterruptFlag(USB_URST);
    } else if (USB_ERROR_FLAG) {
        usb_handle_error();
        ClearUsbInterruptFlag(USB_UERR);
    } else if (USB_ACTIVITY_FLAG) {
        /* Activity - unsuspend */
        //WakeupUsb();
        ClearUsbInterruptFlag(USB_ACTIV);
    } else if (USB_IDLE_FLAG) {
        /* Idle - suspend */
        //SuspendUsb();
        //usb_low_power_request();
        ClearUsbInterruptFlag(USB_IDLE);
    } else if (USB_STALL_FLAG) {
        /* Stall detected
         * Not sure when this interrupt fires
         * as the host never should send out a stall.
         * Perhaps as a respons to our own stalls?
         * For now just ignore it. */
        ClearUsbInterruptFlag(USB_STALL);
    } else if (USB_SOF_FLAG) {
        /* Start-of-frame */
        //if (sof_handler) sof_handler();
        {
            ClearUsbInterruptFlag(USB_SOF);
        }
    } else {
        // process all pending transactions
        while (USB_TRANSACTION_FLAG) {
            usb_handle_transaction();
            ClearUsbInterruptFlag(USB_TRN);
        } // Side effect: advance USTAT Fifo
    }
}