Clarified ep_buffer.xc setup stall

Added getter hidIsReportDescriptorPrepared(),
allowing more readable logic in the setup phase of
ep_buffer.xc
This commit is contained in:
Angel Cascarino
2021-12-20 16:45:24 +00:00
parent 548992ab5c
commit 625123e4a6
3 changed files with 20 additions and 12 deletions

View File

@@ -375,19 +375,13 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
#if( 0 < HID_CONTROLS )
UserHIDInit();
{
int hidReportLength = 0;
unsigned hidReportId;
while(0 == hidReportLength) {
for( hidReportId = 0U; hidReportId < hidGetReportIdLimit(); ++hidReportId) {
hidReportLength = (int) hidGetReportLength(hidReportId);
if(0 < hidReportLength) {
break;
}
}
}
/* Stall until Report Descriptor has been prepared */
while (!hidIsReportDescriptorPrepared());
hidReportLength = (int) UserHIDGetData(hidReportId, g_hidData);
XUD_SetReady_In(ep_hid, g_hidData, hidReportLength);
/* Get the last report - we don't really care which it is, so long as there's some data we can grab. */
int hidReportLength = (int) UserHIDGetData(hidGetReportIdLimit() - 1, g_hidData);
XUD_SetReady_In(ep_hid, g_hidData, hidReportLength)
}
#endif

View File

@@ -213,6 +213,11 @@ unsigned hidGetNextReportTime( const unsigned id ) {
return retVal;
}
unsigned hidIsReportDescriptorPrepared( void )
{
return s_hidReportDescriptorPrepared;
}
unsigned char* hidGetReportDescriptor( void )
{
unsigned char* retVal = NULL;

View File

@@ -142,6 +142,15 @@ typedef struct
*/
void hidClearChangePending( const unsigned id );
/**
* @brief Indicate if the HID Report descriptor has been prepared
*
* \returns A Boolean indicating whether the HID Report descriptor has been prepared.
* \retval True The HID Report descriptor has been prepared.
* \retval False The HID Report has not been prepared.
*/
unsigned hidIsReportDescriptorPrepared( void );
/**
* @brief Get the HID Report descriptor
*