forked from PAWPAW-Mirror/lib_xua
Rename function and variable to better reflect its use beyond initialisation
This commit is contained in:
@@ -154,7 +154,7 @@ static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
|||||||
( sizeof ( USB_HID_Short_Item_t ) - HID_REPORT_ITEM_LOCATION_SIZE ))
|
( sizeof ( USB_HID_Short_Item_t ) - HID_REPORT_ITEM_LOCATION_SIZE ))
|
||||||
|
|
||||||
static unsigned char hidReportDescriptor[ HID_REPORT_DESCRIPTOR_MAX_LENGTH ];
|
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
|
* @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 char* hidTranslateItem( const USB_HID_Short_Item_t* inPtr, unsigned char* outPtr );
|
||||||
|
|
||||||
|
|
||||||
static unsigned hidGetItemBitLocation( const unsigned char location )
|
static unsigned hidGetItemBitLocation( const unsigned char location )
|
||||||
{
|
{
|
||||||
unsigned bBit = ( location & HID_REPORT_ITEM_LOC_BIT_MASK ) >> HID_REPORT_ITEM_LOC_BIT_SHIFT;
|
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;
|
unsigned char* retVal = NULL;
|
||||||
|
|
||||||
if( hidReportDescriptorInitialised ) {
|
if( hidReportDescriptorPrepared ) {
|
||||||
retVal = hidReportDescriptor;
|
retVal = hidReportDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidInitReportDescriptor( void )
|
void hidPrerpareReportDescriptor( void )
|
||||||
{
|
{
|
||||||
unsigned char* ptr = hidReportDescriptor;
|
unsigned char* ptr = hidReportDescriptor;
|
||||||
for( unsigned idx = 0; idx < sizeof hidReportDescriptorItems / sizeof( USB_HID_Short_Item_t ); ++idx ) {
|
for( unsigned idx = 0; idx < sizeof hidReportDescriptorItems / sizeof( USB_HID_Short_Item_t ); ++idx ) {
|
||||||
ptr = hidTranslateItem( hidReportDescriptorItems[ idx ], ptr );
|
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[] )
|
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;
|
*hidConfigurableItems[ itemIdx ] = item;
|
||||||
hidReportDescriptorInitialised = 0;
|
hidReportDescriptorPrepared = 0;
|
||||||
retVal = HID_STATUS_GOOD;
|
retVal = HID_STATUS_GOOD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,15 @@ typedef struct
|
|||||||
*/
|
*/
|
||||||
unsigned char* hidGetReportDescriptor( void );
|
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
|
* @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[] );
|
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_
|
#endif // _HID_REPORT_DESCRIPTOR_
|
||||||
|
|||||||
Reference in New Issue
Block a user