Expose per-interface count values for debugging purposes via USB.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
#include "fsl_pit.h"
|
||||
#include "key_scanner.h"
|
||||
|
||||
uint32_t KeyScannerCounter;
|
||||
|
||||
void PIT_KEY_SCANNER_HANDLER(void)
|
||||
{
|
||||
KeyMatrix_ScanRow(&RightKeyMatrix);
|
||||
KeyScannerCounter++;
|
||||
PIT_ClearStatusFlags(PIT, PIT_KEY_SCANNER_CHANNEL, PIT_TFLG_TIF_MASK);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#define KEY_SCANNER_INTERVAL_USEC (1000 / RIGHT_KEY_MATRIX_ROWS_NUM)
|
||||
|
||||
// Variables:
|
||||
|
||||
extern uint32_t KeyScannerCounter;
|
||||
|
||||
// Functions:
|
||||
|
||||
void InitKeyScanner(void);
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
#include "i2c_watchdog.h"
|
||||
#include "buffer.h"
|
||||
#include "timer.h"
|
||||
#include "key_scanner.h"
|
||||
#include "usb_report_updater.h"
|
||||
#include "usb_interfaces/usb_interface_basic_keyboard.h"
|
||||
#include "usb_interfaces/usb_interface_media_keyboard.h"
|
||||
#include "usb_interfaces/usb_interface_system_keyboard.h"
|
||||
#include "usb_interfaces/usb_interface_mouse.h"
|
||||
|
||||
uint8_t DebugBuffer[USB_GENERIC_HID_OUT_BUFFER_LENGTH];
|
||||
|
||||
@@ -14,7 +20,14 @@ void UsbCommand_GetDebugBuffer(void)
|
||||
SetDebugBufferUint32(5, I2cSlaveScheduler_Counter);
|
||||
SetDebugBufferUint32(9, I2cWatchdog_WatchCounter);
|
||||
SetDebugBufferUint32(13, I2cWatchdog_RecoveryCounter);
|
||||
SetDebugBufferUint32(40, CurrentTime);
|
||||
SetDebugBufferUint32(17, KeyScannerCounter);
|
||||
SetDebugBufferUint32(21, UsbReportUpdateCounter);
|
||||
SetDebugBufferUint32(25, CurrentTime);
|
||||
SetDebugBufferUint32(29, UsbGenericHidActionCounter);
|
||||
SetDebugBufferUint32(33, UsbBasicKeyboardActionCounter);
|
||||
SetDebugBufferUint32(37, UsbMediaKeyboardActionCounter);
|
||||
SetDebugBufferUint32(41, UsbSystemKeyboardActionCounter);
|
||||
SetDebugBufferUint32(45, UsbMouseActionCounter);
|
||||
|
||||
memcpy(GenericHidOutBuffer, DebugBuffer, USB_GENERIC_HID_OUT_BUFFER_LENGTH);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ usb_device_class_struct_t UsbBasicKeyboardClass = {
|
||||
};
|
||||
|
||||
static usb_basic_keyboard_report_t usbBasicKeyboardReports[2];
|
||||
uint32_t UsbBasicKeyboardActionCounter;
|
||||
usb_basic_keyboard_report_t* ActiveUsbBasicKeyboardReport = usbBasicKeyboardReports;
|
||||
bool IsUsbBasicKeyboardReportSent = false;
|
||||
|
||||
@@ -64,6 +65,7 @@ static usb_status_t UsbBasicKeyboardAction(void)
|
||||
UsbCompositeDevice.basicKeyboardHandle, USB_BASIC_KEYBOARD_ENDPOINT_INDEX,
|
||||
(uint8_t*)getInactiveUsbBasicKeyboardReport(), USB_BASIC_KEYBOARD_REPORT_LENGTH);
|
||||
IsUsbBasicKeyboardReportSent = true;
|
||||
UsbBasicKeyboardActionCounter++;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
// Variables:
|
||||
|
||||
extern bool IsUsbBasicKeyboardReportSent;
|
||||
extern uint32_t UsbBasicKeyboardActionCounter;
|
||||
extern usb_device_class_struct_t UsbBasicKeyboardClass;
|
||||
extern usb_basic_keyboard_report_t* ActiveUsbBasicKeyboardReport;
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ usb_device_class_struct_t UsbGenericHidClass = {
|
||||
USB_DEVICE_CONFIGURATION_COUNT,
|
||||
};
|
||||
|
||||
uint32_t UsbGenericHidActionCounter;
|
||||
uint8_t GenericHidInBuffer[USB_GENERIC_HID_IN_BUFFER_LENGTH];
|
||||
uint8_t GenericHidOutBuffer[USB_GENERIC_HID_OUT_BUFFER_LENGTH];
|
||||
|
||||
@@ -67,6 +68,7 @@ usb_status_t UsbGenericHidCallback(class_handle_t handle, uint32_t event, void *
|
||||
USB_GENERIC_HID_ENDPOINT_IN_INDEX,
|
||||
GenericHidOutBuffer,
|
||||
USB_GENERIC_HID_OUT_BUFFER_LENGTH);
|
||||
UsbGenericHidActionCounter++;
|
||||
return UsbReceiveData();
|
||||
break;
|
||||
case kUSB_DeviceHidEventGetReport:
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
// Variables:
|
||||
|
||||
extern usb_device_class_struct_t UsbGenericHidClass;
|
||||
extern uint32_t UsbGenericHidActionCounter;
|
||||
extern uint8_t GenericHidInBuffer[USB_GENERIC_HID_IN_BUFFER_LENGTH];
|
||||
extern uint8_t GenericHidOutBuffer[USB_GENERIC_HID_OUT_BUFFER_LENGTH];
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ usb_device_class_struct_t UsbMediaKeyboardClass = {
|
||||
USB_DEVICE_CONFIGURATION_COUNT,
|
||||
};
|
||||
|
||||
uint32_t UsbMediaKeyboardActionCounter;
|
||||
static usb_media_keyboard_report_t usbMediaKeyboardReports[2];
|
||||
usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport = usbMediaKeyboardReports;
|
||||
bool IsUsbMediaKeyboardReportSent = false;
|
||||
@@ -64,6 +65,7 @@ static usb_status_t UsbMediaKeyboardAction(void)
|
||||
UsbCompositeDevice.mediaKeyboardHandle, USB_MEDIA_KEYBOARD_ENDPOINT_INDEX,
|
||||
(uint8_t*)getInactiveUsbMediaKeyboardReport(), USB_MEDIA_KEYBOARD_REPORT_LENGTH);
|
||||
IsUsbMediaKeyboardReportSent = true;
|
||||
UsbMediaKeyboardActionCounter++;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
// Variables:
|
||||
|
||||
extern bool IsUsbMediaKeyboardReportSent;
|
||||
extern uint32_t UsbMediaKeyboardActionCounter;
|
||||
extern usb_device_class_struct_t UsbMediaKeyboardClass;
|
||||
extern usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ usb_device_class_struct_t UsbMouseClass = {
|
||||
USB_DEVICE_CONFIGURATION_COUNT,
|
||||
};
|
||||
|
||||
uint32_t UsbMouseActionCounter;
|
||||
usb_mouse_report_t usbMouseReports[2];
|
||||
usb_mouse_report_t* ActiveUsbMouseReport = usbMouseReports;
|
||||
bool IsUsbMouseReportSent = false;
|
||||
@@ -58,16 +59,11 @@ void ResetActiveUsbMouseReport(void)
|
||||
bzero(ActiveUsbMouseReport, USB_MOUSE_REPORT_LENGTH);
|
||||
}
|
||||
|
||||
static uint32_t count1 = 0;
|
||||
static uint32_t count2 = 0;
|
||||
static uint32_t count3 = 0;
|
||||
|
||||
static volatile usb_status_t usbMouseAction(void)
|
||||
{
|
||||
count3++;
|
||||
usb_mouse_report_t *mouseReport = getInactiveUsbMouseReport();
|
||||
SetDebugBufferUint16(29, mouseReport->x);
|
||||
SetDebugBufferUint16(31, mouseReport->y);
|
||||
SetDebugBufferUint16(61, mouseReport->x);
|
||||
SetDebugBufferUint16(63, mouseReport->y);
|
||||
IsUsbMouseReportSent = true;
|
||||
return USB_DeviceHidSend(UsbCompositeDevice.mouseHandle, USB_MOUSE_ENDPOINT_INDEX,
|
||||
(uint8_t*)mouseReport, USB_MOUSE_REPORT_LENGTH);
|
||||
@@ -75,17 +71,11 @@ static volatile usb_status_t usbMouseAction(void)
|
||||
|
||||
usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param)
|
||||
{
|
||||
SetDebugBufferUint32(17, count1);
|
||||
SetDebugBufferUint32(21, count2);
|
||||
SetDebugBufferUint32(25, count3);
|
||||
|
||||
count1++;
|
||||
|
||||
UsbMouseActionCounter++;
|
||||
usb_status_t error = kStatus_USB_Error;
|
||||
|
||||
switch (event) {
|
||||
case kUSB_DeviceHidEventSendResponse:
|
||||
count2++;
|
||||
if (UsbCompositeDevice.attach) {
|
||||
return usbMouseAction();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
// Variables:
|
||||
|
||||
extern bool IsUsbMouseReportSent;
|
||||
extern uint32_t UsbMouseActionCounter;
|
||||
extern usb_device_class_struct_t UsbMouseClass;
|
||||
extern usb_mouse_report_t* ActiveUsbMouseReport;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ usb_device_class_struct_t UsbSystemKeyboardClass = {
|
||||
USB_DEVICE_CONFIGURATION_COUNT,
|
||||
};
|
||||
|
||||
uint32_t UsbSystemKeyboardActionCounter;
|
||||
static usb_system_keyboard_report_t usbSystemKeyboardReports[2];
|
||||
usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport = usbSystemKeyboardReports;
|
||||
bool IsUsbSystemKeyboardReportSent = false;
|
||||
@@ -64,6 +65,7 @@ static usb_status_t UsbSystemKeyboardAction(void)
|
||||
UsbCompositeDevice.systemKeyboardHandle, USB_SYSTEM_KEYBOARD_ENDPOINT_INDEX,
|
||||
(uint8_t*)getInactiveUsbSystemKeyboardReport(), USB_SYSTEM_KEYBOARD_REPORT_LENGTH);
|
||||
IsUsbSystemKeyboardReportSent = true;
|
||||
UsbSystemKeyboardActionCounter++;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
// Variables:
|
||||
|
||||
extern bool IsUsbSystemKeyboardReportSent;
|
||||
extern uint32_t UsbSystemKeyboardActionCounter;
|
||||
extern usb_device_class_struct_t UsbSystemKeyboardClass;
|
||||
extern usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport;
|
||||
|
||||
|
||||
@@ -230,8 +230,10 @@ static uint8_t secondaryRoleSlotId;
|
||||
static uint8_t secondaryRoleKeyId;
|
||||
static secondary_role_t secondaryRole;
|
||||
|
||||
#define pos 35
|
||||
void updateActiveUsbReports(void)
|
||||
{
|
||||
SetDebugBufferUint32(pos, 1);
|
||||
memset(activeMouseStates, 0, ACTIVE_MOUSE_STATES_COUNT);
|
||||
|
||||
static uint8_t previousModifiers = 0;
|
||||
@@ -263,6 +265,7 @@ void updateActiveUsbReports(void)
|
||||
memcpy(&ActiveUsbSystemKeyboardReport, &MacroSystemKeyboardReport, sizeof MacroSystemKeyboardReport);
|
||||
return;
|
||||
}
|
||||
SetDebugBufferUint32(pos, 2);
|
||||
|
||||
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
||||
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
||||
@@ -316,8 +319,10 @@ void updateActiveUsbReports(void)
|
||||
keyState->previous = keyState->current;
|
||||
}
|
||||
}
|
||||
SetDebugBufferUint32(pos, 4);
|
||||
|
||||
processMouseActions();
|
||||
SetDebugBufferUint32(pos, 5);
|
||||
|
||||
// When a layer switcher key gets pressed along with another key that produces some modifiers
|
||||
// and the accomanying key gets released then keep the related modifiers active a long as the
|
||||
@@ -332,6 +337,7 @@ void updateActiveUsbReports(void)
|
||||
|
||||
previousModifiers = ActiveUsbBasicKeyboardReport->modifiers;
|
||||
previousLayer = activeLayer;
|
||||
SetDebugBufferUint32(pos, 7);
|
||||
}
|
||||
|
||||
bool UsbBasicKeyboardReportEverSent = false;
|
||||
@@ -339,8 +345,12 @@ bool UsbMediaKeyboardReportEverSent = false;
|
||||
bool UsbSystemKeyboardReportEverSent = false;
|
||||
bool UsbMouseReportEverSentEverSent = false;
|
||||
|
||||
uint32_t UsbReportUpdateCounter;
|
||||
|
||||
void UpdateUsbReports(void)
|
||||
{
|
||||
UsbReportUpdateCounter++;
|
||||
|
||||
if (IsUsbBasicKeyboardReportSent) {
|
||||
UsbBasicKeyboardReportEverSent = true;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
extern uint16_t DoubleTapSwitchLayerTimeout;
|
||||
extern mouse_kinetic_state_t MouseMoveState;
|
||||
extern mouse_kinetic_state_t MouseScrollState;
|
||||
extern uint32_t UsbReportUpdateCounter;
|
||||
|
||||
// Functions:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user