diff --git a/src/firmware/c/main.c b/src/firmware/c/main.c index 3d54a33..787d613 100644 --- a/src/firmware/c/main.c +++ b/src/firmware/c/main.c @@ -29,6 +29,8 @@ static unsigned usbWriteLength; /** The blinks memory */ static unsigned char buffer[512]; +static int buffer_size; + static int buffer_read_index = 0; static int buffer_write_index = 0; @@ -101,18 +103,22 @@ usbMsgLen_t usbFunctionSetup(uchar setupData[8]) switch (usbData->bRequest) { + case 0x14: + return 0xff; + case 0xb0: if (usbData->bmRequestType & USBRQ_DIR_DEVICE_TO_HOST) { /* Read mode */ - usbMsgPtr = &buffer[usbData->wIndex.word]; - return usbData->wLength.word; + usbMsgPtr = &buffer[usbData->wIndex.word]; + return usbData->wLength.word > buffer_size ? buffer_size : usbData->wLength.word; } else { /* Write mode */ usbWriteIndex = usbData->wIndex.word; usbWriteLength = usbData->wLength.word; + buffer_size = usbData->wLength.word; return USB_NO_MSG; } break; diff --git a/src/firmware/c/usbconfig.h b/src/firmware/c/usbconfig.h index 884d19f..e779c31 100644 --- a/src/firmware/c/usbconfig.h +++ b/src/firmware/c/usbconfig.h @@ -95,7 +95,7 @@ section at the end of this file). * Since the token is toggled BEFORE sending any data, the first packet is * sent with the oposite value of this configuration! */ -#define USB_CFG_IMPLEMENT_HALT 0 +#define USB_CFG_IMPLEMENT_HALT 1 /* Define this to 1 if you also want to implement the ENDPOINT_HALT feature * for endpoint 1 (interrupt endpoint). Although you may not need this feature, * it is required by the standard. We have made it a config option because it