Rename function and variable to better reflect its use beyond initialisation

This commit is contained in:
mbanth
2021-05-25 10:04:51 +01:00
parent b552d60567
commit 46cac9afb9
2 changed files with 15 additions and 15 deletions

View File

@@ -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;
}
}

View File

@@ -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_