Removed "0 means all" logic throughout

This commit is contained in:
Angel Cascarino
2022-01-11 15:56:32 +00:00
parent d3560ca7fe
commit ec87a43dbf
2 changed files with 22 additions and 76 deletions

View File

@@ -41,44 +41,20 @@ XUD_Result_t HidInterfaceClassRequests(
unsigned HidIsSetIdleSilenced( const unsigned id )
{
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 ));
unsigned nextTime = hidGetNextReportTime( id );
unsigned isSilenced = timeafter(nextTime, currentTime);
if (!isSilenced)
{
debug_printf("%d\n", nextTime);
}
unsigned isSilenced = hidIsIdleActive( id );
// 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;
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 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.
*
@@ -176,7 +152,7 @@ static void HidUpdateReportPeriod( unsigned reportId, unsigned reportDuration )
hidSetNextReportTime( reportId, nextReportTime );
currentPeriod = reportDuration * MS_IN_TICKS;
} else {
currentPeriod = ENDPOINT_INT_INTERVAL_IN_HID * MS_IN_TICKS;
currentPeriod = ENDPOINT_INT_INTERVAL_IN_HID * MS_IN_TICKS * HID_REPORT_COUNT;
}
hidSetReportPeriod( reportId, currentPeriod );

View File

@@ -136,6 +136,9 @@ static unsigned hidGetUsagePage( const unsigned id );
*/
static size_t hidTranslateItem( const USB_HID_Short_Item_t* inPtr, unsigned char** outPtrPtr );
unsigned hidAreReportIdsInUse ( void ) {
return !hidIsReportIdInUse(0U);
}
void hidCalcNextReportTime( const unsigned id )
{
@@ -213,35 +216,19 @@ static unsigned hidGetItemType( const unsigned char header )
return bType;
}
unsigned hidGetNextReportTime( const unsigned id )
{
unsigned hidGetNextReportTime( const unsigned id ) {
swlock_acquire(&hidStaticVarLock);
unsigned retVal = (id == 0U) ? s_hidNextReportTime[0] : 0U;
unsigned retVal = 0U;
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
if (id == 0U)
{
unsigned nextReportTime = s_hidNextReportTime[ idx ];
retVal = (nextReportTime < retVal) ? nextReportTime : retVal;
} else if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
for ( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
retVal = s_hidNextReportTime[ idx ];
}
}
}
swlock_release(&hidStaticVarLock);
return retVal;
}
//unsigned hidGetNextReportTime( const unsigned id ) {
// unsigned retVal = 0U;
//
// for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
// if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
// retVal = s_hidNextReportTime[ idx ];
// }
// }
// return retVal;
//}
unsigned char* hidGetReportDescriptor( void )
{
unsigned char* retVal = NULL;
@@ -398,9 +385,7 @@ unsigned hidIsChangePending( const unsigned id )
swlock_acquire(&hidStaticVarLock);
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
if( id == 0U && s_hidChangePending[ idx ] != 0U ) {
retVal = 1;
} else if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
retVal = ( s_hidChangePending[ idx ] != 0U );
break;
}
@@ -413,15 +398,10 @@ unsigned hidIsChangePending( const unsigned id )
unsigned hidIsIdleActive( const unsigned id )
{
unsigned retVal = 0U;
if( 0U == id ) {
retVal = 1U;
}
swlock_acquire(&hidStaticVarLock);
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
if( id == 0U ) {
retVal &= ( s_hidIdleActive[ idx ] != 0U );
} else if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
retVal = ( s_hidIdleActive[ idx ] != 0U );
break;
}
@@ -438,16 +418,6 @@ unsigned hidIsReportDescriptorPrepared( void )
return retVal;
}
unsigned hidIsReportIdInUse ( void ) {
swlock_acquire(&hidStaticVarLock);
if ( hidGetElementReportId( hidReports[ 0 ]->location ) ) {
swlock_release(&hidStaticVarLock);
return 1;
}
swlock_release(&hidStaticVarLock);
return 0;
}
unsigned hidIsReportIdValid ( unsigned id ) {
size_t retVal = 0;