@ -135,10 +135,7 @@ uint8_t matrix_cols(void) {
return MATRIX_COLS ;
return MATRIX_COLS ;
}
}
i2c_status_t i2c_transaction ( uint8_t address , uint32_t mask , uint8_t col_offset ) ;
i2c_status_t i2c_transaction ( uint8_t address , uint32_t mask , uint8_t col_offset ) ;
//uint8_t i2c_transaction_numpad(void);
//uint8_t i2c_transaction_arrow(void);
//this replases tmk code
//this replases tmk code
void matrix_setup ( void ) {
void matrix_setup ( void ) {
@ -440,12 +437,9 @@ static void unselect_cols(void)
// Complete rows from other modules over i2c
// Complete rows from other modules over i2c
i2c_status_t i2c_transaction ( uint8_t address , uint32_t mask , uint8_t col_offset ) {
i2c_status_t i2c_transaction ( uint8_t address , uint32_t mask , uint8_t col_offset ) {
i2c_status_t err = i2c_start ( ( address < < 1 ) | I2C_WRITE , 10 ) ;
i2c_status_t err = i2c_start ( ( address < < 1 ) | I2C_WRITE , 10 ) ;
if ( err ) return err ;
i2c_write ( 0x01 , 10 ) ; //request data in address 1
i2c_write ( 0x01 , 10 ) ;
if ( err ) return err ;
i2c_start ( ( address < < 1 ) | I2C_READ , 10 ) ;
i2c_start ( ( address < < 1 ) | I2C_READ , 5 ) ;
if ( err ) return err ;
err = i2c_read_ack ( 10 ) ;
err = i2c_read_ack ( 10 ) ;
if ( err = = 0x55 ) { //synchronization byte
if ( err = = 0x55 ) { //synchronization byte
@ -453,27 +447,18 @@ i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset)
for ( uint8_t i = 0 ; i < MATRIX_ROWS - 1 ; i + + ) { //assemble slave matrix in main matrix
for ( uint8_t i = 0 ; i < MATRIX_ROWS - 1 ; i + + ) { //assemble slave matrix in main matrix
matrix [ i ] & = mask ; //mask bits to keep
matrix [ i ] & = mask ; //mask bits to keep
err = i2c_read_ack ( 10 ) ;
err = i2c_read_ack ( 10 ) ;
if ( err > = 0 ) {
matrix [ i ] | = ( ( uint32_t ) err < < ( MATRIX_COLS_SCANNED + col_offset ) ) ; //add new bits at the end
matrix [ i ] | = ( ( uint32_t ) err < < ( MATRIX_COLS_SCANNED + col_offset ) ) ; //add new bits at the end
} else {
return err ;
}
}
}
//last read request must be followed by a NACK
//last read request must be followed by a NACK
matrix [ MATRIX_ROWS - 1 ] & = mask ; //mask bits to keep
matrix [ MATRIX_ROWS - 1 ] & = mask ; //mask bits to keep
err = i2c_read_nack ( 10 ) ;
err = i2c_read_nack ( 10 ) ;
if ( err > = 0 ) {
matrix [ MATRIX_ROWS - 1 ] | = ( ( uint32_t ) err < < ( MATRIX_COLS_SCANNED + col_offset ) ) ; //add new bits at the end
matrix [ MATRIX_ROWS - 1 ] | = ( ( uint32_t ) err < < ( MATRIX_COLS_SCANNED + col_offset ) ) ; //add new bits at the end
} else {
return err ;
}
} else {
} else {
i2c_stop ( 10 ) ;
i2c_stop ( 10 ) ;
return 1 ;
return 1 ;
}
}
i2c_stop ( 10 ) ;
i2c_stop ( 10 ) ;
if ( err ) return err ;
return 0 ;
return 0 ;
}
}