Add I2C_WatchdogOuterCounter, I2C_WatchdogInnerCounter, BridgeCounter and expose them via USB getDebugInfo()
This commit is contained in:
@@ -10,12 +10,16 @@
|
|||||||
#define PIT_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_BusClk)
|
#define PIT_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_BusClk)
|
||||||
|
|
||||||
static uint32_t prevWatchdogCounter = 0;
|
static uint32_t prevWatchdogCounter = 0;
|
||||||
|
uint32_t I2C_WatchdogInnerCounter;
|
||||||
|
uint32_t I2C_WatchdogOuterCounter;
|
||||||
|
|
||||||
// This function is designed to restart and reinstall the I2C handler
|
// This function is designed to restart and reinstall the I2C handler
|
||||||
// when a disconnection of the left side makes the master I2C bus unresponsive.
|
// when a disconnection of the left side makes the master I2C bus unresponsive.
|
||||||
void PIT_I2C_WATCHDOG_HANDLER(void)
|
void PIT_I2C_WATCHDOG_HANDLER(void)
|
||||||
{
|
{
|
||||||
|
I2C_WatchdogOuterCounter++;
|
||||||
if (I2C_Watchdog == prevWatchdogCounter) { // Restart I2C if there hasn't be any interrupt during 1 sec
|
if (I2C_Watchdog == prevWatchdogCounter) { // Restart I2C if there hasn't be any interrupt during 1 sec
|
||||||
|
I2C_WatchdogInnerCounter++;
|
||||||
i2c_master_config_t masterConfig;
|
i2c_master_config_t masterConfig;
|
||||||
I2C_MasterGetDefaultConfig(&masterConfig);
|
I2C_MasterGetDefaultConfig(&masterConfig);
|
||||||
I2C_MasterDeinit(I2C_MAIN_BUS_BASEADDR);
|
I2C_MasterDeinit(I2C_MAIN_BUS_BASEADDR);
|
||||||
|
|||||||
@@ -4,5 +4,6 @@
|
|||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
extern void InitI2cWatchdog();
|
extern void InitI2cWatchdog();
|
||||||
|
extern uint32_t I2C_WatchdogInnerCounter;
|
||||||
|
extern uint32_t I2C_WatchdogOuterCounter;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
uint8_t previousSlaveId = 0;
|
uint8_t previousSlaveId = 0;
|
||||||
uint8_t currentSlaveId = 0;
|
uint8_t currentSlaveId = 0;
|
||||||
|
uint32_t BridgeCounter;
|
||||||
|
|
||||||
uhk_slave_t Slaves[] = {
|
uhk_slave_t Slaves[] = {
|
||||||
{ .initializer = UhkModuleSlaveDriver_Init, .updater = UhkModuleSlaveDriver_Update, .perDriverId = UhkModuleId_LeftKeyboardHalf },
|
{ .initializer = UhkModuleSlaveDriver_Init, .updater = UhkModuleSlaveDriver_Update, .perDriverId = UhkModuleId_LeftKeyboardHalf },
|
||||||
@@ -22,6 +23,7 @@ static void bridgeProtocolCallback(I2C_Type *base, i2c_master_handle_t *handle,
|
|||||||
IsI2cTransferScheduled = false;
|
IsI2cTransferScheduled = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
BridgeCounter++;
|
||||||
if (TestStates.disableI2c) {
|
if (TestStates.disableI2c) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -36,6 +38,9 @@ static void bridgeProtocolCallback(I2C_Type *base, i2c_master_handle_t *handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentSlave->updater(currentSlave->perDriverId);
|
currentSlave->updater(currentSlave->perDriverId);
|
||||||
|
if (IsI2cTransferScheduled) {
|
||||||
|
currentSlave->isConnected = true;
|
||||||
|
}
|
||||||
|
|
||||||
previousSlaveId = currentSlaveId;
|
previousSlaveId = currentSlaveId;
|
||||||
currentSlaveId++;
|
currentSlaveId++;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern uhk_slave_t Slaves[];
|
extern uhk_slave_t Slaves[];
|
||||||
|
extern uint32_t BridgeCounter;
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
#include "keymaps.h"
|
#include "keymaps.h"
|
||||||
#include "microseconds/microseconds_pit.c"
|
#include "microseconds/microseconds_pit.c"
|
||||||
|
#include "i2c_watchdog.h"
|
||||||
// Functions for setting error statuses
|
// Functions for setting error statuses
|
||||||
|
|
||||||
void setError(uint8_t error)
|
void setError(uint8_t error)
|
||||||
@@ -206,6 +206,21 @@ void getDebugInfo(void)
|
|||||||
GenericHidOutBuffer[3] = I2C_Watchdog >> 16;
|
GenericHidOutBuffer[3] = I2C_Watchdog >> 16;
|
||||||
GenericHidOutBuffer[4] = I2C_Watchdog >> 24;
|
GenericHidOutBuffer[4] = I2C_Watchdog >> 24;
|
||||||
|
|
||||||
|
GenericHidOutBuffer[5] = BridgeCounter >> 0;
|
||||||
|
GenericHidOutBuffer[6] = BridgeCounter >> 8;
|
||||||
|
GenericHidOutBuffer[7] = BridgeCounter >> 16;
|
||||||
|
GenericHidOutBuffer[8] = BridgeCounter >> 24;
|
||||||
|
|
||||||
|
GenericHidOutBuffer[9] = I2C_WatchdogOuterCounter >> 0;
|
||||||
|
GenericHidOutBuffer[10] = I2C_WatchdogOuterCounter >> 8;
|
||||||
|
GenericHidOutBuffer[11] = I2C_WatchdogOuterCounter >> 16;
|
||||||
|
GenericHidOutBuffer[12] = I2C_WatchdogOuterCounter >> 24;
|
||||||
|
|
||||||
|
GenericHidOutBuffer[13] = I2C_WatchdogInnerCounter >> 0;
|
||||||
|
GenericHidOutBuffer[14] = I2C_WatchdogInnerCounter >> 8;
|
||||||
|
GenericHidOutBuffer[15] = I2C_WatchdogInnerCounter >> 16;
|
||||||
|
GenericHidOutBuffer[16] = I2C_WatchdogInnerCounter >> 24;
|
||||||
|
/*
|
||||||
uint64_t ticks = microseconds_get_ticks();
|
uint64_t ticks = microseconds_get_ticks();
|
||||||
uint32_t microseconds = microseconds_convert_to_microseconds(ticks);
|
uint32_t microseconds = microseconds_convert_to_microseconds(ticks);
|
||||||
uint32_t milliseconds = microseconds/1000;
|
uint32_t milliseconds = microseconds/1000;
|
||||||
@@ -218,7 +233,7 @@ void getDebugInfo(void)
|
|||||||
GenericHidOutBuffer[6] = (ticks >> 40) & 0xff;
|
GenericHidOutBuffer[6] = (ticks >> 40) & 0xff;
|
||||||
GenericHidOutBuffer[7] = (ticks >> 48) & 0xff;
|
GenericHidOutBuffer[7] = (ticks >> 48) & 0xff;
|
||||||
GenericHidOutBuffer[8] = (ticks >> 56) & 0xff;
|
GenericHidOutBuffer[8] = (ticks >> 56) & 0xff;
|
||||||
}
|
*/}
|
||||||
|
|
||||||
// The main protocol handler function
|
// The main protocol handler function
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user