Skip to content

Instantly share code, notes, and snippets.

@drashna
Created May 28, 2025 02:52
Show Gist options
  • Save drashna/e9b6dd56458071fafe1468aa672a816a to your computer and use it in GitHub Desktop.
Save drashna/e9b6dd56458071fafe1468aa672a816a to your computer and use it in GitHub Desktop.
#ifndef I2C_DRIVER
# define I2C_DRIVER I2CD1
#endif
// ...
if (io_expander_ready()) {
// If we managed to initialize the mcp23018 - we need to reinitialize the matrix / layer state. During an electric discharge the i2c peripherals might be in a weird state. Giving a delay and resetting the MCU allows to recover from this.
mcp23018_reset_loop = 0;
mcp23018_errors = 0;
i2cStop(I2C_DRIVER);
wait_ms(10);
#ifdef RGB_MATRIX_ENABLE
rgb_matrix_init();
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment