forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f02430b
commit 52f4a38
Showing
13 changed files
with
1,067 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ifndef MAKEFILE_INCLUDED | ||
include ../../../Makefile | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#ifndef ERGODOX_ERGODONE_CONFIG_H | ||
#define ERGODOX_ERGODONE_CONFIG_H | ||
|
||
#include "../config.h" | ||
|
||
#include "config_common.h" | ||
|
||
/* USB Device descriptor parameter */ | ||
#define VENDOR_ID 0xFEED | ||
#define PRODUCT_ID 0x1307 | ||
#define DEVICE_VER 0x0001 | ||
#define MANUFACTURER ErgoDone | ||
#define PRODUCT ErgoDone | ||
#define DESCRIPTION QMK keyboard firmware for ErgoDone | ||
|
||
/* key matrix size */ | ||
#define MATRIX_ROWS 6 | ||
#define MATRIX_COLS 14 | ||
|
||
/* fix space cadet rollover issue */ | ||
#define DISABLE_SPACE_CADET_ROLLOVER | ||
|
||
/* Set 0 if debouncing isn't needed */ | ||
#define DEBOUNCE 5 | ||
|
||
#define PREVENT_STUCK_MODIFIERS | ||
|
||
#define USB_MAX_POWER_CONSUMPTION 500 | ||
|
||
/* | ||
* Feature disable options | ||
* These options are also useful to firmware size reduction. | ||
*/ | ||
|
||
/* disable debug print */ | ||
// #define NO_DEBUG | ||
|
||
/* disable print */ | ||
// #define NO_PRINT | ||
|
||
/* disable action features */ | ||
//#define NO_ACTION_LAYER | ||
//#define NO_ACTION_TAPPING | ||
//#define NO_ACTION_ONESHOT | ||
//#define NO_ACTION_MACRO | ||
//#define NO_ACTION_FUNCTION | ||
//#define DEBUG_MATRIX_SCAN_RATE | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "ergodone.h" | ||
|
||
void matrix_init_kb(void) { | ||
matrix_init_user(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef ERGODOX_ERGODONE_H | ||
#define ERGODOX_ERGODONE_H | ||
|
||
#include "quantum.h" | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) | ||
#define CPU_16MHz 0x00 | ||
|
||
void init_ergodox(void); | ||
|
||
inline void ergodox_right_led_1_off(void) {} | ||
inline void ergodox_right_led_1_on(void) {} | ||
inline void ergodox_right_led_2_off(void) {} | ||
inline void ergodox_right_led_2_on(void) {} | ||
inline void ergodox_right_led_3_off(void) {} | ||
inline void ergodox_right_led_3_on(void) {} | ||
inline void ergodox_board_led_off(void) {} | ||
inline void ergodox_board_led_on(void) {} | ||
|
||
#define KEYMAP( \ | ||
\ | ||
/* left hand, spatial positions */ \ | ||
k00,k01,k02,k03,k04,k05,k06, \ | ||
k10,k11,k12,k13,k14,k15,k16, \ | ||
k20,k21,k22,k23,k24,k25, \ | ||
k30,k31,k32,k33,k34,k35,k36, \ | ||
k40,k41,k42,k43,k44, \ | ||
k55,k56, \ | ||
k54, \ | ||
k53,k52,k51, \ | ||
\ | ||
/* right hand, spatial positions */ \ | ||
k07,k08,k09,k0A,k0B,k0C,k0D, \ | ||
k17,k18,k19,k1A,k1B,k1C,k1D, \ | ||
k28,k29,k2A,k2B,k2C,k2D, \ | ||
k37,k38,k39,k3A,k3B,k3C,k3D, \ | ||
k49,k4A,k4B,k4C,k4D, \ | ||
k57,k58, \ | ||
k59, \ | ||
k5C,k5B,k5A ) \ | ||
\ | ||
/* matrix positions */ \ | ||
{ \ | ||
{ k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0A, k0B, k0C, k0D }, \ | ||
{ k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B, k1C, k1D }, \ | ||
{ k20, k21, k22, k23, k24, k25, KC_NO, KC_NO, k28, k29, k2A, k2B, k2C, k2D }, \ | ||
{ k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B, k3C, k3D }, \ | ||
{ k40, k41, k42, k43, k44, KC_NO, KC_NO, KC_NO, KC_NO, k49, k4A, k4B, k4C, k4D }, \ | ||
{ KC_NO, k51, k52, k53, k54, k55, k56, k57, k58, k59, k5A, k5B, k5C, KC_NO } \ | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#include <stdbool.h> | ||
#include "action.h" | ||
#include "i2cmaster.h" | ||
#include "expander.h" | ||
#include "debug.h" | ||
|
||
static uint8_t expander_status = 0; | ||
static uint8_t expander_input = 0; | ||
|
||
void expander_config(void); | ||
uint8_t expander_write(uint8_t reg, uint8_t data); | ||
uint8_t expander_read(uint8_t reg, uint8_t *data); | ||
|
||
void expander_init(void) | ||
{ | ||
i2c_init(); | ||
expander_scan(); | ||
} | ||
|
||
void expander_scan(void) | ||
{ | ||
dprintf("expander status: %d ... ", expander_status); | ||
uint8_t ret = i2c_start(EXPANDER_ADDR | I2C_WRITE); | ||
if (ret == 0) { | ||
i2c_stop(); | ||
if (expander_status == 0) { | ||
dprintf("attached\n"); | ||
expander_status = 1; | ||
expander_config(); | ||
clear_keyboard(); | ||
} | ||
} | ||
else { | ||
if (expander_status == 1) { | ||
dprintf("detached\n"); | ||
expander_status = 0; | ||
clear_keyboard(); | ||
} | ||
} | ||
dprintf("%d\n", expander_status); | ||
} | ||
|
||
void expander_read_cols(void) | ||
{ | ||
expander_read(EXPANDER_REG_GPIOA, &expander_input); | ||
} | ||
|
||
uint8_t expander_get_col(uint8_t col) | ||
{ | ||
if (col > 4) { | ||
col++; | ||
} | ||
return expander_input & (1<<col) ? 1 : 0; | ||
} | ||
|
||
matrix_row_t expander_read_row(void) | ||
{ | ||
expander_read_cols(); | ||
|
||
/* make cols */ | ||
matrix_row_t cols = 0; | ||
for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
if (expander_get_col(col)) { | ||
cols |= (1UL << (MATRIX_COLS - 1 - col)); | ||
} | ||
} | ||
|
||
return cols; | ||
} | ||
|
||
void expander_unselect_rows(void) | ||
{ | ||
expander_write(EXPANDER_REG_IODIRB, 0xFF); | ||
} | ||
|
||
void expander_select_row(uint8_t row) | ||
{ | ||
expander_write(EXPANDER_REG_IODIRB, ~(1<<(row+1))); | ||
} | ||
|
||
void expander_config(void) | ||
{ | ||
expander_write(EXPANDER_REG_IPOLA, 0xFF); | ||
expander_write(EXPANDER_REG_GPPUA, 0xFF); | ||
expander_write(EXPANDER_REG_IODIRB, 0xFF); | ||
} | ||
|
||
uint8_t expander_write(uint8_t reg, uint8_t data) | ||
{ | ||
if (expander_status == 0) { | ||
return 0; | ||
} | ||
uint8_t ret; | ||
ret = i2c_start(EXPANDER_ADDR | I2C_WRITE); | ||
if (ret) goto stop; | ||
ret = i2c_write(reg); | ||
if (ret) goto stop; | ||
ret = i2c_write(data); | ||
stop: | ||
i2c_stop(); | ||
return ret; | ||
} | ||
|
||
uint8_t expander_read(uint8_t reg, uint8_t *data) | ||
{ | ||
if (expander_status == 0) { | ||
return 0; | ||
} | ||
uint8_t ret; | ||
ret = i2c_start(EXPANDER_ADDR | I2C_WRITE); | ||
if (ret) goto stop; | ||
ret = i2c_write(reg); | ||
if (ret) goto stop; | ||
ret = i2c_rep_start(EXPANDER_ADDR | I2C_READ); | ||
if (ret) goto stop; | ||
*data = i2c_readNak(); | ||
stop: | ||
i2c_stop(); | ||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef EXPANDER_H | ||
#define EXPANDER_H | ||
|
||
#include <stdint.h> | ||
#include "matrix.h" | ||
|
||
#define MCP23017 | ||
#define MCP23017_A0 0 | ||
#define MCP23017_A1 0 | ||
#define MCP23017_A2 0 | ||
|
||
#ifdef MCP23017 | ||
#define EXPANDER_ADDR ((0x20|(MCP23017_A0<<0)|(MCP23017_A1<<1)|(MCP23017_A2<<2)) << 1) | ||
enum EXPANDER_REG_BANK0 { | ||
EXPANDER_REG_IODIRA = 0, | ||
EXPANDER_REG_IODIRB, | ||
EXPANDER_REG_IPOLA, | ||
EXPANDER_REG_IPOLB, | ||
EXPANDER_REG_GPINTENA, | ||
EXPANDER_REG_GPINTENB, | ||
EXPANDER_REG_DEFVALA, | ||
EXPANDER_REG_DEFVALB, | ||
EXPANDER_REG_INTCONA, | ||
EXPANDER_REG_INTCONB, | ||
EXPANDER_REG_IOCONA, | ||
EXPANDER_REG_IOCONB, | ||
EXPANDER_REG_GPPUA, | ||
EXPANDER_REG_GPPUB, | ||
EXPANDER_REG_INTFA, | ||
EXPANDER_REG_INTFB, | ||
EXPANDER_REG_INTCAPA, | ||
EXPANDER_REG_INTCAPB, | ||
EXPANDER_REG_GPIOA, | ||
EXPANDER_REG_GPIOB, | ||
EXPANDER_REG_OLATA, | ||
EXPANDER_REG_OLATB | ||
}; | ||
#endif | ||
|
||
void expander_init(void); | ||
void expander_scan(void); | ||
void expander_read_cols(void); | ||
uint8_t expander_get_col(uint8_t col); | ||
matrix_row_t expander_read_row(void); | ||
void expander_unselect_rows(void); | ||
void expander_select_row(uint8_t row); | ||
|
||
#endif |
Oops, something went wrong.