Add a 100 ms assertion period when this demonstration code signals an NDP100 interrupt.

When testing with the Play/Pause Usage (0xCD) with a Mac as USB Host, adding in this assertion period produced reliable playing and pausing of the iTunes app every 10 seconds.  Without an explicit assertion period, i.e. sending only one report with the lsb set to 1b followed by many reports with the lsb set to 0b, the iTunes app behaved as though it did not see many of the Play/Pause signals.  The inclusion of an assertion period may or may not help when reporting Voice Command events on Andriod.
This commit is contained in:
Michael Banther
2019-09-26 14:27:20 +01:00
parent 9472bd7dce
commit ba666fb314

View File

@@ -4,6 +4,7 @@
#include <xs1.h>
#include "user_hid.h"
#define HID_DEASSERT_COUNT 10000000
#define HID_INTERRUPT_COUNT 1000000000
#define HID_REPORT_DATA 0x01
@@ -24,16 +25,18 @@ void UserReadHIDData( unsigned char hidData[ HID_DATA_SIZE ])
tmr :> curr_time;
tick_count += ( last_time < curr_time ) ? curr_time - last_time : curr_time + ( UINT_MAX - last_time );
if( HID_INTERRUPT_COUNT <= tick_count ) {
if(( HID_INTERRUPT_COUNT <= tick_count ) && ( tick_count <= ( HID_INTERRUPT_COUNT + HID_DEASSERT_COUNT ))) {
for( unsigned idx = 0; idx < HID_DATA_SIZE; ++idx ) {
hidData[ idx ] = HID_REPORT_DATA;
}
tick_count = 0;
} else {
for( unsigned idx = 0; idx < HID_DATA_SIZE; ++idx ) {
hidData[ idx ] = 0x00;
}
}
if (( HID_INTERRUPT_COUNT + HID_DEASSERT_COUNT ) <= tick_count ) {
tick_count = 0;
}
}
last_time = curr_time;