Пример #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
}
Пример #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;
}
Пример #3
0
void usb_handle_transaction(void) {

    usbrequesterrorflag = 0;

    trn_status = GetUsbTransaction();
    EP0_Outbdp = &usb_bdt[USB_USTAT2BD(trn_status)];
    EP0_Inbdp = &usb_bdt[USB_USTAT2BD(trn_status | DIRBIT)]; // All replies in IN direction

    switch (EP0_Outbdp->BDSTAT & USB_TOKEN_Mask) {
        case USB_TOKEN_SETUP:
            usb_handle_setup();
            break;
        case USB_TOKEN_OUT:
            usb_handle_out();
            break;
        case USB_TOKEN_IN:
            usb_handle_in();
            break;
            //default:
            /* Default case of unknown TOKEN - discard */
    }
}
Пример #4
0
void usb_handle_transaction(void) {
    uLedToggle();
    trn_status = GetUsbTransaction();
    bdp = &usb_bdt[USB_USTAT2BD(trn_status)];
    // JTR PIC24 fixup Added DIRBIT as it is different for PIC24F ( and different again for the PIC24E/dsPIC33E)
    // the USB_USTAT2BD macro is also altered to shift the result the correct number of places.

    rbdp = &usb_bdt[USB_USTAT2BD(trn_status | DIRBIT)]; // All replies in IN direction

    switch (bdp->BDSTAT & USB_TOKEN_Mask) {
        case USB_TOKEN_SETUP:
            usb_handle_setup();
            break;
        case USB_TOKEN_OUT:
            usb_handle_out();
            break;
        case USB_TOKEN_IN:
            usb_handle_in();
            break;
            //default:
            /* Default case of unknown TOKEN - discard */
    }
}