diff --git a/right/src/timer.c b/right/src/timer.c index ac96d4c..4106877 100644 --- a/right/src/timer.c +++ b/right/src/timer.c @@ -1,7 +1,7 @@ #include "fsl_pit.h" #include "timer.h" -volatile uint32_t CurrentTime; +static volatile uint32_t CurrentTime; void PIT_TIMER_HANDLER(void) { @@ -24,6 +24,10 @@ void Timer_Init(void) PIT_StartTimer(PIT, PIT_TIMER_CHANNEL); } +uint32_t Timer_GetCurrentTime() { + return CurrentTime; +} + void Timer_SetCurrentTime(uint32_t *time) { *time = CurrentTime; diff --git a/right/src/timer.h b/right/src/timer.h index 69b54bc..1ce3218 100644 --- a/right/src/timer.h +++ b/right/src/timer.h @@ -9,13 +9,10 @@ #define TIMER_INTERVAL_MSEC 1 -// Variables: - - extern volatile uint32_t CurrentTime; - // Functions: void Timer_Init(void); + uint32_t Timer_GetCurrentTime(); void Timer_SetCurrentTime(uint32_t *time); uint32_t Timer_GetElapsedTime(uint32_t *time); uint32_t Timer_GetElapsedTimeAndSetCurrent(uint32_t *time); diff --git a/right/src/usb_commands/usb_command_get_debug_buffer.c b/right/src/usb_commands/usb_command_get_debug_buffer.c index 4439841..92d0073 100644 --- a/right/src/usb_commands/usb_command_get_debug_buffer.c +++ b/right/src/usb_commands/usb_command_get_debug_buffer.c @@ -22,7 +22,7 @@ void UsbCommand_GetDebugBuffer(void) SetDebugBufferUint32(13, I2cWatchdog_RecoveryCounter); SetDebugBufferUint32(17, KeyScannerCounter); SetDebugBufferUint32(21, UsbReportUpdateCounter); - SetDebugBufferUint32(25, CurrentTime); + SetDebugBufferUint32(25, Timer_GetCurrentTime()); SetDebugBufferUint32(29, UsbGenericHidActionCounter); SetDebugBufferUint32(33, UsbBasicKeyboardActionCounter); SetDebugBufferUint32(37, UsbMediaKeyboardActionCounter); diff --git a/right/src/usb_commands/usb_command_get_device_property.c b/right/src/usb_commands/usb_command_get_device_property.c index 62c1e5a..50d67c6 100644 --- a/right/src/usb_commands/usb_command_get_device_property.c +++ b/right/src/usb_commands/usb_command_get_device_property.c @@ -69,7 +69,7 @@ void UsbCommand_GetDeviceProperty(void) SetUsbTxBufferUint32(6, I2cMainBusActualBaudRateBps); break; case DevicePropertyId_Uptime: - SetUsbTxBufferUint32(1, CurrentTime); + SetUsbTxBufferUint32(1, Timer_GetCurrentTime()); break; default: SetUsbTxBufferUint8(0, UsbStatusCode_GetDeviceProperty_InvalidProperty); diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 7fb3eeb..250de4a 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -245,11 +245,11 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action) if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) { if (doubleTapSwitchLayerKey && Timer_GetElapsedTimeAndSetCurrent(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) { ToggledLayer = action->switchLayer.layer; - doubleTapSwitchLayerTriggerTime = CurrentTime; + doubleTapSwitchLayerTriggerTime = Timer_GetCurrentTime(); } else { doubleTapSwitchLayerKey = keyState; } - doubleTapSwitchLayerStartTime = CurrentTime; + doubleTapSwitchLayerStartTime = Timer_GetCurrentTime(); } break; case KeyActionType_SwitchKeymap: