Move the HID Clear Pending, Is Pending and Set Pending functions from hid.xc to hid_report_descriptor.c.

These functions are called from the application so they do not belong in hid.xc which contains internal XUA functionality.
This commit is contained in:
mbanth
2021-11-30 18:29:17 +00:00
parent 966d8db9a9
commit b853589120
4 changed files with 53 additions and 40 deletions

View File

@@ -11,17 +11,12 @@
#if( 0 < HID_CONTROLS )
#define MS_IN_TICKS 100000U
static unsigned s_hidChangePending = 0U;
static unsigned s_hidCurrentPeriod = ENDPOINT_INT_INTERVAL_IN_HID * MS_IN_TICKS;
static unsigned s_hidIdleActive = 0U;
static unsigned s_hidIndefiniteDuration = 0U;
static unsigned s_hidNextReportTime = 0U;
static unsigned s_hidReportTime = 0U;
unsafe {
volatile unsigned * unsafe s_hidChangePendingPtr = &s_hidChangePending;
}
static unsigned HidCalcNewReportTime( const unsigned currentPeriod, const unsigned reportTime, const unsigned reportToSetIdleInterval, const unsigned newPeriod );
static unsigned HidCalcReportToSetIdleInterval( const unsigned reportTime );
static unsigned HidFindSetIdleActivationPoint( const unsigned currentPeriod, const unsigned timeWithinPeriod );
@@ -58,18 +53,6 @@ XUD_Result_t HidInterfaceClassRequests(
return result;
}
void HidClearChangePending( void )
{
unsafe {
*s_hidChangePendingPtr = 0U;
}
}
unsigned HidIsChangePending( void )
{
return( s_hidChangePending != 0 );
}
unsigned HidIsSetIdleSilenced( void )
{
unsigned isSilenced = s_hidIdleActive;
@@ -86,13 +69,6 @@ unsigned HidIsSetIdleSilenced( void )
return isSilenced;
}
void HidSetChangePending( void )
{
unsafe {
*s_hidChangePendingPtr = 1;
}
}
/**
* \brief Calculate the timer value for sending the next HID Report.
*

View File

@@ -13,10 +13,13 @@
#define HID_REPORT_DESCRIPTOR_MAX_LENGTH ( HID_REPORT_DESCRIPTOR_ITEM_COUNT * \
( sizeof ( USB_HID_Short_Item_t ) - HID_REPORT_ITEM_LOCATION_SIZE ))
static unsigned hidChangePending = 0U;
static unsigned char hidReportDescriptor[ HID_REPORT_DESCRIPTOR_MAX_LENGTH ];
static size_t hidReportDescriptorLength = 0U;
static unsigned hidReportDescriptorPrepared = 0U;
volatile unsigned* s_hidChangePendingPtr = &hidChangePending;
/**
* @brief Get the bit position from the location of a report element
*
@@ -121,6 +124,11 @@ static unsigned hidGetUsagePage( const unsigned id );
static size_t hidTranslateItem( const USB_HID_Short_Item_t* inPtr, unsigned char** outPtrPtr );
void hidClearChangePending( void )
{
s_hidChangePending = 0U;
}
static unsigned hidGetElementBitLocation( const unsigned short location )
{
unsigned bBit = ( location & HID_REPORT_ELEMENT_LOC_BIT_MASK ) >> HID_REPORT_ELEMENT_LOC_BIT_SHIFT;
@@ -245,6 +253,11 @@ static unsigned hidGetUsagePage( const unsigned id )
return retVal;
}
unsigned hidIsChangePending( void )
{
return( s_hidChangePending != 0 );
}
void hidPrepareReportDescriptor( void )
{
if( !hidReportDescriptorPrepared ) {
@@ -264,6 +277,11 @@ void hidResetReportDescriptor( void )
hidReportDescriptorPrepared = 0U;
}
void hidSetChangePending( void )
{
s_hidChangePending = 1;
}
unsigned hidSetReportItem(
const unsigned id,
const unsigned byte,

View File

@@ -41,17 +41,6 @@ XUD_Result_t HidInterfaceClassRequests(
XUD_ep c_ep0_in,
REFERENCE_PARAM( USB_SetupPacket_t, sp ));
/**
* \brief Register that previously changed HID Report data has reported
* to the USB Host.
*/
void HidClearChangePending( void );
/**
* \brief Indicate if a change to the HID Report data has been received.
*/
unsigned HidIsChangePending( void );
/**
* \brief Indicate whether to send a HID Report based on elapsed time.
*
@@ -70,9 +59,4 @@ unsigned HidIsChangePending( void );
*/
unsigned HidIsSetIdleSilenced( void );
/**
* \brief Register that a change to the HID Report data has been received.
*/
void HidSetChangePending( void );
#endif // __XUA_HID_H__

View File

@@ -87,6 +87,16 @@ typedef struct
unsigned short location;
} USB_HID_Report_Element_t;
/**
* \brief Register that previously changed HID Report data has been sent
* to the USB Host.
*
* \param[in] id A HID Report ID.
* Zero clears the pending status of all Report IDs.
* Use zero if the application does not use Report IDs.
*/
void hidClearChangePending( const unsigned id );
/**
* @brief Get the HID Report descriptor
*
@@ -180,6 +190,22 @@ unsigned hidGetReportItem(
*/
size_t hidGetReportLength( const unsigned id );
/**
* \brief Indicate if a change to the HID Report data has been received.
*
* \param[in] id A HID Report ID.
* Zero reports the pending status of all Report IDs.
* Use zero if the application does not use Report IDs.
*
* \returns A Boolean indicating whether the given \a id has a changed
* HID Report not yet sent to the USB Host.
* \retval True The given \a id has changed HID Report data.
* For an \a id of zero, some HID Report has changed data.
* \retval False The given \a id does not have changed HID Report data.
* For an \a id of zero, no HID Report has changed data.
*/
unsigned hidIsChangePending( const unsigned id );
/**
* @brief Prepare the USB HID Report descriptor
*
@@ -197,6 +223,15 @@ void hidPrepareReportDescriptor( void );
*/
void hidResetReportDescriptor( void );
/**
* \brief Register that a change to the HID Report data has been received.
*
* \param[in] id A HID Report ID.
* Zero reports the pending status of all Report IDs.
* Use zero if the application does not use Report IDs.
*/
void hidSetChangePending( const unsigned id );
/**
* @brief Modify a HID Report descriptor item
*