Merge pull request #111 from mbanth/feature/hid_4bit_reliance_jan_demo

Feature/hid 4bit reliance jan demo
This commit is contained in:
Michael Banther
2019-12-19 15:16:01 +00:00
committed by GitHub
6 changed files with 91 additions and 15 deletions

View File

@@ -11,6 +11,8 @@ lib_xua Change Log
microphone operation
* FIXED: Descriptors for XUA_ADAPTIVE incorrectly defined for IN endpoint
* ADDED: Guards to user_hid.h and xua_hid.h
* ADDED: UAC1 HID support for AC Stop (End Call), Volume Increment and
Volume Decrement
0.2.1
-----

View File

@@ -880,7 +880,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
case XUD_SetData_Select(c_hid, ep_hid, result):
{
g_hidData[0]=0;
UserReadHIDData(g_hidData);
g_hidData[0]=UserHIDGetData();
XUD_SetReady_In(ep_hid, g_hidData, 1);
}
break;

View File

@@ -572,10 +572,16 @@ unsigned char hidReportDescriptor[] = /* Voice Command usage as per request #HUT
0xa1, 0x01, /* Collection (Application) */
0x0a, 0x00, 0x02, /* Usage (Generic GUI Application Controls) */
0xa1, 0x02, /* Collection (Logical) */
0x0a, 0x21, 0x02, /* Usage (AC Search) */
0x95, 0x01, /* Report Count (1) */
0x0a, 0x21, 0x02, /* Usage (AC Search) */
0x81, 0x40, /* Input (Data, Ary, Abs, Nul) */
0x95, 0x07, /* Report Count (7) */
0x0a, 0x26, 0x02, /* Usage (AC Stop) */
0x81, 0x40, /* Input (Data, Ary, Abs, Nul) */
0x09, 0xe9, /* Usage (Volume Increment) */
0x81, 0x40, /* Input (Data, Ary, Abs, Nul) */
0x09, 0xea, /* Usage (Volume Decrement) */
0x81, 0x40, /* Input (Data, Ary, Abs, Nul) */
0x95, 0x04, /* Report Count (4) */
0x81, 0x01, /* Input (Cnst, Ary, Abs) */
0xc0, /* End collection (Logical) */
0xc0 /* End collection (Application) */
@@ -2884,7 +2890,7 @@ unsigned char cfgDesc_Audio1[] =
0x00, /* 4 bCountryCode */
0x01, /* 5 bNumDescriptors */
0x22, /* 6 bDescriptorType[0] (Report) */
0x1E, /* 7 wDescriptorLength[0] */
0x2B, /* 7 wDescriptorLength[0] */
0x00, /* 8 wDescriptorLength[0] */
/* HID Endpoint descriptor (IN) */

View File

@@ -3,21 +3,49 @@
#ifndef __USER_HID_H__
#define __USER_HID_H__
/* These defines relate to the HID report desc - do not mod */
#define HID_CONTROL_PLAYPAUSE_SHIFT 0x00
#define HID_CONTROL_NEXT_SHIFT 0x01
#define HID_CONTROL_PREV_SHIFT 0x02
#define HID_CONTROL_VOLUP_SHIFT 0x03
#define HID_CONTROL_VOLDN_SHIFT 0x04
#define HID_CONTROL_MUTE_SHIFT 0x05
/* These enumerated constants relate to the HID report desc - do not mod */
typedef enum hidEventId_t {
HID_EVENT_ID_GPI0 = 0,
HID_EVENT_ID_GPI1,
HID_EVENT_ID_GPI2,
HID_EVENT_ID_GPI3,
HID_EVENT_ID_EVT0,
HID_EVENT_ID_EVT1,
HID_EVENT_ID_EVT2,
HID_EVENT_ID_EVT3,
HID_EVENT_ID_EVT4,
HID_EVENT_ID_EVT5,
HID_EVENT_ID_EVT6,
HID_EVENT_ID_EVT7,
HID_EVENT_ID_EVT8,
HID_EVENT_ID_EVT9,
HID_EVENT_ID_EVT10,
HID_EVENT_ID_EVT11,
HID_EVENT_ID_EVT12,
HID_EVENT_ID_EVT13,
HID_EVENT_ID_EVT14,
HID_EVENT_ID_EVT15,
HID_EVENT_ID_EVT16,
HID_EVENT_ID_EVT17,
HID_EVENT_ID_EVT18,
HID_EVENT_ID_EVT19,
HID_EVENT_ID_EVT20,
HID_EVENT_ID_EVT21,
HID_EVENT_ID_EVT22,
HID_EVENT_ID_EVT23,
HID_EVENT_ID_EVT24,
HID_EVENT_ID_EVT25,
HID_EVENT_ID_EVT26,
HID_EVENT_ID_EVT27
} hidEventId_t;
#define HID_DATA_SIZE 1
#if( 0 < HID_CONTROLS )
void UserInitHIDData( void );
void UserReadHIDData( unsigned char hidData[ HID_DATA_SIZE ]);
void UserSetHIDData( const unsigned hidData );
unsigned UserHIDGetData( void );
void UserHIDInit( void );
void UserHIDRegisterEvent( const hidEventId_t hidEventId, const int * hidEventData, const unsigned hidEventDataSize );
#endif /* ( 0 < HID_CONTROLS ) */
#endif /* __USER_HID_H__ */

View File

@@ -9,12 +9,17 @@
#if( 0 < HID_CONTROLS )
#define MS_IN_TICKS 100000U
static unsigned s_hidIdleActive = 0U;
static unsigned s_hidChangePending = 0U;
static unsigned s_hidCurrentPeriod = ENDPOINT_INT_INTERVAL_IN_HID * MS_IN_TICKS;
static unsigned s_hidIdleActive = 0U;
static unsigned s_hidIndefiniteDuration = 0U;
static unsigned s_hidNextReportTime = 0U;
static unsigned s_hidReportTime = 0U;
unsafe {
volatile unsigned * unsafe s_hidChangePendingPtr = &s_hidChangePending;
}
static unsigned HidCalcNewReportTime( const unsigned currentPeriod, const unsigned reportTime, const unsigned reportToSetIdleInterval, const unsigned newPeriod );
static unsigned HidCalcReportToSetIdleInterval( const unsigned reportTime );
static unsigned HidFindSetIdleActivationPoint( const unsigned currentPeriod, const unsigned timeWithinPeriod );
@@ -51,6 +56,18 @@ XUD_Result_t HidInterfaceClassRequests(
return result;
}
void HidClearChangePending( void )
{
unsafe {
*s_hidChangePendingPtr = 0U;
}
}
unsigned HidIsChangePending( void )
{
return( s_hidChangePending != 0 );
}
unsigned HidIsSetIdleSilenced( void )
{
unsigned isSilenced = s_hidIdleActive;
@@ -67,6 +84,13 @@ unsigned HidIsSetIdleSilenced( void )
return isSilenced;
}
void HidSetChangePending( void )
{
unsafe {
*s_hidChangePendingPtr = 1;
}
}
/**
* \brief Calculate the timer value for sending the next HID Report.
*

View File

@@ -40,6 +40,17 @@ XUD_Result_t HidInterfaceClassRequests(
XUD_ep c_ep0_in,
REFERENCE_PARAM( USB_SetupPacket_t, sp ));
/**
* \brief Register that previously changed HID Report data has reported
* to the USB Host.
*/
void HidClearChangePending( void );
/**
* \brief Indicate if a change to the HID Report data has been received.
*/
unsigned HidIsChangePending( void );
/**
* \brief Indicate whether to send a HID Report based on elapsed time.
*
@@ -58,4 +69,9 @@ XUD_Result_t HidInterfaceClassRequests(
*/
unsigned HidIsSetIdleSilenced( void );
/**
* \brief Register that a change to the HID Report data has been received.
*/
void HidSetChangePending( void );
#endif // __XUA_HID_H__