-static void unselect_rows(void)
-{
- // unselect on mcp23018
- if (mcp23018_status) { // if there was an error
- // do nothing
- } else {
- // set all rows hi-Z : 1
- mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPIOA); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write( 0xFF
- & ~(0<<7)
- ); if (mcp23018_status) goto out;
- out:
- i2c_stop();
- }
-
- // unselect on teensy
- // Hi-Z(DDR:0, PORT:0) to unselect
- DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
- PORTB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
- DDRD &= ~(1<<2 | 1<<3);
- PORTD &= ~(1<<2 | 1<<3);
- DDRC &= ~(1<<6);
- PORTC &= ~(1<<6);
+static void unselect_rows(void) {
+ // no need to unselect on mcp23018, because the select step sets all
+ // the other row bits high, and it's not changing to a different
+ // direction
+
+ // unselect on teensy
+ // Hi-Z(DDR:0, PORT:0) to unselect
+ DDRB &= ~(1 << 0 | 1 << 1 | 1 << 2 | 1 << 3);
+ PORTB &= ~(1 << 0 | 1 << 1 | 1 << 2 | 1 << 3);
+ DDRD &= ~(1 << 2 | 1 << 3);
+ PORTD &= ~(1 << 2 | 1 << 3);
+ DDRC &= ~(1 << 6);
+ PORTC &= ~(1 << 6);