Manually revert to capture the current time within the HidIsSetIdleSilenced() function

This commit is contained in:
mbanth
2022-01-05 17:52:07 +00:00
parent 7a0cfca280
commit 737c5bd7d0
3 changed files with 6 additions and 10 deletions

View File

@@ -393,8 +393,6 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
#endif #endif
timer tmr; timer tmr;
unsigned loopTime;
tmr :> loopTime;
while(1) while(1)
{ {
@@ -898,13 +896,13 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
#if( 0 < HID_CONTROLS ) #if( 0 < HID_CONTROLS )
/* HID Report Data */ /* HID Report Data */
case (hidIsChangePending(0U) || !HidIsSetIdleSilenced(0U, loopTime)) => XUD_SetData_Select(c_hid, ep_hid, result): case (hidIsChangePending(0U) || !HidIsSetIdleSilenced(0U)) => XUD_SetData_Select(c_hid, ep_hid, result):
{ {
unsigned reportTime; unsigned reportTime;
tmr :> reportTime; tmr :> reportTime;
for(unsigned id = hidIsReportIdInUse(); id < hidGetReportIdLimit(); ++id) { for(unsigned id = hidIsReportIdInUse(); id < hidGetReportIdLimit(); ++id) {
if(0U == id || (hidIsChangePending(id) || !HidIsSetIdleSilenced(id, reportTime))) { if(0U == id || (hidIsChangePending(id) || !HidIsSetIdleSilenced(id))) {
hidCaptureReportTime(id, reportTime); hidCaptureReportTime(id, reportTime);
int hidDataLength = (int) UserHIDGetData(id, g_hidData); int hidDataLength = (int) UserHIDGetData(id, g_hidData);
XUD_SetReady_In(ep_hid, g_hidData, hidDataLength); XUD_SetReady_In(ep_hid, g_hidData, hidDataLength);
@@ -1124,8 +1122,6 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
} }
tmr :> loopTime;
} }
} }
#endif /* XUA_USB_EN */ #endif /* XUA_USB_EN */

View File

@@ -35,16 +35,16 @@ XUD_Result_t HidInterfaceClassRequests(
return result; return result;
} }
unsigned HidIsSetIdleSilenced( const unsigned id, const unsigned currentTime ) unsigned HidIsSetIdleSilenced( const unsigned id )
{ {
unsigned isSilenced = hidIsIdleActive( id ); unsigned isSilenced = hidIsIdleActive( id );
if( !isSilenced ) { if( !isSilenced ) {
// unsigned currentTime; unsigned currentTime;
// Use inline assembly to access the time without creating a side-effect. // 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. // 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. // 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 ))); isSilenced = ( 0U == hidGetReportPeriod( id ) || ( timeafter( hidGetNextReportTime( id ), currentTime )));
} }

View File

@@ -41,6 +41,6 @@ XUD_Result_t HidInterfaceClassRequests(
* \retval 1 -- Do not send the HID Report * \retval 1 -- Do not send the HID Report
* \retval 0 -- Send the HID Report * \retval 0 -- Send the HID Report
*/ */
unsigned HidIsSetIdleSilenced( const unsigned id, const unsigned currentTime ); unsigned HidIsSetIdleSilenced( const unsigned id );
#endif // __XUA_HID_H__ #endif // __XUA_HID_H__