Skip to content

Commit

Permalink
orthodox: revert TWI support to minimum to debug
Browse files Browse the repository at this point in the history
- disabled ssd1306 and hardware locking in build configuration
- increased TWI buffer from 0x10 to 0x20 bytes
- decreased TWI clock from 400000 to 100000
- removed hardcoded TWI multi-byte sending/receiving

An 'i2c' build of this was found to work on a rev1 Orthodox, although
slave-side col9 was understandably not working. When testing-time
permits, features will be gradually re-enabled towards getting the full
matrix supported over TWI.
  • Loading branch information
utrrrongeeb committed Jun 26, 2017
1 parent e40d2aa commit 3244e69
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions keyboards/orthodox/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#define I2C_ACK 1
#define I2C_NACK 0

#define SLAVE_BUFFER_SIZE 0x10
#define SLAVE_BUFFER_SIZE 0x20

// i2c SCL clock frequency
#define SCL_CLOCK 400000L
#define SCL_CLOCK 100000UL

extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];

Expand Down
13 changes: 9 additions & 4 deletions keyboards/orthodox/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ int i2c_transaction(void) {
*((uint8_t*)&matrix[slaveOffset]+i) = i2c_master_read(I2C_NACK);
*/

i2c_master_read(I2C_ACK);
// i2c_master_read(I2C_ACK);
matrix[slaveOffset+0] = i2c_master_read(I2C_ACK);
i2c_master_read(I2C_ACK);
// i2c_master_read(I2C_ACK);
matrix[slaveOffset+1] = i2c_master_read(I2C_ACK);
i2c_master_read(I2C_ACK);
// i2c_master_read(I2C_ACK);
matrix[slaveOffset+2] = i2c_master_read(I2C_NACK);

i2c_master_stop();
Expand Down Expand Up @@ -255,12 +255,17 @@ void matrix_slave_scan(void) {
// SLAVE_BUFFER_SIZE is from i2c.h
// (MATRIX_ROWS/2*sizeof(matrix_row_t))
// memcpy((void*)i2c_slave_buffer, (const void*)&matrix[offset], (ROWS_PER_HAND*sizeof(matrix_row_t)));
i2c_slave_buffer[0] = (uint8_t)matrix[offset+0];
i2c_slave_buffer[0] = (uint8_t)(matrix[offset+0]);
i2c_slave_buffer[1] = (uint8_t)(matrix[offset+1]);
i2c_slave_buffer[2] = (uint8_t)(matrix[offset+2]);
// note: looks like a possible operator-precedence bug here, in last version?
/*
i2c_slave_buffer[1] = (uint8_t)matrix[offset+0];
i2c_slave_buffer[2] = (uint8_t)(matrix[offset+1]>>8);
i2c_slave_buffer[3] = (uint8_t)(matrix[offset+1]>>8);
i2c_slave_buffer[4] = (uint8_t)(matrix[offset+2]>>8);
i2c_slave_buffer[5] = (uint8_t)matrix[offset+2];
*/
#else // USE_SERIAL
for (int i = 0; i < ROWS_PER_HAND; ++i) {
serial_slave_buffer[i] = matrix[offset+i];
Expand Down
4 changes: 2 additions & 2 deletions keyboards/orthodox/rev1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEBOUNCING_DELAY 5

/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
// #define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
// #define LOCKING_RESYNC_ENABLE

/* key combination for command */
#define IS_COMMAND() ( \
Expand Down
3 changes: 1 addition & 2 deletions keyboards/orthodox/rules.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
SRC += matrix.c \
i2c.c \
split_util.c \
serial.c \
ssd1306.c
serial.c

# MCU name
#MCU = at90usb1287
Expand Down

0 comments on commit 3244e69

Please sign in to comment.