diff --git a/lib/KSDK_2.0_MK22FN512xxx12 b/lib/KSDK_2.0_MK22FN512xxx12 index 69affcf..bc5aeb5 160000 --- a/lib/KSDK_2.0_MK22FN512xxx12 +++ b/lib/KSDK_2.0_MK22FN512xxx12 @@ -1 +1 @@ -Subproject commit 69affcfe62cdabd8e95a96da6f3e0d6a21cf12ea +Subproject commit bc5aeb58ee69fc59115cbfb034f8a1075956504e diff --git a/right/src/init_peripherials.c b/right/src/init_peripherials.c index 01ef755..20674ad 100644 --- a/right/src/init_peripherials.c +++ b/right/src/init_peripherials.c @@ -46,25 +46,23 @@ void InitI2c() { } /* 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 restartI2C(void) { - extern uint32_t I2C_Watchdog; - volatile uint32_t temp, counter; - uint32_t sourceClock; + extern uint32_t I2C_Watchdog; + volatile uint32_t temp, counter; + uint32_t sourceClock; i2c_master_config_t masterConfig; - temp = I2C_Watchdog; // We take the current value of I2C counter - for (counter = 0; counter < 10000000; counter++); // This can also be changed for 1 sec delay using PIT + temp = I2C_Watchdog; // We take the current value of I2C counter + for (counter=0; counter<10000000; counter++); // This can also be changed for 1 sec delay using PIT - if (I2C_Watchdog == temp) { // Restart I2C if there hasn't be any interrupt during 1 sec - I2C_MasterGetDefaultConfig(&masterConfig); - - I2C_MasterDeinit(I2C_MAIN_BUS_BASEADDR); - sourceClock = CLOCK_GetFreq(I2C_MASTER_BUS_CLK_SRC); - I2C_MasterInit(I2C_MAIN_BUS_BASEADDR, &masterConfig, sourceClock); - InitBridgeProtocolScheduler(); - } + if (I2C_Watchdog == temp) { // Restart I2C if there hasn't be any interrupt during 1 sec + I2C_MasterGetDefaultConfig(&masterConfig); + I2C_MasterDeinit(I2C_MAIN_BUS_BASEADDR); + sourceClock = CLOCK_GetFreq(I2C_MASTER_BUS_CLK_SRC); + I2C_MasterInit(I2C_MAIN_BUS_BASEADDR, &masterConfig, sourceClock); + InitBridgeProtocolScheduler(); + } } void InitPeripherials(void) diff --git a/right/src/init_peripherials.h b/right/src/init_peripherials.h index 47105db..4ea38a1 100644 --- a/right/src/init_peripherials.h +++ b/right/src/init_peripherials.h @@ -3,9 +3,13 @@ #include "fsl_common.h" +// Variables: + + uint32_t I2C_Watchdog = 0; + // Functions: void InitPeripherials(); void restartI2C(); - uint32_t I2C_Watchdog = 0; + #endif diff --git a/right/src/main.c b/right/src/main.c index 1f36ac0..b4b813f 100644 --- a/right/src/main.c +++ b/right/src/main.c @@ -8,7 +8,6 @@ #include "bridge_protocol_scheduler.h" #include "test_led.h" - key_matrix_t KeyMatrix = { .colNum = KEYBOARD_MATRIX_COLS_NUM, .rowNum = KEYBOARD_MATRIX_ROWS_NUM, @@ -81,8 +80,6 @@ void UpdateUsbReports() } void main() { - - InitPeripherials(); InitClock(); LedDriver_InitAllLeds(1); @@ -95,7 +92,7 @@ void main() { while (1) { //UpdateUsbReports(); - restartI2C(); + restartI2C(); asm("wfi"); } }