diff --git a/lib_xua/src/core/buffer/ep/ep_buffer.xc b/lib_xua/src/core/buffer/ep/ep_buffer.xc index e2f81ef4..93781ca9 100644 --- a/lib_xua/src/core/buffer/ep/ep_buffer.xc +++ b/lib_xua/src/core/buffer/ep/ep_buffer.xc @@ -392,6 +392,10 @@ void XUA_Buffer_Ep(register chanend c_aud_out, #endif #endif + timer tmr; + unsigned loopTime; + tmr :> loopTime; + while(1) { XUD_Result_t result; @@ -894,14 +898,13 @@ void XUA_Buffer_Ep(register chanend c_aud_out, #if( 0 < HID_CONTROLS ) /* HID Report Data */ - case (hidIsChangePending(0U) || !HidIsSetIdleSilenced(0U)) => XUD_SetData_Select(c_hid, ep_hid, result): + case (hidIsChangePending(0U) || !HidIsSetIdleSilenced(0U, loopTime)) => XUD_SetData_Select(c_hid, ep_hid, result): { - timer tmr; unsigned reportTime; tmr :> reportTime; for(unsigned id = hidIsReportIdInUse(); id < hidGetReportIdLimit(); ++id) { - if(0U == id || (hidIsChangePending(id) || !HidIsSetIdleSilenced(id))) { + if(0U == id || (hidIsChangePending(id) || !HidIsSetIdleSilenced(id, reportTime))) { hidCaptureReportTime(id, reportTime); int hidDataLength = (int) UserHIDGetData(id, g_hidData); XUD_SetReady_In(ep_hid, g_hidData, hidDataLength); @@ -1122,6 +1125,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out, } + tmr :> loopTime; } } #endif /* XUA_USB_EN */ diff --git a/lib_xua/src/hid/hid.xc b/lib_xua/src/hid/hid.xc index 0c09d609..3559e6c8 100644 --- a/lib_xua/src/hid/hid.xc +++ b/lib_xua/src/hid/hid.xc @@ -35,16 +35,16 @@ XUD_Result_t HidInterfaceClassRequests( return result; } -unsigned HidIsSetIdleSilenced( const unsigned id ) +unsigned HidIsSetIdleSilenced( const unsigned id, const unsigned currentTime ) { unsigned isSilenced = hidIsIdleActive( id ); if( !isSilenced ) { - unsigned currentTime; +// 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 )); +// asm volatile( "gettime %0" : "=r" ( currentTime )); isSilenced = ( 0U == hidGetReportPeriod( id ) || ( timeafter( hidGetNextReportTime( id ), currentTime ))); } diff --git a/lib_xua/src/hid/xua_hid.h b/lib_xua/src/hid/xua_hid.h index 6e5d31b2..f7bc9448 100644 --- a/lib_xua/src/hid/xua_hid.h +++ b/lib_xua/src/hid/xua_hid.h @@ -41,6 +41,6 @@ XUD_Result_t HidInterfaceClassRequests( * \retval 1 -- Do not send the HID Report * \retval 0 -- Send the HID Report */ -unsigned HidIsSetIdleSilenced( const unsigned id ); +unsigned HidIsSetIdleSilenced( const unsigned id, const unsigned currentTime ); #endif // __XUA_HID_H__