#include "usb_vendor.h"
#include "system.h"

void USBVendor_HandleDeviceSetup(USB_SetupPacket_t *sp,
    const void **reply_data, int *reply_length, uint8_t *reply_response)
{
    USBVendor_Command_t command = sp->bRequest;

    *reply_data = NULL;
    *reply_length = 0;

    switch(command)
    {
        case USB_VENDOR_COMMAND_NOP:
            *reply_response = USB_EP_TX_VALID;
            break;

        case USB_VENDOR_COMMAND_ENTER_BOOTLOADER:
            *reply_response = USB_EP_TX_VALID;
            System_EnterBootloader();
            break;

        default:
            *reply_response = USB_EP_TX_STALL;
    }
}
