Reset UsbReportUpdateSemaphore if it gets stuck for 100ms. This should fix occasional freezes.
This commit is contained in:
@@ -440,14 +440,21 @@ uint32_t UsbReportUpdateCounter;
|
|||||||
|
|
||||||
void UpdateUsbReports(void)
|
void UpdateUsbReports(void)
|
||||||
{
|
{
|
||||||
|
static uint32_t lastUpdateTime;
|
||||||
|
|
||||||
for (uint8_t keyId = 0; keyId < RIGHT_KEY_MATRIX_KEY_COUNT; keyId++) {
|
for (uint8_t keyId = 0; keyId < RIGHT_KEY_MATRIX_KEY_COUNT; keyId++) {
|
||||||
KeyStates[SlotId_RightKeyboardHalf][keyId].current = RightKeyMatrix.keyStates[keyId];
|
KeyStates[SlotId_RightKeyboardHalf][keyId].current = RightKeyMatrix.keyStates[keyId];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UsbReportUpdateSemaphore && !SleepModeActive) {
|
if (UsbReportUpdateSemaphore && !SleepModeActive) {
|
||||||
return;
|
if (Timer_GetElapsedTime(&lastUpdateTime) < USB_SEMAPHORE_TIMEOUT) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
UsbReportUpdateSemaphore = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastUpdateTime = CurrentTime;
|
||||||
UsbReportUpdateCounter++;
|
UsbReportUpdateCounter++;
|
||||||
|
|
||||||
ResetActiveUsbBasicKeyboardReport();
|
ResetActiveUsbBasicKeyboardReport();
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#define SECONDARY_ROLE_MODIFIER_TO_HID_MODIFIER(secondaryRoleModifier) (1 << ((secondaryRoleModifier) - 1))
|
#define SECONDARY_ROLE_MODIFIER_TO_HID_MODIFIER(secondaryRoleModifier) (1 << ((secondaryRoleModifier) - 1))
|
||||||
#define SECONDARY_ROLE_LAYER_TO_LAYER_ID(secondaryRoleLayer) ((secondaryRoleLayer) - SecondaryRole_RightSuper)
|
#define SECONDARY_ROLE_LAYER_TO_LAYER_ID(secondaryRoleLayer) ((secondaryRoleLayer) - SecondaryRole_RightSuper)
|
||||||
|
|
||||||
|
#define USB_SEMAPHORE_TIMEOUT 100 // ms
|
||||||
|
|
||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
Reference in New Issue
Block a user