forked from PAWPAW-Mirror/lib_xua
Merge remote-tracking branch 'angel/feature/multiple_hid_report_exception' into feature/set_idle_work
This commit is contained in:
@@ -392,6 +392,8 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
timer tmr;
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
XUD_Result_t result;
|
XUD_Result_t result;
|
||||||
@@ -896,7 +898,6 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
|||||||
/* HID Report Data */
|
/* HID Report Data */
|
||||||
case (hidIsChangePending(0U) || !HidIsSetIdleSilenced(0U)) => XUD_SetData_Select(c_hid, ep_hid, result):
|
case (hidIsChangePending(0U) || !HidIsSetIdleSilenced(0U)) => XUD_SetData_Select(c_hid, ep_hid, result):
|
||||||
{
|
{
|
||||||
timer tmr;
|
|
||||||
unsigned reportTime;
|
unsigned reportTime;
|
||||||
tmr :> reportTime;
|
tmr :> reportTime;
|
||||||
|
|
||||||
@@ -1121,7 +1122,6 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* XUA_USB_EN */
|
#endif /* XUA_USB_EN */
|
||||||
|
|||||||
@@ -9,15 +9,21 @@
|
|||||||
#include "descriptor_defs.h"
|
#include "descriptor_defs.h"
|
||||||
#include "xua_hid_report.h"
|
#include "xua_hid_report.h"
|
||||||
#include "hid_report_descriptor.h"
|
#include "hid_report_descriptor.h"
|
||||||
|
#include "swlock.h"
|
||||||
|
|
||||||
|
|
||||||
#define HID_REPORT_ITEM_LOCATION_SIZE ( 1 )
|
#define HID_REPORT_ITEM_LOCATION_SIZE ( 1 )
|
||||||
#define HID_REPORT_DESCRIPTOR_ITEM_COUNT ( sizeof hidReportDescriptorItems / sizeof ( USB_HID_Short_Item_t* ))
|
#define HID_REPORT_DESCRIPTOR_ITEM_COUNT ( sizeof hidReportDescriptorItems / sizeof ( USB_HID_Short_Item_t* ))
|
||||||
#define HID_REPORT_DESCRIPTOR_MAX_LENGTH ( HID_REPORT_DESCRIPTOR_ITEM_COUNT * \
|
#define HID_REPORT_DESCRIPTOR_MAX_LENGTH ( HID_REPORT_DESCRIPTOR_ITEM_COUNT * \
|
||||||
( sizeof ( USB_HID_Short_Item_t ) - HID_REPORT_ITEM_LOCATION_SIZE ))
|
( sizeof ( USB_HID_Short_Item_t ) - HID_REPORT_ITEM_LOCATION_SIZE ))
|
||||||
|
|
||||||
|
swlock_t hidStaticVarLock = SWLOCK_INITIAL_VALUE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Each element in s_hidChangePending corresponds to an element in hidReports.
|
* Each element in s_hidChangePending corresponds to an element in hidReports.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static unsigned s_hidChangePending[ HID_REPORT_COUNT ];
|
static unsigned s_hidChangePending[ HID_REPORT_COUNT ];
|
||||||
static unsigned char s_hidReportDescriptor[ HID_REPORT_DESCRIPTOR_MAX_LENGTH ];
|
static unsigned char s_hidReportDescriptor[ HID_REPORT_DESCRIPTOR_MAX_LENGTH ];
|
||||||
static size_t s_hidReportDescriptorLength;
|
static size_t s_hidReportDescriptorLength;
|
||||||
@@ -134,30 +140,36 @@ static size_t hidTranslateItem( const USB_HID_Short_Item_t* inPtr, unsigned char
|
|||||||
|
|
||||||
void hidCalcNextReportTime( const unsigned id )
|
void hidCalcNextReportTime( const unsigned id )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
s_hidNextReportTime[ idx ] = s_hidReportTime[ idx ] + s_hidCurrentPeriod[ idx ];
|
s_hidNextReportTime[ idx ] = s_hidReportTime[ idx ] + s_hidCurrentPeriod[ idx ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidCaptureReportTime( const unsigned id, const unsigned time )
|
void hidCaptureReportTime( const unsigned id, const unsigned time )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
s_hidReportTime[ idx ] = time;
|
s_hidReportTime[ idx ] = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidClearChangePending( const unsigned id )
|
void hidClearChangePending( const unsigned id )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
||||||
if(( id == 0U ) || ( id == hidGetElementReportId( hidReports[ idx ]->location ))) {
|
if(( id == 0U ) || ( id == hidGetElementReportId( hidReports[ idx ]->location ))) {
|
||||||
s_hidChangePending[ idx ] = 0U;
|
s_hidChangePending[ idx ] = 0U;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned hidGetElementBitLocation( const unsigned short location )
|
static unsigned hidGetElementBitLocation( const unsigned short location )
|
||||||
@@ -202,7 +214,9 @@ static unsigned hidGetItemType( const unsigned char header )
|
|||||||
return bType;
|
return bType;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hidGetNextReportTime( const unsigned id ) {
|
unsigned hidGetNextReportTime( const unsigned id )
|
||||||
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
unsigned retVal = 0U;
|
unsigned retVal = 0U;
|
||||||
|
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
@@ -210,67 +224,49 @@ unsigned hidGetNextReportTime( const unsigned id ) {
|
|||||||
retVal = s_hidNextReportTime[ idx ];
|
retVal = s_hidNextReportTime[ idx ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hidIsReportDescriptorPrepared( void )
|
|
||||||
{
|
|
||||||
return s_hidReportDescriptorPrepared;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char* hidGetReportDescriptor( void )
|
unsigned char* hidGetReportDescriptor( void )
|
||||||
{
|
{
|
||||||
unsigned char* retVal = NULL;
|
unsigned char* retVal = NULL;
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
|
|
||||||
if( s_hidReportDescriptorPrepared ) {
|
if( s_hidReportDescriptorPrepared ) {
|
||||||
retVal = s_hidReportDescriptor;
|
retVal = s_hidReportDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t hidGetReportDescriptorLength( void )
|
size_t hidGetReportDescriptorLength( void )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
size_t retVal = ( s_hidReportDescriptorPrepared ) ? s_hidReportDescriptorLength : 0U;
|
size_t retVal = ( s_hidReportDescriptorPrepared ) ? s_hidReportDescriptorLength : 0U;
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hidGetReportIdLimit ( void ) {
|
unsigned hidGetReportIdLimit ( void ) {
|
||||||
unsigned retVal = 0U;
|
unsigned retVal = 0U;
|
||||||
|
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
unsigned reportId = hidGetElementReportId( hidReports[ idx ]->location );
|
unsigned reportId = hidGetElementReportId( hidReports[ idx ]->location );
|
||||||
if( reportId >= retVal ) {
|
if( reportId >= retVal ) {
|
||||||
retVal = reportId + 1;
|
retVal = reportId + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
|
||||||
|
|
||||||
unsigned hidIsReportIdInUse ( void ) {
|
|
||||||
if ( hidGetElementReportId( hidReports[ 0 ]->location ) ) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned hidIsReportIdValid ( unsigned id ) {
|
|
||||||
size_t retVal = 0;
|
|
||||||
|
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
|
||||||
unsigned reportId = hidGetElementReportId( hidReports[ idx ]->location );
|
|
||||||
if( reportId == id ) {
|
|
||||||
retVal = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hidGetNextValidReportId ( unsigned idPrev ) {
|
unsigned hidGetNextValidReportId ( unsigned idPrev ) {
|
||||||
size_t retIndex = 0;
|
size_t retIndex = 0;
|
||||||
|
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
unsigned reportId = hidGetElementReportId( hidReports[ idx ]->location );
|
unsigned reportId = hidGetElementReportId( hidReports[ idx ]->location );
|
||||||
if( reportId == idPrev ) {
|
if( reportId == idPrev ) {
|
||||||
@@ -279,7 +275,9 @@ unsigned hidGetNextValidReportId ( unsigned idPrev ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hidGetElementReportId( hidReports[ retIndex ]->location );
|
unsigned retVal = hidGetElementReportId( hidReports[ retIndex ]->location );
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HID_CONFIGURABLE_ELEMENT_COUNT ( sizeof hidConfigurableElements / sizeof ( USB_HID_Report_Element_t* ))
|
#define HID_CONFIGURABLE_ELEMENT_COUNT ( sizeof hidConfigurableElements / sizeof ( USB_HID_Report_Element_t* ))
|
||||||
@@ -294,7 +292,10 @@ unsigned hidGetReportItem(
|
|||||||
{
|
{
|
||||||
unsigned retVal = HID_STATUS_BAD_ID;
|
unsigned retVal = HID_STATUS_BAD_ID;
|
||||||
for( size_t elementIdx = 0U; elementIdx < HID_CONFIGURABLE_ELEMENT_COUNT; ++elementIdx ) {
|
for( size_t elementIdx = 0U; elementIdx < HID_CONFIGURABLE_ELEMENT_COUNT; ++elementIdx ) {
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
USB_HID_Report_Element_t element = *hidConfigurableElements[ elementIdx ];
|
USB_HID_Report_Element_t element = *hidConfigurableElements[ elementIdx ];
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
|
|
||||||
unsigned bBit = hidGetElementBitLocation( element.location );
|
unsigned bBit = hidGetElementBitLocation( element.location );
|
||||||
unsigned bByte = hidGetElementByteLocation( element.location );
|
unsigned bByte = hidGetElementByteLocation( element.location );
|
||||||
unsigned bId = hidGetElementReportId( element.location );
|
unsigned bId = hidGetElementReportId( element.location );
|
||||||
@@ -320,6 +321,7 @@ unsigned hidGetReportItem(
|
|||||||
|
|
||||||
size_t hidGetReportLength( const unsigned id )
|
size_t hidGetReportLength( const unsigned id )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
size_t retVal = 0U;
|
size_t retVal = 0U;
|
||||||
if( s_hidReportDescriptorPrepared ) {
|
if( s_hidReportDescriptorPrepared ) {
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
@@ -328,11 +330,13 @@ size_t hidGetReportLength( const unsigned id )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hidGetReportPeriod( const unsigned id )
|
unsigned hidGetReportPeriod( const unsigned id )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
unsigned retVal = 0U;
|
unsigned retVal = 0U;
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
||||||
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
@@ -340,10 +344,13 @@ unsigned hidGetReportPeriod( const unsigned id )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hidGetReportTime( const unsigned id ) {
|
unsigned hidGetReportTime( const unsigned id )
|
||||||
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
unsigned retVal = 0U;
|
unsigned retVal = 0U;
|
||||||
|
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
@@ -351,24 +358,32 @@ unsigned hidGetReportTime( const unsigned id ) {
|
|||||||
retVal = s_hidReportTime[ idx ];
|
retVal = s_hidReportTime[ idx ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned hidGetUsagePage( const unsigned id )
|
static unsigned hidGetUsagePage( const unsigned id )
|
||||||
{
|
{
|
||||||
unsigned retVal = 0U;
|
unsigned retVal = 0U;
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
|
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
||||||
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
retVal = hidReports[ idx ]->item.data[ 0 ];
|
retVal = hidReports[ idx ]->item.data[ 0 ];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hidIsChangePending( const unsigned id )
|
unsigned hidIsChangePending( const unsigned id )
|
||||||
{
|
{
|
||||||
unsigned retVal = 0U;
|
unsigned retVal = 0U;
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
|
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
||||||
if( id == 0U && s_hidChangePending[ idx ] != 0U ) {
|
if( id == 0U && s_hidChangePending[ idx ] != 0U ) {
|
||||||
retVal = 1;
|
retVal = 1;
|
||||||
@@ -377,6 +392,8 @@ unsigned hidIsChangePending( const unsigned id )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,6 +404,7 @@ unsigned hidIsIdleActive( const unsigned id )
|
|||||||
retVal = 1U;
|
retVal = 1U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
||||||
if( id == 0U ) {
|
if( id == 0U ) {
|
||||||
retVal &= ( s_hidIdleActive[ idx ] != 0U );
|
retVal &= ( s_hidIdleActive[ idx ] != 0U );
|
||||||
@@ -395,11 +413,47 @@ unsigned hidIsIdleActive( const unsigned id )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
swlock_release(hidStaticVarLock);
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned hidIsReportDescriptorPrepared( void )
|
||||||
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
|
unsigned retVal = s_hidReportDescriptorPrepared;
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned hidIsReportIdInUse ( void ) {
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
|
if ( hidGetElementReportId( hidReports[ 0 ]->location ) ) {
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned hidIsReportIdValid ( unsigned id ) {
|
||||||
|
size_t retVal = 0;
|
||||||
|
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
|
unsigned reportId = hidGetElementReportId( hidReports[ idx ]->location );
|
||||||
|
if( reportId == id ) {
|
||||||
|
retVal = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidPrepareReportDescriptor( void )
|
void hidPrepareReportDescriptor( void )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
if( !s_hidReportDescriptorPrepared ) {
|
if( !s_hidReportDescriptorPrepared ) {
|
||||||
s_hidReportDescriptorLength = 0U;
|
s_hidReportDescriptorLength = 0U;
|
||||||
unsigned char* ptr = s_hidReportDescriptor;
|
unsigned char* ptr = s_hidReportDescriptor;
|
||||||
@@ -410,49 +464,60 @@ void hidPrepareReportDescriptor( void )
|
|||||||
|
|
||||||
s_hidReportDescriptorPrepared = 1U;
|
s_hidReportDescriptorPrepared = 1U;
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidReportInit( void )
|
void hidReportInit( void )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( unsigned idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
for( unsigned idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
s_hidCurrentPeriod[ idx ] = ENDPOINT_INT_INTERVAL_IN_HID * MS_IN_TICKS;
|
s_hidCurrentPeriod[ idx ] = ENDPOINT_INT_INTERVAL_IN_HID * MS_IN_TICKS;
|
||||||
}
|
}
|
||||||
memset( s_hidIdleActive, 0, sizeof( s_hidIdleActive ) );
|
memset( s_hidIdleActive, 0, sizeof( s_hidIdleActive ) );
|
||||||
memset( s_hidChangePending, 0, sizeof( s_hidChangePending ) );
|
memset( s_hidChangePending, 0, sizeof( s_hidChangePending ) );
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidResetReportDescriptor( void )
|
void hidResetReportDescriptor( void )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
s_hidReportDescriptorPrepared = 0U;
|
s_hidReportDescriptorPrepared = 0U;
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidSetChangePending( const unsigned id )
|
void hidSetChangePending( const unsigned id )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
||||||
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
s_hidChangePending[ idx ] = 1U;
|
s_hidChangePending[ idx ] = 1U;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidSetIdle( const unsigned id, const unsigned state )
|
void hidSetIdle( const unsigned id, const unsigned state )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
||||||
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
s_hidIdleActive[ idx ] = ( state != 0U );
|
s_hidIdleActive[ idx ] = ( state != 0U );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidSetNextReportTime( const unsigned id, const unsigned time )
|
void hidSetNextReportTime( const unsigned id, const unsigned time )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx ) {
|
||||||
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
s_hidNextReportTime[ idx ] = time;
|
s_hidNextReportTime[ idx ] = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned hidSetReportItem(
|
unsigned hidSetReportItem(
|
||||||
@@ -478,7 +543,10 @@ unsigned hidSetReportItem(
|
|||||||
retVal = HID_STATUS_BAD_HEADER;
|
retVal = HID_STATUS_BAD_HEADER;
|
||||||
} else {
|
} else {
|
||||||
for( size_t elementIdx = 0U; elementIdx < HID_CONFIGURABLE_ELEMENT_COUNT; ++elementIdx ) {
|
for( size_t elementIdx = 0U; elementIdx < HID_CONFIGURABLE_ELEMENT_COUNT; ++elementIdx ) {
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
USB_HID_Report_Element_t element = *hidConfigurableElements[ elementIdx ];
|
USB_HID_Report_Element_t element = *hidConfigurableElements[ elementIdx ];
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
|
|
||||||
unsigned bBit = hidGetElementBitLocation( element.location );
|
unsigned bBit = hidGetElementBitLocation( element.location );
|
||||||
unsigned bByte = hidGetElementByteLocation( element.location );
|
unsigned bByte = hidGetElementByteLocation( element.location );
|
||||||
unsigned bId = hidGetElementReportId( element.location );
|
unsigned bId = hidGetElementReportId( element.location );
|
||||||
@@ -501,7 +569,9 @@ unsigned hidSetReportItem(
|
|||||||
element.item.data[ dataIdx ] = 0U;
|
element.item.data[ dataIdx ] = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
*hidConfigurableElements[ elementIdx ] = element;
|
*hidConfigurableElements[ elementIdx ] = element;
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
retVal = HID_STATUS_GOOD;
|
retVal = HID_STATUS_GOOD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -510,18 +580,19 @@ unsigned hidSetReportItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hidSetReportPeriod( const unsigned id, const unsigned period )
|
void hidSetReportPeriod( const unsigned id, const unsigned period )
|
||||||
{
|
{
|
||||||
|
swlock_acquire(hidStaticVarLock);
|
||||||
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
for( size_t idx = 0U; idx < HID_REPORT_COUNT; ++idx) {
|
||||||
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
if( id == hidGetElementReportId( hidReports[ idx ]->location )) {
|
||||||
s_hidCurrentPeriod[ idx ] = period;
|
s_hidCurrentPeriod[ idx ] = period;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
swlock_release(hidStaticVarLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t hidTranslateItem( const USB_HID_Short_Item_t* inPtr, unsigned char** outPtrPtr )
|
static size_t hidTranslateItem( const USB_HID_Short_Item_t* inPtr, unsigned char** outPtrPtr )
|
||||||
|
|||||||
Reference in New Issue
Block a user