Use a semaphore to control the rate at which reports are updated

This commit is contained in:
Eric Tang
2018-06-27 22:57:07 -07:00
parent 6eceb6ad30
commit 4214f3e0b6
6 changed files with 36 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
#include "led_display.h"
#include "usb_composite_device.h"
#include "usb_report_updater.h"
static usb_basic_keyboard_report_t usbBasicKeyboardReports[2];
uint32_t UsbBasicKeyboardActionCounter;
@@ -40,6 +41,8 @@ usb_status_t UsbBasicKeyboardCallback(class_handle_t handle, uint32_t event, voi
switch (event) {
// This report is received when the report has been sent
case kUSB_DeviceHidEventSendResponse:
UsbReportUpdateSemaphore &= ~(1 << USB_BASIC_KEYBOARD_INTERFACE_INDEX);
break;
case kUSB_DeviceHidEventRecvResponse:
case kUSB_DeviceHidEventGetReport:
break;

View File

@@ -1,4 +1,5 @@
#include "usb_composite_device.h"
#include "usb_report_updater.h"
uint32_t UsbMediaKeyboardActionCounter;
static usb_media_keyboard_report_t usbMediaKeyboardReports[2];
@@ -38,6 +39,8 @@ usb_status_t UsbMediaKeyboardCallback(class_handle_t handle, uint32_t event, voi
switch (event) {
// This report is received when the report has been sent
case kUSB_DeviceHidEventSendResponse:
UsbReportUpdateSemaphore &= ~(1 << USB_MEDIA_KEYBOARD_INTERFACE_INDEX);
break;
case kUSB_DeviceHidEventRecvResponse:
case kUSB_DeviceHidEventGetReport:
case kUSB_DeviceHidEventSetReport:

View File

@@ -1,4 +1,5 @@
#include "usb_composite_device.h"
#include "usb_report_updater.h"
uint32_t UsbMouseActionCounter;
static usb_mouse_report_t usbMouseReports[2];
@@ -38,6 +39,8 @@ usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param
switch (event) {
// This report is received when the report has been sent
case kUSB_DeviceHidEventSendResponse:
UsbReportUpdateSemaphore &= ~(1 << USB_MOUSE_INTERFACE_INDEX);
break;
case kUSB_DeviceHidEventRecvResponse:
case kUSB_DeviceHidEventGetReport:
case kUSB_DeviceHidEventSetReport:

View File

@@ -1,4 +1,5 @@
#include "usb_composite_device.h"
#include "usb_report_updater.h"
uint32_t UsbSystemKeyboardActionCounter;
static usb_system_keyboard_report_t usbSystemKeyboardReports[2];
@@ -38,6 +39,8 @@ usb_status_t UsbSystemKeyboardCallback(class_handle_t handle, uint32_t event, vo
switch (event) {
// This report is received when the report has been sent
case kUSB_DeviceHidEventSendResponse:
UsbReportUpdateSemaphore &= ~(1 << USB_SYSTEM_KEYBOARD_INTERFACE_INDEX);
break;
case kUSB_DeviceHidEventRecvResponse:
case kUSB_DeviceHidEventGetReport:
case kUSB_DeviceHidEventSetReport: