From ba666fb314e96c8655688ca6925fbdf6f30597c7 Mon Sep 17 00:00:00 2001 From: Michael Banther Date: Thu, 26 Sep 2019 14:27:20 +0100 Subject: [PATCH] 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. --- lib_xua/src/core/user/user_hid.xc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib_xua/src/core/user/user_hid.xc b/lib_xua/src/core/user/user_hid.xc index d27d6914..4319bf43 100644 --- a/lib_xua/src/core/user/user_hid.xc +++ b/lib_xua/src/core/user/user_hid.xc @@ -4,6 +4,7 @@ #include #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;