diff --git a/drivers/arm/twi2c.c b/drivers/arm/twi2c.c index c1ab3c6594..7200d2db95 100644 --- a/drivers/arm/twi2c.c +++ b/drivers/arm/twi2c.c @@ -92,7 +92,7 @@ I2CSlaveMsg initialReply = // Response to received messages I2CSlaveMsg echoReply = { /* this is in RAM so size may be updated */ - 0, /* filled in with the length of the message to send */ + MATRIX_ROWS / 2, /* filled in with the length of the message to send */ txBody, /* Response message */ NULL, /* do nothing special on address match */ clearAfterSend, /* Clear receive buffer once replied */ @@ -140,8 +140,8 @@ void twi2c_slave_message_process(I2CDriver *i2cp) { // size_t len = i2cSlaveBytes(i2cp); // Number of bytes received - memset(txBody, 0, MATRIX_ROWS / 2 * sizeof(matrix_row_t)); - // matrix_copy(txBody); + // memset(txBody, 0, MATRIX_ROWS / 2 * sizeof(matrix_row_t)); + matrix_copy(txBody); echoReply.size = MATRIX_ROWS / 2; i2cSlaveReplyI(i2cp, &echoReply); @@ -153,8 +153,8 @@ void twi2c_slave_message_process(I2CDriver *i2cp) { */ void clearAfterSend(I2CDriver *i2cp) { - echoReply.size = 0; // Clear receive message - i2cSlaveReplyI(i2cp, &initialReply); + // echoReply.size = 0; // Clear receive message + // i2cSlaveReplyI(i2cp, &initialReply); } @@ -179,13 +179,16 @@ void twi2c_slave_init(void) { I2C_DRIVER.slaveTimeout = MS2ST(100); // Time for complete message #endif - i2cSlaveConfigure(&I2C_DRIVER, &echoRx, &initialReply); - // i2cSlaveConfigure(&I2C_DRIVER, &echoRx, &echoReply); + // i2cSlaveConfigure(&I2C_DRIVER, &echoRx, &initialReply); + + memset(txBody, 0, MATRIX_ROWS / 2 * sizeof(matrix_row_t)); + + i2cSlaveConfigure(&I2C_DRIVER, &echoRx, &echoReply); // Enable match address after everything else set up - // i2cMatchAddress(&I2C_DRIVER, slaveI2Caddress/2); + i2cMatchAddress(&I2C_DRIVER, slaveI2Caddress/2); // i2cMatchAddress(&I2C_DRIVER, myOtherI2Caddress/2); - i2cMatchAddress(&I2C_DRIVER, 0); /* "all call" */ + // i2cMatchAddress(&I2C_DRIVER, 0); /* "all call" */ printf("Slave I2C started\n\r"); diff --git a/keyboards/_qmk_handwire/matrix.c b/keyboards/_qmk_handwire/matrix.c index a651d33940..499c92f8ca 100644 --- a/keyboards/_qmk_handwire/matrix.c +++ b/keyboards/_qmk_handwire/matrix.c @@ -135,8 +135,8 @@ void matrix_scan_master(void) { msg_t resp; // resp = twi2c_master_send(slaveI2Caddress/2, command, 2, other_matrix, US2ST(100)); - // resp = i2cMasterTransmitTimeout(&I2C_DRIVER, slaveI2Caddress/2, command, 2, other_matrix, MATRIX_ROWS / 2, US2ST(100)); - resp = i2cMasterReceiveTimeout(&I2C_DRIVER, slaveI2Caddress/2, other_matrix, MATRIX_ROWS / 2, US2ST(100)); + resp = i2cMasterTransmitTimeout(&I2C_DRIVER, slaveI2Caddress/2, command, 2, other_matrix, MATRIX_ROWS / 2, MS2ST(100)); + // resp = i2cMasterReceiveTimeout(&I2C_DRIVER, slaveI2Caddress/2, other_matrix, MATRIX_ROWS / 2, US2ST(100)); // printf("%x\n", resp); // if (resp != MSG_OK) { // for (i = 0; i < MATRIX_ROWS / 2; i++) {