Added sequence ID (aka num) to RawHID

This commit is contained in:
NicoHood 2015-11-07 10:54:50 +01:00
parent 72e2e124b8
commit 186c2c432c
2 changed files with 5 additions and 4 deletions

View file

@ -82,7 +82,7 @@ void loop() {
}
}
void RawHIDEvent(void) {
void RawHIDEvent(uint8_t num) {
// This event is called via interrupt.
// Do not use print inside, or other long function calls!
// If you not use this event function,

View file

@ -48,8 +48,8 @@ static const uint8_t _hidReportDescriptorRawHID[] PROGMEM = {
};
// Weak implementation of the Event function
void RawHIDEvent(void) __attribute__ ((weak));
void RawHIDEvent(void){
void RawHIDEvent(uint8_t num) __attribute__ ((weak));
void RawHIDEvent(uint8_t num){
// Empty
}
@ -122,6 +122,7 @@ bool RawHID_::setup(USBSetup& setup)
{
// Get the data length information and the corresponding bytes
int length = setup.wLength;
uint8_t num = 0;
while(length)
{
// Dont receive more than the USB EP has to offer
@ -143,7 +144,7 @@ bool RawHID_::setup(USBSetup& setup)
// Write data to fit to the end (not the beginning) of the array
USB_RecvControl(data + (sizeof(data) - recvLength), recvLength);
dataLength = recvLength;
RawHIDEvent();
RawHIDEvent(num++);
}
// Do not read the data, flag an error to the USB Host
// TODO always return no error, even if data was discarded? -> use break then