Experiment with obtaining the time used in HidIsSetIdleSilenced() from outside of the function

This commit is contained in:
mbanth
2022-01-05 17:01:28 +00:00
parent 3988906e39
commit 7a0cfca280
3 changed files with 11 additions and 7 deletions

View File

@@ -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 */

View File

@@ -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 )));
}

View File

@@ -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__