59 #define DEFAULT_IDLE_RATE 500
108 static uint32_t tmpBuffer;
109 static uint8_t idleRate;
110 static void *hidDescriptor = NULL;
121 static
bool QueueEmpty(
void );
122 static
bool QueueFull(
void );
124 static
void QueueInit(
void );
134 static
void IdleTimeout(
void )
141 QueueGet( &lastSentReport );
144 USBD_Write( HIDKBD_INTR_IN_EP_ADDR, &lastSentReport,
170 && ( setReportFunc != NULL ) )
172 setReportFunc( (uint8_t)tmpBuffer );
204 lastKnownReport = *report;
214 lastSentReport = *report;
215 USBD_Write( HIDKBD_INTR_IN_EP_ADDR, &lastSentReport,
250 USBD_Write( 0, (
void*)HIDKBD_ReportDescriptor,
269 ( setup->
wIndex == HIDKBD_INTERFACE_NO ) )
276 if ( ( ( setup->
wValue >> 8 ) == 2 ) &&
277 ( ( setup->
wValue & 0xFF ) == 0 ) &&
281 USBD_Read( 0, (
void*)&tmpBuffer, 1, OutputReportReceived );
288 if ( ( ( setup->
wValue >> 8 ) == 1 ) &&
289 ( ( setup->
wValue & 0xFF ) == 0 ) &&
293 USBD_Write( HIDKBD_INTR_IN_EP_ADDR, &lastKnownReport,
301 if ( ( ( setup->
wValue & 0xFF) == 0 ) &&
305 idleRate = setup->
wValue >> 8;
306 if ( ( idleRate != 0 ) && ( idleRate < ( HIDKBD_POLL_RATE / 4 ) ) )
308 idleRate = HIDKBD_POLL_RATE / 4;
321 if ( ( setup->
wValue == 0 ) &&
325 *(uint8_t*)&tmpBuffer = idleRate;
380 #define QUEUE_SIZE 16
382 typedef struct ringBuffer_t
391 static bool QueueEmpty(
void )
393 return ( queue.putIdx - queue.getIdx ) == 0;
396 static bool QueueFull(
void )
398 return ( queue.putIdx - queue.getIdx ) >= QUEUE_SIZE;
405 *element = queue.buf[ queue.getIdx++ & (QUEUE_SIZE - 1) ];
406 queue.getIdx = ( queue.getIdx + 1 ) % QUEUE_SIZE;
412 static void QueueInit(
void )
422 queue.buf[ queue.putIdx++ & (QUEUE_SIZE - 1) ] = *element;
423 queue.putIdx = ( queue.putIdx + 1 ) % QUEUE_SIZE;
void USBTIMER_Stop(uint32_t id)
Stop a timer.
HIDKBD_SetReportFunc_t setReportFunc
#define DEFAULT_IDLE_RATE
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define SL_ALIGN(X)
Macro for aligning a variable. Use this macro before the variable definition. X denotes the stora...
void HIDKBD_StateChangeEvent(USBD_State_TypeDef oldState, USBD_State_TypeDef newState)
Handle USB state change events, this function must be called each time the USB device state is change...
General purpose utilities.
#define USB_HID_SET_REPORT
USB Setup request package.
const char HIDKBD_ReportDescriptor[69] SL_ATTRIBUTE_ALIGN(4)
USBD_State_TypeDef
USB device state enumerator.
USB_Status_TypeDef
USB transfer status enumerator.
#define USB_HID_REPORT_DESCRIPTOR
int HIDKBD_SetupCmd(const USB_Setup_TypeDef *setup)
Handle USB setup commands. Implements HID class specific commands. This function must be called each ...
void HIDKBD_Init(HIDKBD_Init_t *init)
Initialize HID Keyboard driver.
USB protocol stack library API for EFM32/EZR32.
#define USB_SETUP_RECIPIENT_INTERFACE
#define USB_SETUP_TYPE_STANDARD
#define USB_HID_GET_REPORT
void(* HIDKBD_SetReportFunc_t)(uint8_t report)
Callback function pointer for HID output reports. This function will be called by the driver each tim...
int USBD_Write(int epAddr, void *data, int byteCount, USB_XferCompleteCb_TypeDef callback)
Start a write (IN) transfer on an endpoint.
void HIDKBD_KeyboardEvent(HIDKBD_KeyReport_t *report)
Report a keyboard press/release event.
#define SL_MIN(a, b)
Macro for getting minimum value. No sideeffects, a and b are evaluated once only. ...
#define USB_HID_DESCRIPTOR
#define USB_SETUP_TYPE_CLASS
void USBTIMER_Start(uint32_t id, uint32_t timeout, USBTIMER_Callback_TypeDef callback)
Start a timer.
int USBD_Read(int epAddr, void *data, int byteCount, USB_XferCompleteCb_TypeDef callback)
Start a read (OUT) transfer on an endpoint.
#define STATIC_UBUF(x, y)
USB Human Interface Devices (HID) class keyboard driver.