mirror of
https://github.com/firewalkwithm3/qmk_firmware.git
synced 2024-11-22 11:30:30 +08:00
[Keyboard] Add Ingrained Keyboard (#15928)
Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> Co-authored-by: Juan Puerto <jpuerto@psc.edu> Co-authored-by: jpuerto-psc <68066250+jpuerto-psc@users.noreply.github.com>
This commit is contained in:
parent
7adef85fa4
commit
101d7b5337
51
keyboards/ingrained/config.h
Normal file
51
keyboards/ingrained/config.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Copyright 2021 s8erdude (@jpuerto96)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 12
|
||||
|
||||
#define MATRIX_ROWS_PER_SIDE (MATRIX_ROWS / 2)
|
||||
#define MATRIX_COLS_PER_SIDE (MATRIX_COLS / 2)
|
||||
|
||||
#define UNUSED_MCU 13
|
||||
#define UNUSED_MCP 6
|
||||
|
||||
|
||||
// wiring
|
||||
#define MATRIX_ROW_PINS_MCU \
|
||||
{ B0, B1, B2, B3 }
|
||||
#define MATRIX_COL_PINS_MCU \
|
||||
{ F7, F6, F5, F4, F1, F0 }
|
||||
#define UNUSED_PINS_MCU \
|
||||
{ B4, B5, B6, B7, C6, C7, D2, D3, D4, D5, D6, D7, E6}
|
||||
#define MATRIX_ROW_PINS_MCP \
|
||||
{ B0, B1, B2, B3 }
|
||||
#define MATRIX_COL_PINS_MCP \
|
||||
{ A0, A1, A2, A3, A4, A5 }
|
||||
#define UNUSED_PINS_MCP \
|
||||
{ B4, B5, B6, B7, A6, A7 }
|
||||
|
||||
/*
|
||||
* Keyboard Matrix Assignments
|
||||
*
|
||||
* Change this to how you wired your keyboard
|
||||
* COLS: AVR pins used for columns, left to right
|
||||
* ROWS: AVR pins used for rows, top to bottom
|
||||
* DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
|
||||
* ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
|
||||
*
|
||||
*/
|
||||
|
||||
/* COL2ROW, ROW2COL */
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
|
||||
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* define if matrix has ghost (lacks anti-ghosting diodes) */
|
||||
//#define MATRIX_HAS_GHOST
|
276
keyboards/ingrained/info.json
Normal file
276
keyboards/ingrained/info.json
Normal file
|
@ -0,0 +1,276 @@
|
|||
{
|
||||
"keyboard_name": "ingrained",
|
||||
"manufacturer": "s8erdude"
|
||||
"url": "https://github.com/jpuerto96",
|
||||
"maintainer": "jpuerto96 (s8erdude)",
|
||||
"usb": {
|
||||
"vid": "0xB33F",
|
||||
"pid": "0x58E4",
|
||||
"device_version": "0.0.1"
|
||||
},
|
||||
"layouts": {
|
||||
"LAYOUT_split_3x6_3": {
|
||||
"layout": [
|
||||
{
|
||||
"label": "Esc",
|
||||
"x": 0,
|
||||
"y": 0.3
|
||||
},
|
||||
{
|
||||
"label": "Q",
|
||||
"x": 1,
|
||||
"y": 0.3
|
||||
},
|
||||
{
|
||||
"label": "W",
|
||||
"x": 2,
|
||||
"y": 0.1
|
||||
},
|
||||
{
|
||||
"label": "E",
|
||||
"x": 3,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "R",
|
||||
"x": 4,
|
||||
"y": 0.1
|
||||
},
|
||||
{
|
||||
"label": "T",
|
||||
"x": 5,
|
||||
"y": 0.2
|
||||
},
|
||||
{
|
||||
"label": "Y",
|
||||
"x": 9,
|
||||
"y": 0.2
|
||||
},
|
||||
{
|
||||
"label": "U",
|
||||
"x": 10,
|
||||
"y": 0.1
|
||||
},
|
||||
{
|
||||
"label": "I",
|
||||
"x": 11,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "O",
|
||||
"x": 12,
|
||||
"y": 0.1
|
||||
},
|
||||
{
|
||||
"label": "P",
|
||||
"x": 13,
|
||||
"y": 0.3
|
||||
},
|
||||
{
|
||||
"label": "Back Space",
|
||||
"x": 14,
|
||||
"y": 0.3
|
||||
},
|
||||
{
|
||||
"label": "Tab",
|
||||
"x": 0,
|
||||
"y": 1.3
|
||||
},
|
||||
{
|
||||
"label": "A",
|
||||
"x": 1,
|
||||
"y": 1.3
|
||||
},
|
||||
{
|
||||
"label": "S",
|
||||
"x": 2,
|
||||
"y": 1.1
|
||||
},
|
||||
{
|
||||
"label": "D",
|
||||
"x": 3,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "F",
|
||||
"x": 4,
|
||||
"y": 1.1
|
||||
},
|
||||
{
|
||||
"label": "G",
|
||||
"x": 5,
|
||||
"y": 1.2
|
||||
},
|
||||
{
|
||||
"label": "H",
|
||||
"x": 9,
|
||||
"y": 1.2
|
||||
},
|
||||
{
|
||||
"label": "J",
|
||||
"x": 10,
|
||||
"y": 1.1
|
||||
},
|
||||
{
|
||||
"label": "K",
|
||||
"x": 11,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "L",
|
||||
"x": 12,
|
||||
"y": 1.1
|
||||
},
|
||||
{
|
||||
"label": ";",
|
||||
"x": 13,
|
||||
"y": 1.3
|
||||
},
|
||||
{
|
||||
"label": "'",
|
||||
"x": 14,
|
||||
"y": 1.3
|
||||
},
|
||||
{
|
||||
"label": "Shift",
|
||||
"x": 0,
|
||||
"y": 2.3
|
||||
},
|
||||
{
|
||||
"label": "Z",
|
||||
"x": 1,
|
||||
"y": 2.3
|
||||
},
|
||||
{
|
||||
"label": "X",
|
||||
"x": 2,
|
||||
"y": 2.1
|
||||
},
|
||||
{
|
||||
"label": "C",
|
||||
"x": 3,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "V",
|
||||
"x": 4,
|
||||
"y": 2.1
|
||||
},
|
||||
{
|
||||
"label": "B",
|
||||
"x": 5,
|
||||
"y": 2.2
|
||||
},
|
||||
{
|
||||
"label": "N",
|
||||
"x": 9,
|
||||
"y": 2.2
|
||||
},
|
||||
{
|
||||
"label": "M",
|
||||
"x": 10,
|
||||
"y": 2.1
|
||||
},
|
||||
{
|
||||
"label": ",",
|
||||
"x": 11,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": ".",
|
||||
"x": 12,
|
||||
"y": 2.1
|
||||
},
|
||||
{
|
||||
"label": "/",
|
||||
"x": 13,
|
||||
"y": 2.3
|
||||
},
|
||||
{
|
||||
"label": "Shift",
|
||||
"x": 14,
|
||||
"y": 2.3
|
||||
},
|
||||
{
|
||||
"label": "GUI",
|
||||
"x": 4,
|
||||
"y": 3.7
|
||||
},
|
||||
{
|
||||
"label": "Lower",
|
||||
"x": 5,
|
||||
"y": 3.7
|
||||
},
|
||||
{
|
||||
"label": "Space",
|
||||
"x": 6,
|
||||
"y": 3.2,
|
||||
"h": 1.5
|
||||
},
|
||||
{
|
||||
"label": "Enter",
|
||||
"x": 8,
|
||||
"y": 3.2,
|
||||
"h": 1.5
|
||||
},
|
||||
{
|
||||
"label": "Raise",
|
||||
"x": 9,
|
||||
"y": 3.7
|
||||
},
|
||||
{
|
||||
"label": "Alt",
|
||||
"x": 10,
|
||||
"y": 3.7
|
||||
}
|
||||
]
|
||||
},
|
||||
"LAYOUT_split_3x5_3": {
|
||||
"layout": [
|
||||
{"label":"Q", "x":0, "y":0.3},
|
||||
{"label":"W", "x":1, "y":0.1},
|
||||
{"label":"E", "x":2, "y":0},
|
||||
{"label":"R", "x":3, "y":0.1},
|
||||
{"label":"T", "x":4, "y":0.2},
|
||||
|
||||
{"label":"Y", "x":8, "y":0.2},
|
||||
{"label":"U", "x":9, "y":0.1},
|
||||
{"label":"I", "x":10, "y":0},
|
||||
{"label":"O", "x":11, "y":0.1},
|
||||
{"label":"P", "x":12, "y":0.3},
|
||||
|
||||
{"label":"A", "x":0, "y":1.3},
|
||||
{"label":"S", "x":1, "y":1.1},
|
||||
{"label":"D", "x":2, "y":1},
|
||||
{"label":"F", "x":3, "y":1.1},
|
||||
{"label":"G", "x":4, "y":1.2},
|
||||
|
||||
{"label":"H", "x":8, "y":1.2},
|
||||
{"label":"J", "x":9, "y":1.1},
|
||||
{"label":"K", "x":10, "y":1},
|
||||
{"label":"L", "x":11, "y":1.1},
|
||||
{"label":";", "x":12, "y":1.3},
|
||||
|
||||
{"label":"Z", "x":0, "y":2.3},
|
||||
{"label":"X", "x":1, "y":2.1},
|
||||
{"label":"C", "x":2, "y":2},
|
||||
{"label":"V", "x":3, "y":2.1},
|
||||
{"label":"B", "x":4, "y":2.2},
|
||||
|
||||
{"label":"N", "x":8, "y":2.2},
|
||||
{"label":"M", "x":9, "y":2.1},
|
||||
{"label":",", "x":10, "y":2},
|
||||
{"label":".", "x":11, "y":2.1},
|
||||
{"label":"/", "x":12, "y":2.3},
|
||||
|
||||
{"label":"GUI", "x":3, "y":3.7},
|
||||
{"label":"Lower", "x":4, "y":3.7},
|
||||
{"label":"Space", "x":5, "y":3.2, "h":1.5},
|
||||
|
||||
{"label":"Enter", "x":7, "y":3.2, "h":1.5},
|
||||
{"label":"Raise", "x":8, "y":3.7},
|
||||
{"label":"Alt", "x":9, "y":3.7}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
4
keyboards/ingrained/ingrained.c
Normal file
4
keyboards/ingrained/ingrained.c
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright 2021 s8erdude (@jpuerto96)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "ingrained.h"
|
47
keyboards/ingrained/ingrained.h
Normal file
47
keyboards/ingrained/ingrained.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Copyright 2021 s8erdude (@jpuerto96)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
/* This is a shortcut to help you visually see your layout.
|
||||
*
|
||||
* The first section contains all of the arguments representing the physical
|
||||
* layout of the board and position of the keys.
|
||||
*
|
||||
* The second converts the arguments into a two-dimensional array which
|
||||
* represents the switch matrix.
|
||||
*/
|
||||
#define XXX KC_NO
|
||||
|
||||
#define LAYOUT_split_3x6_3( \
|
||||
k00, k01, k02, k03, k04, k05, k011, k010, k09, k08, k07, k06,\
|
||||
k10, k11, k12, k13, k14, k15, k111, k110, k19, k18, k17, k16,\
|
||||
k20, k21, k22, k23, k24, k25, k211, k210, k29, k28, k27, k26,\
|
||||
k33, k34, k35, k311, k310, k39\
|
||||
) { \
|
||||
{ k00, k01, k02, k03, k04, k05 },\
|
||||
{ k10, k11, k12, k13, k14, k15 },\
|
||||
{ k20, k21, k22, k23, k24, k25 },\
|
||||
{ XXX, XXX, XXX, k33, k34, k35 },\
|
||||
{ k06, k07, k08, k09, k010, k011 },\
|
||||
{ k16, k17, k18, k19, k110, k111 },\
|
||||
{ k26, k27, k28, k29, k210, k211 },\
|
||||
{ XXX, XXX, XXX, k39, k310, k311 }\
|
||||
}
|
||||
#define LAYOUT_split_3x5_3( \
|
||||
k01, k02, k03, k04, k05, k011, k010, k09, k08, k07,\
|
||||
k11, k12, k13, k14, k15, k111, k110, k19, k18, k17,\
|
||||
k21, k22, k23, k24, k25, k211, k210, k29, k28, k27,\
|
||||
k33, k34, k35, k311, k310, k39\
|
||||
) { \
|
||||
{ XXX, k01, k02, k03, k04, k05 },\
|
||||
{ XXX, k11, k12, k13, k14, k15 },\
|
||||
{ XXX, k21, k22, k23, k24, k25 },\
|
||||
{ XXX, XXX, XXX, k33, k34, k35 },\
|
||||
{ XXX, k07, k08, k09, k010, k011 },\
|
||||
{ XXX, k17, k18, k19, k110, k111 },\
|
||||
{ XXX, k27, k28, k29, k210, k211 },\
|
||||
{ XXX, XXX, XXX, k39, k310, k311 }\
|
||||
}
|
23
keyboards/ingrained/keymaps/3x5/keymap.c
Normal file
23
keyboards/ingrained/keymaps/3x5/keymap.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2021 s8erdude (@jpuerto96)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
|
||||
// Each layer gets a name for readability, which is then used in the keymap matrix below.
|
||||
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
|
||||
// Layer names don't all need to be of the same length, obviously, and you can also skip them
|
||||
// entirely and just use numbers.
|
||||
|
||||
enum layer_names {
|
||||
_BASE,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[_BASE] = LAYOUT_split_3x5_3(
|
||||
KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,
|
||||
KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,
|
||||
KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH,
|
||||
KC_LGUI, KC_SPC, KC_TAB, KC_BSPC, KC_ENT, KC_RALT
|
||||
)
|
||||
};
|
1
keyboards/ingrained/keymaps/3x5/readme.md
Normal file
1
keyboards/ingrained/keymaps/3x5/readme.md
Normal file
|
@ -0,0 +1 @@
|
|||
# The 3x5 keymap for ingrained
|
23
keyboards/ingrained/keymaps/default/keymap.c
Normal file
23
keyboards/ingrained/keymaps/default/keymap.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2021 s8erdude (@jpuerto96)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
|
||||
// Each layer gets a name for readability, which is then used in the keymap matrix below.
|
||||
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
|
||||
// Layer names don't all need to be of the same length, obviously, and you can also skip them
|
||||
// entirely and just use numbers.
|
||||
|
||||
enum layer_names {
|
||||
_BASE,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[_BASE] = LAYOUT_split_3x6_3(
|
||||
KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
|
||||
KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
|
||||
KC_LGUI, KC_SPC, KC_TAB, KC_BSPC, KC_ENT, KC_RALT
|
||||
),
|
||||
};
|
1
keyboards/ingrained/keymaps/default/readme.md
Normal file
1
keyboards/ingrained/keymaps/default/readme.md
Normal file
|
@ -0,0 +1 @@
|
|||
# The default keymap for ingrained
|
253
keyboards/ingrained/matrix.c
Normal file
253
keyboards/ingrained/matrix.c
Normal file
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
|
||||
2020 Pierre Chevalier <pierrechevalier83@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code was heavily inspired by the ergodox_ez keymap, and modernized
|
||||
* to take advantage of the quantum.h microcontroller agnostics gpio control
|
||||
* abstractions and use the macros defined in config.h for the wiring as opposed
|
||||
* to repeating that information all over the place.
|
||||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "i2c_master.h"
|
||||
|
||||
extern i2c_status_t mcp23017_status;
|
||||
#define I2C_TIMEOUT 1000
|
||||
|
||||
// For a better understanding of the i2c protocol, this is a good read:
|
||||
// https://www.robot-electronics.co.uk/i2c-tutorial
|
||||
|
||||
// I2C address:
|
||||
// See the datasheet, section 3.3.1 on addressing I2C devices and figure 3-6 for an
|
||||
// illustration
|
||||
// http://ww1.microchip.com/downloads/en/devicedoc/20001952c.pdf
|
||||
// All address pins of the mcp23017 are connected to the ground on the ferris
|
||||
// | 0 | 1 | 0 | 0 | A2 | A1 | A0 |
|
||||
// | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
|
||||
#define I2C_ADDR 0b0100000
|
||||
#define I2C_ADDR_WRITE ((I2C_ADDR << 1) | I2C_WRITE)
|
||||
#define I2C_ADDR_READ ((I2C_ADDR << 1) | I2C_READ)
|
||||
|
||||
// Register addresses
|
||||
// See https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/blob/master/Adafruit_MCP23017.h
|
||||
#define IODIRA 0x00 // i/o direction register
|
||||
#define IODIRB 0x01
|
||||
#define GPPUA 0x0C // GPIO pull-up resistor register
|
||||
#define GPPUB 0x0D
|
||||
#define GPIOA 0x12 // general purpose i/o port register (write modifies OLAT)
|
||||
#define GPIOB 0x13
|
||||
#define OLATA 0x14 // output latch register
|
||||
#define OLATB 0x15
|
||||
|
||||
bool i2c_initialized = 0;
|
||||
i2c_status_t mcp23017_status = I2C_ADDR;
|
||||
|
||||
uint8_t init_mcp23017(void) {
|
||||
print("starting init");
|
||||
mcp23017_status = I2C_ADDR;
|
||||
|
||||
// I2C subsystem
|
||||
if (i2c_initialized == 0) {
|
||||
i2c_init(); // on pins D(1,0)
|
||||
i2c_initialized = true;
|
||||
wait_ms(I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
// set pin direction
|
||||
// - unused : input : 1
|
||||
// - input : input : 1
|
||||
// - driving : output : 0
|
||||
// This means: we will read all the bits on GPIOA
|
||||
// This means: we will write to the pins 0-4 on GPIOB (in select_rows)
|
||||
uint8_t buf[] = {IODIRA, 0b11111111, 0b11110000};
|
||||
mcp23017_status = i2c_transmit(I2C_ADDR_WRITE, buf, sizeof(buf), I2C_TIMEOUT);
|
||||
if (!mcp23017_status) {
|
||||
// set pull-up
|
||||
// - unused : on : 1
|
||||
// - input : on : 1
|
||||
// - driving : off : 0
|
||||
// This means: we will read all the bits on GPIOA
|
||||
// This means: we will write to the pins 0-4 on GPIOB (in select_rows)
|
||||
uint8_t pullup_buf[] = {GPPUA, 0b11111111, 0b11110000};
|
||||
mcp23017_status = i2c_transmit(I2C_ADDR_WRITE, pullup_buf, sizeof(pullup_buf), I2C_TIMEOUT);
|
||||
}
|
||||
return mcp23017_status;
|
||||
}
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS]; // debounced values
|
||||
|
||||
static matrix_row_t read_cols(uint8_t row);
|
||||
static void init_cols(void);
|
||||
static void unselect_rows(void);
|
||||
static void select_row(uint8_t row);
|
||||
|
||||
static uint8_t mcp23017_reset_loop;
|
||||
|
||||
void matrix_init_custom(void) {
|
||||
// initialize row and col
|
||||
|
||||
mcp23017_status = init_mcp23017();
|
||||
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void matrix_power_up(void) {
|
||||
mcp23017_status = init_mcp23017();
|
||||
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Reads and stores a row, returning
|
||||
// whether a change occurred.
|
||||
static inline bool store_matrix_row(matrix_row_t current_matrix[], uint8_t index) {
|
||||
matrix_row_t temp = read_cols(index);
|
||||
if (current_matrix[index] != temp) {
|
||||
current_matrix[index] = temp;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
||||
if (mcp23017_status) { // if there was an error
|
||||
if (++mcp23017_reset_loop == 0) {
|
||||
// if (++mcp23017_reset_loop >= 1300) {
|
||||
// since mcp23017_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans
|
||||
// this will be approx bit more frequent than once per second
|
||||
dprint("trying to reset mcp23017\n");
|
||||
mcp23017_status = init_mcp23017();
|
||||
if (mcp23017_status) {
|
||||
dprint("right side not responding\n");
|
||||
} else {
|
||||
dprint("right side attached\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
|
||||
// select rows from left and right hands
|
||||
uint8_t left_index = i;
|
||||
uint8_t right_index = i + MATRIX_ROWS_PER_SIDE;
|
||||
select_row(left_index);
|
||||
select_row(right_index);
|
||||
|
||||
// we don't need a 30us delay anymore, because selecting a
|
||||
// left-hand row requires more than 30us for i2c.
|
||||
|
||||
changed |= store_matrix_row(current_matrix, left_index);
|
||||
changed |= store_matrix_row(current_matrix, right_index);
|
||||
|
||||
unselect_rows();
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
static void init_cols(void) {
|
||||
// init on mcp23017
|
||||
// not needed, already done as part of init_mcp23017()
|
||||
|
||||
// init on mcu
|
||||
pin_t matrix_col_pins_mcu[MATRIX_COLS_PER_SIDE] = MATRIX_COL_PINS_MCU;
|
||||
for (int pin_index = 0; pin_index < MATRIX_COLS_PER_SIDE; pin_index++) {
|
||||
pin_t pin = matrix_col_pins_mcu[pin_index];
|
||||
setPinInput(pin);
|
||||
writePinHigh(pin);
|
||||
}
|
||||
}
|
||||
|
||||
static matrix_row_t read_cols(uint8_t row) {
|
||||
if (row < MATRIX_ROWS_PER_SIDE) {
|
||||
pin_t matrix_col_pins_mcu[MATRIX_COLS_PER_SIDE] = MATRIX_COL_PINS_MCU;
|
||||
matrix_row_t current_row_value = 0;
|
||||
// For each col...
|
||||
for (uint8_t col_index = 0; col_index < MATRIX_COLS_PER_SIDE; col_index++) {
|
||||
// Select the col pin to read (active low)
|
||||
uint8_t pin_state = readPin(matrix_col_pins_mcu[col_index]);
|
||||
|
||||
// Populate the matrix row with the state of the col pin
|
||||
current_row_value |= pin_state ? 0 : (MATRIX_ROW_SHIFTER << col_index);
|
||||
}
|
||||
return current_row_value;
|
||||
} else {
|
||||
if (mcp23017_status) { // if there was an error
|
||||
return 0;
|
||||
} else {
|
||||
uint8_t buf[] = {GPIOA};
|
||||
mcp23017_status = i2c_transmit(I2C_ADDR_WRITE, buf, sizeof(buf), I2C_TIMEOUT);
|
||||
// We read all the pins on GPIOA.
|
||||
// The initial state was all ones and any depressed key at a given column for the currently selected row will have its bit flipped to zero.
|
||||
// The return value is a row as represented in the generic matrix code were the rightmost bits represent the lower columns and zeroes represent non-depressed keys while ones represent depressed keys.
|
||||
// Since the pins connected to eact columns are sequential, and counting from zero up (col 5 -> GPIOA0, col 6 -> GPIOA1 and so on), the only transformation needed is a bitwise not to swap all zeroes and ones.
|
||||
uint8_t data[] = {0};
|
||||
if (!mcp23017_status) {
|
||||
mcp23017_status = i2c_receive(I2C_ADDR_READ, data, sizeof(data), I2C_TIMEOUT);
|
||||
data[0] = ~(data[0]);
|
||||
}
|
||||
return data[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void unselect_rows(void) {
|
||||
// no need to unselect on mcp23017, because the select step sets all
|
||||
// the other row bits high, and it's not changing to a different
|
||||
// direction
|
||||
|
||||
// unselect rows on microcontroller
|
||||
pin_t matrix_row_pins_mcu[MATRIX_ROWS_PER_SIDE] = MATRIX_ROW_PINS_MCU;
|
||||
for (int pin_index = 0; pin_index < MATRIX_ROWS_PER_SIDE; pin_index++) {
|
||||
pin_t pin = matrix_row_pins_mcu[pin_index];
|
||||
setPinInput(pin);
|
||||
writePinLow(pin);
|
||||
}
|
||||
}
|
||||
|
||||
static void select_row(uint8_t row) {
|
||||
if (row < MATRIX_ROWS_PER_SIDE) {
|
||||
// select on atmega32u4
|
||||
pin_t matrix_row_pins_mcu[MATRIX_ROWS_PER_SIDE] = MATRIX_ROW_PINS_MCU;
|
||||
pin_t pin = matrix_row_pins_mcu[row];
|
||||
setPinOutput(pin);
|
||||
writePinLow(pin);
|
||||
} else {
|
||||
// select on mcp23017
|
||||
if (mcp23017_status) { // if there was an error
|
||||
// do nothing
|
||||
} else {
|
||||
// Select the desired row by writing a byte for the entire GPIOB bus where only the bit representing the row we want to select is a zero (write instruction) and every other bit is a one.
|
||||
// Note that the row - MATRIX_ROWS_PER_SIDE reflects the fact that being on the right hand, the columns are numbered from MATRIX_ROWS_PER_SIDE to MATRIX_ROWS, but the pins we want to write to are indexed from zero up on the GPIOB bus.
|
||||
uint8_t buf[] = {GPIOB, 0xFF & ~(1 << (row - MATRIX_ROWS_PER_SIDE))};
|
||||
mcp23017_status = i2c_transmit(I2C_ADDR_WRITE, buf, sizeof(buf), I2C_TIMEOUT);
|
||||
}
|
||||
}
|
||||
}
|
19
keyboards/ingrained/readme.md
Normal file
19
keyboards/ingrained/readme.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# ingrained
|
||||
|
||||
This PCB is an integrated, USB-C to USB-C, Corne replacement.
|
||||
|
||||
* Keyboard Maintainer: [s8erdude](https://github.com/jpuerto96)
|
||||
* Hardware Supported: Ingrained PCB
|
||||
* Hardware Availability: [Open Source PCB](https://github.com/jpuerto96/crkbd)
|
||||
|
||||
Make example for this keyboard (after setting up your build environment):
|
||||
|
||||
make ingrained:default
|
||||
|
||||
Flashing example for this keyboard:
|
||||
|
||||
make ingrained:default:flash
|
||||
|
||||
To reset the board, you will want to short the pad labeled RESET on the main half (near the USB-C interconnect).
|
||||
|
||||
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
|
27
keyboards/ingrained/rules.mk
Normal file
27
keyboards/ingrained/rules.mk
Normal file
|
@ -0,0 +1,27 @@
|
|||
# MCU name
|
||||
MCU = atmega32u4
|
||||
|
||||
# Bootloader selection
|
||||
BOOTLOADER = atmel-dfu
|
||||
|
||||
# Build Options
|
||||
# change yes to no to disable
|
||||
#
|
||||
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = no # Enable N-Key Rollover
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
UNICODE_ENABLE = yes
|
||||
CUSTOM_MATRIX = lite
|
||||
NO_USB_STARTUP_CHECK = yes
|
||||
LTO_ENABLE = yes
|
||||
|
||||
SRC += matrix.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
|
||||
LAYOUTS = split_3x5_3 split_3x6_3
|
Loading…
Reference in a new issue