From 9f667d96f8ee0c856f39a2a1a1ac5b9d7335af32 Mon Sep 17 00:00:00 2001 From: xmos-jenkins Date: Tue, 11 Jan 2022 11:23:28 +0000 Subject: [PATCH] Added alternative hidIsGetIdleSilenced function --- lib_xua/src/hid/hid.xc | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/lib_xua/src/hid/hid.xc b/lib_xua/src/hid/hid.xc index 0c09d609..3f81bd07 100644 --- a/lib_xua/src/hid/hid.xc +++ b/lib_xua/src/hid/hid.xc @@ -37,20 +37,40 @@ XUD_Result_t HidInterfaceClassRequests( unsigned HidIsSetIdleSilenced( const unsigned id ) { - unsigned isSilenced = hidIsIdleActive( id ); - - if( !isSilenced ) { unsigned currentTime; // Use inline assembly to access the time without creating a side-effect. // The mapper complains if the time comes from an XC timer because this function is called in the guard of a select case. // Appearently the use of a timer creates a side-effect that prohibits the operation of the select functionality. asm volatile( "gettime %0" : "=r" ( currentTime )); - isSilenced = ( 0U == hidGetReportPeriod( id ) || ( timeafter( hidGetNextReportTime( id ), currentTime ))); - } - return isSilenced; + unsigned isSilenced = timeafter(hidGetNextReportTime( id ), currentTime); + + // Calling hidGetReportPeriod with an ID of 0 is meaningless if we are using + // report IDs. + if (!hidIsReportIdInUse() || (id != 0)) + { + isSilenced |= ( 0U == hidGetReportPeriod( id ) ); + } + + return isSilenced; } +//unsigned HidIsSetIdleSilenced( const unsigned id ) +//{ +// unsigned isSilenced = hidIsIdleActive( id ); +// +// if( !isSilenced ) { +// unsigned currentTime; +// // Use inline assembly to access the time without creating a side-effect. +// // The mapper complains if the time comes from an XC timer because this function is called in the guard of a select case. +// // Appearently the use of a timer creates a side-effect that prohibits the operation of the select functionality. +// asm volatile( "gettime %0" : "=r" ( currentTime )); +// isSilenced = ( 0U == hidGetReportPeriod( id ) || ( timeafter( hidGetNextReportTime( id ), currentTime ))); +// } +// +// return isSilenced; +//} + /** * \brief Calculate the timer value for sending the next HID Report. *