diff --git a/lib_xua/src/hid/hid_report_descriptor.c b/lib_xua/src/hid/hid_report_descriptor.c index c55ff8f0..0d43b9fb 100644 --- a/lib_xua/src/hid/hid_report_descriptor.c +++ b/lib_xua/src/hid/hid_report_descriptor.c @@ -154,7 +154,7 @@ static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = { ( sizeof ( USB_HID_Short_Item_t ) - HID_REPORT_ITEM_LOCATION_SIZE )) static unsigned char hidReportDescriptor[ HID_REPORT_DESCRIPTOR_MAX_LENGTH ]; -static unsigned hidReportDescriptorInitialised = 0; +static unsigned hidReportDescriptorPrepared = 0; /** * @brief Get the bit position from the location of an Item @@ -223,6 +223,7 @@ static unsigned hidGetItemType( const unsigned char header ); */ static unsigned char* hidTranslateItem( const USB_HID_Short_Item_t* inPtr, unsigned char* outPtr ); + static unsigned hidGetItemBitLocation( const unsigned char location ) { unsigned bBit = ( location & HID_REPORT_ITEM_LOC_BIT_MASK ) >> HID_REPORT_ITEM_LOC_BIT_SHIFT; @@ -258,21 +259,21 @@ unsigned char* hidGetReportDescriptor( void ) { unsigned char* retVal = NULL; - if( hidReportDescriptorInitialised ) { + if( hidReportDescriptorPrepared ) { retVal = hidReportDescriptor; } return retVal; } -void hidInitReportDescriptor( void ) +void hidPrerpareReportDescriptor( void ) { unsigned char* ptr = hidReportDescriptor; for( unsigned idx = 0; idx < sizeof hidReportDescriptorItems / sizeof( USB_HID_Short_Item_t ); ++idx ) { ptr = hidTranslateItem( hidReportDescriptorItems[ idx ], ptr ); } - hidReportDescriptorInitialised = 1; + hidReportDescriptorPrepared = 1; } unsigned hidSetReportItem( const unsigned byte, const unsigned bit, const unsigned char header, const unsigned char data[] ) @@ -300,7 +301,7 @@ unsigned hidSetReportItem( const unsigned byte, const unsigned bit, const unsign } *hidConfigurableItems[ itemIdx ] = item; - hidReportDescriptorInitialised = 0; + hidReportDescriptorPrepared = 0; retVal = HID_STATUS_GOOD; } } diff --git a/lib_xua/src/hid/xua_hid_report_descriptor.h b/lib_xua/src/hid/xua_hid_report_descriptor.h index 94e335d8..6198ce16 100644 --- a/lib_xua/src/hid/xua_hid_report_descriptor.h +++ b/lib_xua/src/hid/xua_hid_report_descriptor.h @@ -63,6 +63,15 @@ typedef struct */ unsigned char* hidGetReportDescriptor( void ); +/** + * @brief Prepare the USB HID Report descriptor + * + * After preparation, \c hidGetReportDescriptor() returns a list suitablefor transmission over USB. + * + * Call this function after altering one or more Report Items using \c hidSetReportItem(). + */ +void hidPrepareReportDescriptor( void ); + /** * @brief Modify a HID Report descriptor item * @@ -82,14 +91,4 @@ unsigned char* hidGetReportDescriptor( void ); */ unsigned hidSetReportItem( const unsigned byte, const unsigned bit, const unsigned char header, const unsigned char data[] ); -/** - * @brief Initialise the USB HID Report descriptor - * - * After initialisation, \c hidGetReportDescriptor() returns a list suitable - * for transmission over USB. - * - * Call this function after altering one or more Report Items using \c hidSetReportItem(). - */ -void hidInitReportDescriptor( void ); - #endif // _HID_REPORT_DESCRIPTOR_