Skip to content

Commit

Permalink
Implement COL_PINS/ROW_PINS for dactyl [qmk#2065]
Browse files Browse the repository at this point in the history
  • Loading branch information
ErinCall committed Mar 25, 2018
1 parent abc83b9 commit c7e7c47
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 260 deletions.
6 changes: 6 additions & 0 deletions keyboards/handwired/dactyl/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DIODE_DIRECTION ROW2COL
#define MATRIX_ROWS 6
#define MATRIX_COLS 12
#define COL_EXPANDED { true, true, true, true, true, true, false, false, false, false, false, false}
#define MATRIX_ONBOARD_ROW_PINS { F0, F1, F4, F5, F6, F7 }
#define MATRIX_ONBOARD_COL_PINS { 0, 0, 0, 0, 0, 0, B1, B2, B3, D2, D3, C6 }
#define EXPANDER_COL_REGISTER 0
#define MATRIX_EXPANDER_COL_PINS {0, 1, 2, 3, 4, 5}
#define MATRIX_EXPANDER_ROW_PINS {0, 1, 2, 3, 4, 5}

#define MOUSEKEY_INTERVAL 20
#define MOUSEKEY_DELAY 0
Expand Down
68 changes: 0 additions & 68 deletions keyboards/handwired/dactyl/dactyl.c
Original file line number Diff line number Diff line change
@@ -1,74 +1,6 @@
#include "dactyl.h"
#include "i2cmaster.h"


bool i2c_initialized = 0;
uint8_t mcp23018_status = 0x20;

void matrix_init_kb(void) {
DDRB &= ~(1<<4); // set B(4) as input
PORTB &= ~(1<<4); // set B(4) internal pull-up disabled

// unused pins - C7, D4, D5, D7, E6
// set as input with internal pull-up enabled
DDRC &= ~(1<<7);
DDRD &= ~(1<<5 | 1<<4);
DDRE &= ~(1<<6);
PORTC |= (1<<7);
PORTD |= (1<<5 | 1<<4);
PORTE |= (1<<6);

matrix_init_user();
}

uint8_t init_mcp23018(void) {
mcp23018_status = 0x20;

// I2C subsystem

if (i2c_initialized == 0) {
i2c_init(); // on pins D(1,0)
i2c_initialized = true;
_delay_ms(1000);
}

// set pin direction
// - unused : input : 1
// - input : input : 1
// - driving : output : 0
mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(IODIRA); if (mcp23018_status) goto out;

#if (DIODE_DIRECTION == COL2ROW)
mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out;
#elif (DIODE_DIRECTION == ROW2COL)
mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out;
#endif

i2c_stop();

// set pull-up
// - unused : on : 1
// - input : on : 1
// - driving : off : 0
mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(GPPUA); if (mcp23018_status) goto out;
#if (DIODE_DIRECTION == COL2ROW)
mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out;
#elif (DIODE_DIRECTION == ROW2COL)
mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out;
#endif

out:
i2c_stop();

return mcp23018_status;
}

#ifdef ONEHAND_ENABLE
__attribute__ ((weak))
// swap-hands action needs a matrix to define the swap
Expand Down
3 changes: 2 additions & 1 deletion keyboards/handwired/dactyl/dactyl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
#define OLATB 0x15

extern uint8_t mcp23018_status;
extern bool i2c_initialized;

void init_dactyl(void);
uint8_t init_mcp23018(void);
void init_expander(void);

#define KEYMAP( \
\
Expand Down
Loading

0 comments on commit c7e7c47

Please sign in to comment.