diff --git a/lib_xua/src/core/buffer/ep/ep_buffer.xc b/lib_xua/src/core/buffer/ep/ep_buffer.xc index 0324bc0b..2eecb6b7 100644 --- a/lib_xua/src/core/buffer/ep/ep_buffer.xc +++ b/lib_xua/src/core/buffer/ep/ep_buffer.xc @@ -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 diff --git a/lib_xua/src/hid/hid_report.c b/lib_xua/src/hid/hid_report.c index ab35b63b..4f165656 100644 --- a/lib_xua/src/hid/hid_report.c +++ b/lib_xua/src/hid/hid_report.c @@ -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; diff --git a/lib_xua/src/hid/xua_hid_report.h b/lib_xua/src/hid/xua_hid_report.h index 21bc3aa9..1b2cb4e9 100644 --- a/lib_xua/src/hid/xua_hid_report.h +++ b/lib_xua/src/hid/xua_hid_report.h @@ -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 *