1
0

[Keyboard] Move Ergodox STM32 to handwired folder (#24903)

* [Keyboard] Move Erogdox STM32 to handwired folder

To minimize confusion with ZSA's ergodox EZ ST (stm32f303) and because this is basically a one-off board

* Don't forget mapping

* Fix readme
This commit is contained in:
Drashna Jaelre
2025-02-07 00:10:45 -08:00
committed by GitHub
parent 273d8d6a1a
commit 7fe168a8ed
14 changed files with 4 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
/*
Copyright 2021 QMK
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/>.
*/
#pragma once
#include_next <board.h>
#ifdef STM32_LSECLK
#undef STM32_LSECLK
#endif // STM32_LSECLK
#define STM32_LSECLK 32768
#ifdef STM32_HSECLK
#undef STM32_HSECLK
#endif // STM32_HSECLK
#define STM32_HSECLK 8000000
#undef VAL_GPIOACRL
#define VAL_GPIOACRL 0x88888888
#undef VAL_GPIOAODR
#define VAL_GPIOAODR 0xFFFFFFFF
#undef VAL_GPIOCCRH
#define VAL_GPIOCCRH 0x88888888

View File

@@ -0,0 +1,61 @@
/* Copyright 2020 QMK
*
* 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 file was auto-generated by:
* `qmk chibios-confmigrate -i keyboards/ergodox_stm32/chconf.h -r platforms/chibios/common/configs/chconf.h`
*/
#pragma once
#define CH_CFG_ST_TIMEDELTA 0
#define CH_CFG_TIME_QUANTUM 20
#define CH_CFG_USE_REGISTRY TRUE
#define CH_CFG_USE_WAITEXIT TRUE
#define CH_CFG_USE_CONDVARS TRUE
#define CH_CFG_USE_MESSAGES TRUE
#define CH_CFG_USE_MAILBOXES TRUE
#define CH_CFG_USE_HEAP TRUE
#define CH_CFG_USE_MEMPOOLS TRUE
#define CH_CFG_USE_OBJ_FIFOS TRUE
#define CH_CFG_USE_PIPES TRUE
#define CH_CFG_USE_DYNAMIC TRUE
#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
#define CH_CFG_FACTORY_SEMAPHORES TRUE
#define CH_CFG_FACTORY_MAILBOXES TRUE
#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
#define CH_CFG_FACTORY_PIPES TRUE
#include_next <chconf.h>

View File

@@ -0,0 +1,31 @@
/*
Copyright 2019 Yaotian Feng(Codetector) <codetector@codetector.cn>
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/>.
*/
#pragma once
#define MATRIX_ROWS 14
#define MATRIX_ROWS_PER_SIDE (MATRIX_ROWS / 2)
#define MATRIX_COLS 6
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || \
keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \
)
// i2c_master driver config
#define I2C1_CLOCK_SPEED 400000
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2

View File

@@ -0,0 +1,74 @@
#include "ergodox_stm32.h"
#include "i2c_master.h"
extern inline void ergodox_board_led_1_on(void);
extern inline void ergodox_board_led_2_on(void);
extern inline void ergodox_board_led_3_on(void);
extern inline void ergodox_board_led_1_off(void);
extern inline void ergodox_board_led_2_off(void);
extern inline void ergodox_board_led_3_off(void);
extern inline void ergodox_led_all_off(void);
volatile int mcp23017_status = 0x20;
uint8_t i2c_initializied = 0;
void board_init(void) {
AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE;
}
void bootloader_jump(void) {
// This board doesn't use the "standard" stm32duino bootloader, and is resident in memory at the base location. All we can do here is reset.
NVIC_SystemReset();
}
void matrix_init_kb(void)
{
// Init LED Ports
palSetPadMode(GPIOA, 10, PAL_MODE_OUTPUT_PUSHPULL); // LED 1
palSetPadMode(GPIOA, 9, PAL_MODE_OUTPUT_PUSHPULL); // LED 2
palSetPadMode(GPIOA, 8, PAL_MODE_OUTPUT_PUSHPULL); // LED 3
ergodox_blink_all_leds();
matrix_init_user();
}
void ergodox_blink_all_leds(void)
{
ergodox_led_all_off();
// ergodox_led_all_set(LED_BRIGHTNESS_DEFAULT);
ergodox_board_led_1_on();
wait_ms(50);
ergodox_board_led_2_on();
wait_ms(50);
ergodox_board_led_3_on();
wait_ms(50);
ergodox_board_led_1_off();
wait_ms(50);
ergodox_board_led_2_off();
wait_ms(50);
ergodox_board_led_3_off();
}
uint8_t init_mcp23017(void) {
if (!i2c_initializied) {
i2c_init();
i2c_initializied = 1;
}
uint8_t data[2];
data[0] = 0x0;
data[1] = 0b00111111;
mcp23017_status = i2c_write_register(I2C_ADDR, I2C_IODIRA, data, 2, 50000);
if (mcp23017_status) goto out;
data[0] = 0xFFU;
mcp23017_status = i2c_write_register(I2C_ADDR, I2C_GPIOA, data, 1, 5000);
if (mcp23017_status) goto out;
mcp23017_status = i2c_write_register(I2C_ADDR, I2C_GPPUB, data+1, 1, 2);
if (mcp23017_status) goto out;
out:
return mcp23017_status;
// i2c_read_register(I2C_ADDR, );
}

View File

@@ -0,0 +1,37 @@
#pragma once
#include "quantum.h"
#include "action_layer.h"
#include <stdint.h>
#include <stdbool.h>
#include <hal.h>
// #define I2C_ADDR 0b01000000
#define I2C_ADDR 0b01000000
#define I2C_IODIRA 0x0
#define I2C_IODIRB 0x1
#define I2C_GPIOA 0x12
#define I2C_GPIOB 0x13
#define I2C_OLATA 0x14
#define I2C_OLATB 0x15
#define I2C_GPPUA 0x0C
#define I2C_GPPUB 0x0D
inline void ergodox_board_led_1_on(void) { palSetPad(GPIOA, 10); }
inline void ergodox_board_led_2_on(void) { palSetPad(GPIOA, 9); }
inline void ergodox_board_led_3_on(void) { palSetPad(GPIOA, 8); }
inline void ergodox_board_led_1_off(void) { palClearPad(GPIOA, 10); }
inline void ergodox_board_led_2_off(void) { palClearPad(GPIOA, 9); }
inline void ergodox_board_led_3_off(void) { palClearPad(GPIOA, 8); }
inline void ergodox_led_all_off(void)
{
palClearPad(GPIOA, 10);
palClearPad(GPIOA, 9);
palClearPad(GPIOA, 8);
}
extern volatile int mcp23017_status;
uint8_t init_mcp23017(void);
void ergodox_blink_all_leds(void);

View File

@@ -0,0 +1,27 @@
/* Copyright 2020 QMK
*
* 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 file was auto-generated by:
* `qmk chibios-confmigrate -i keyboards/ergodox_stm32/halconf.h -r platforms/chibios/common/configs/halconf.h`
*/
#pragma once
#define HAL_USE_I2C TRUE
#include_next <halconf.h>

View File

@@ -0,0 +1,214 @@
{
"keyboard_name": "ErgoDox STM32",
"manufacturer": "ErgoDox",
"url": "github.com/codetector1374",
"maintainer": "codetector1374",
"usb": {
"vid": "0xFEED",
"pid": "0x1308",
"device_version": "1.0.1"
},
"features": {
"bootmagic": false,
"mousekey": false,
"extrakey": true,
"nkro": true,
"unicode": true
},
"processor": "STM32F103",
"bootloader": "custom",
"community_layouts": ["ergodox"],
"layouts": {
"LAYOUT_ergodox": {
"layout": [
{"matrix": [0, 0], "x": 0, "y": 0.375, "w": 1.5},
{"matrix": [1, 0], "x": 1.5, "y": 0.375},
{"matrix": [2, 0], "x": 2.5, "y": 0.125},
{"matrix": [3, 0], "x": 3.5, "y": 0},
{"matrix": [4, 0], "x": 4.5, "y": 0.125},
{"matrix": [5, 0], "x": 5.5, "y": 0.25},
{"matrix": [6, 0], "x": 6.5, "y": 0.25},
{"matrix": [0, 1], "x": 0, "y": 1.375, "w": 1.5},
{"matrix": [1, 1], "x": 1.5, "y": 1.375},
{"matrix": [2, 1], "x": 2.5, "y": 1.125},
{"matrix": [3, 1], "x": 3.5, "y": 1},
{"matrix": [4, 1], "x": 4.5, "y": 1.125},
{"matrix": [5, 1], "x": 5.5, "y": 1.25},
{"matrix": [6, 1], "x": 6.5, "y": 1.25, "h": 1.5},
{"matrix": [0, 2], "x": 0, "y": 2.375, "w": 1.5},
{"matrix": [1, 2], "x": 1.5, "y": 2.375},
{"matrix": [2, 2], "x": 2.5, "y": 2.125},
{"matrix": [3, 2], "x": 3.5, "y": 2},
{"matrix": [4, 2], "x": 4.5, "y": 2.125},
{"matrix": [5, 2], "x": 5.5, "y": 2.25},
{"matrix": [0, 3], "x": 0, "y": 3.375, "w": 1.5},
{"matrix": [1, 3], "x": 1.5, "y": 3.375},
{"matrix": [2, 3], "x": 2.5, "y": 3.125},
{"matrix": [3, 3], "x": 3.5, "y": 3},
{"matrix": [4, 3], "x": 4.5, "y": 3.125},
{"matrix": [5, 3], "x": 5.5, "y": 3.25},
{"matrix": [6, 3], "x": 6.5, "y": 2.75, "h": 1.5},
{"matrix": [0, 4], "x": 0.5, "y": 4.375},
{"matrix": [1, 4], "x": 1.5, "y": 4.375},
{"matrix": [2, 4], "x": 2.5, "y": 4.125},
{"matrix": [3, 4], "x": 3.5, "y": 4},
{"matrix": [4, 4], "x": 4.5, "y": 4.125},
{"matrix": [5, 5], "x": 6, "y": 5},
{"matrix": [6, 5], "x": 7, "y": 5},
{"matrix": [4, 5], "x": 7, "y": 6},
{"matrix": [3, 5], "x": 5, "y": 6, "h": 2},
{"matrix": [2, 5], "x": 6, "y": 6, "h": 2},
{"matrix": [1, 5], "x": 7, "y": 7},
{"matrix": [7, 0], "x": 9.5, "y": 0.25},
{"matrix": [8, 0], "x": 10.5, "y": 0.25},
{"matrix": [9, 0], "x": 11.5, "y": 0.125},
{"matrix": [10, 0], "x": 12.5, "y": 0},
{"matrix": [11, 0], "x": 13.5, "y": 0.125},
{"matrix": [12, 0], "x": 14.5, "y": 0.375},
{"matrix": [13, 0], "x": 15.5, "y": 0.375, "w": 1.5},
{"matrix": [7, 1], "x": 9.5, "y": 1.25, "h": 1.5},
{"matrix": [8, 1], "x": 10.5, "y": 1.25},
{"matrix": [9, 1], "x": 11.5, "y": 1.125},
{"matrix": [10, 1], "x": 12.5, "y": 1},
{"matrix": [11, 1], "x": 13.5, "y": 1.125},
{"matrix": [12, 1], "x": 14.5, "y": 1.375},
{"matrix": [13, 1], "x": 15.5, "y": 1.375, "w": 1.5},
{"matrix": [8, 2], "x": 10.5, "y": 2.25},
{"matrix": [9, 2], "x": 11.5, "y": 2.125},
{"matrix": [10, 2], "x": 12.5, "y": 2},
{"matrix": [11, 2], "x": 13.5, "y": 2.125},
{"matrix": [12, 2], "x": 14.5, "y": 2.375},
{"matrix": [13, 2], "x": 15.5, "y": 2.375, "w": 1.5},
{"matrix": [7, 3], "x": 9.5, "y": 2.75, "h": 1.5},
{"matrix": [8, 3], "x": 10.5, "y": 3.25},
{"matrix": [9, 3], "x": 11.5, "y": 3.125},
{"matrix": [10, 3], "x": 12.5, "y": 3},
{"matrix": [11, 3], "x": 13.5, "y": 3.125},
{"matrix": [12, 3], "x": 14.5, "y": 3.375},
{"matrix": [13, 3], "x": 15.5, "y": 3.375, "w": 1.5},
{"matrix": [9, 4], "x": 11.5, "y": 4.125},
{"matrix": [10, 4], "x": 12.5, "y": 4},
{"matrix": [11, 4], "x": 13.5, "y": 4.125},
{"matrix": [12, 4], "x": 14.5, "y": 4.375},
{"matrix": [13, 4], "x": 15.5, "y": 4.375},
{"matrix": [7, 5], "x": 9, "y": 5},
{"matrix": [8, 5], "x": 10, "y": 5},
{"matrix": [9, 5], "x": 9, "y": 6},
{"matrix": [12, 5], "x": 9, "y": 7},
{"matrix": [11, 5], "x": 10, "y": 6, "h": 2},
{"matrix": [10, 5], "x": 11, "y": 6, "h": 2}
]
},
"LAYOUT_ergodox_pretty": {
"layout": [
{"matrix": [0, 0], "x": 0, "y": 0.375, "w": 1.5},
{"matrix": [1, 0], "x": 1.5, "y": 0.375},
{"matrix": [2, 0], "x": 2.5, "y": 0.125},
{"matrix": [3, 0], "x": 3.5, "y": 0},
{"matrix": [4, 0], "x": 4.5, "y": 0.125},
{"matrix": [5, 0], "x": 5.5, "y": 0.25},
{"matrix": [6, 0], "x": 6.5, "y": 0.25},
{"matrix": [7, 0], "x": 9.5, "y": 0.25},
{"matrix": [8, 0], "x": 10.5, "y": 0.25},
{"matrix": [9, 0], "x": 11.5, "y": 0.125},
{"matrix": [10, 0], "x": 12.5, "y": 0},
{"matrix": [11, 0], "x": 13.5, "y": 0.125},
{"matrix": [12, 0], "x": 14.5, "y": 0.375},
{"matrix": [13, 0], "x": 15.5, "y": 0.375, "w": 1.5},
{"matrix": [0, 1], "x": 0, "y": 1.375, "w": 1.5},
{"matrix": [1, 1], "x": 1.5, "y": 1.375},
{"matrix": [2, 1], "x": 2.5, "y": 1.125},
{"matrix": [3, 1], "x": 3.5, "y": 1},
{"matrix": [4, 1], "x": 4.5, "y": 1.125},
{"matrix": [5, 1], "x": 5.5, "y": 1.25},
{"matrix": [6, 1], "x": 6.5, "y": 1.25, "h": 1.5},
{"matrix": [7, 1], "x": 9.5, "y": 1.25, "h": 1.5},
{"matrix": [8, 1], "x": 10.5, "y": 1.25},
{"matrix": [9, 1], "x": 11.5, "y": 1.125},
{"matrix": [10, 1], "x": 12.5, "y": 1},
{"matrix": [11, 1], "x": 13.5, "y": 1.125},
{"matrix": [12, 1], "x": 14.5, "y": 1.375},
{"matrix": [13, 1], "x": 15.5, "y": 1.375, "w": 1.5},
{"matrix": [0, 2], "x": 0, "y": 2.375, "w": 1.5},
{"matrix": [1, 2], "x": 1.5, "y": 2.375},
{"matrix": [2, 2], "x": 2.5, "y": 2.125},
{"matrix": [3, 2], "x": 3.5, "y": 2},
{"matrix": [4, 2], "x": 4.5, "y": 2.125},
{"matrix": [5, 2], "x": 5.5, "y": 2.25},
{"matrix": [8, 2], "x": 10.5, "y": 2.25},
{"matrix": [9, 2], "x": 11.5, "y": 2.125},
{"matrix": [10, 2], "x": 12.5, "y": 2},
{"matrix": [11, 2], "x": 13.5, "y": 2.125},
{"matrix": [12, 2], "x": 14.5, "y": 2.375},
{"matrix": [13, 2], "x": 15.5, "y": 2.375, "w": 1.5},
{"matrix": [0, 3], "x": 0, "y": 3.375, "w": 1.5},
{"matrix": [1, 3], "x": 1.5, "y": 3.375},
{"matrix": [2, 3], "x": 2.5, "y": 3.125},
{"matrix": [3, 3], "x": 3.5, "y": 3},
{"matrix": [4, 3], "x": 4.5, "y": 3.125},
{"matrix": [5, 3], "x": 5.5, "y": 3.25},
{"matrix": [6, 3], "x": 6.5, "y": 2.75, "h": 1.5},
{"matrix": [7, 3], "x": 9.5, "y": 2.75, "h": 1.5},
{"matrix": [8, 3], "x": 10.5, "y": 3.25},
{"matrix": [9, 3], "x": 11.5, "y": 3.125},
{"matrix": [10, 3], "x": 12.5, "y": 3},
{"matrix": [11, 3], "x": 13.5, "y": 3.125},
{"matrix": [12, 3], "x": 14.5, "y": 3.375},
{"matrix": [13, 3], "x": 15.5, "y": 3.375, "w": 1.5},
{"matrix": [0, 4], "x": 0.5, "y": 4.375},
{"matrix": [1, 4], "x": 1.5, "y": 4.375},
{"matrix": [2, 4], "x": 2.5, "y": 4.125},
{"matrix": [3, 4], "x": 3.5, "y": 4},
{"matrix": [4, 4], "x": 4.5, "y": 4.125},
{"matrix": [9, 4], "x": 11.5, "y": 4.125},
{"matrix": [10, 4], "x": 12.5, "y": 4},
{"matrix": [11, 4], "x": 13.5, "y": 4.125},
{"matrix": [12, 4], "x": 14.5, "y": 4.375},
{"matrix": [13, 4], "x": 15.5, "y": 4.375},
{"matrix": [5, 5], "x": 6, "y": 5},
{"matrix": [6, 5], "x": 7, "y": 5},
{"matrix": [7, 5], "x": 9, "y": 5},
{"matrix": [8, 5], "x": 10, "y": 5},
{"matrix": [4, 5], "x": 7, "y": 6},
{"matrix": [9, 5], "x": 9, "y": 6},
{"matrix": [3, 5], "x": 5, "y": 6, "h": 2},
{"matrix": [2, 5], "x": 6, "y": 6, "h": 2},
{"matrix": [1, 5], "x": 7, "y": 7},
{"matrix": [12, 5], "x": 9, "y": 7},
{"matrix": [11, 5], "x": 10, "y": 6, "h": 2},
{"matrix": [10, 5], "x": 11, "y": 6, "h": 2}
]
}
}
}

View File

@@ -0,0 +1,52 @@
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_ergodox(KC_GRAVE,KC_1,KC_2,KC_3,KC_4,KC_5,KC_MINUS,KC_TAB,KC_Q,KC_W,KC_E,KC_R,KC_T,KC_LPRN,KC_ESCAPE,KC_A,KC_S,KC_D,KC_F,KC_G,KC_LSFT,KC_Z,KC_X,KC_C,KC_V,KC_B,KC_RPRN,KC_LCTL,KC_LGUI,KC_LALT,KC_LGUI,KC_LALT,KC_INSERT,MO(1),KC_HOME,KC_SPACE,KC_DELETE,KC_END,KC_EQUAL,KC_6,KC_7,KC_8,KC_9,KC_0,KC_BSPC,KC_LBRC,KC_Y,KC_U,KC_I,KC_O,KC_P,KC_BSLS,KC_H,KC_J,KC_K,KC_L,KC_SCLN,KC_QUOTE,KC_RBRC,KC_N,KC_M,KC_COMMA,KC_DOT,KC_SLASH,KC_RSFT,KC_LEFT,KC_DOWN,KC_UP,KC_RIGHT,KC_RCTL,MO(1),TG(2),KC_PGUP,KC_PGDN,KC_BSPC,KC_ENTER),
[1] = LAYOUT_ergodox(KC_TILD,KC_F1,KC_F2,KC_F3,KC_F4,KC_F5,KC_F6,KC_GRAVE,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_CAPS,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_MEDIA_PLAY_PAUSE,KC_TRANSPARENT,KC_TRANSPARENT,KC_F7,KC_F8,KC_F9,KC_F10,KC_F11,KC_F12,KC_BSPC,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,LCTL(LGUI(KC_Q)),KC_MEDIA_PREV_TRACK,KC_MEDIA_NEXT_TRACK,KC_AUDIO_VOL_DOWN,KC_AUDIO_VOL_UP),
[2] = LAYOUT_ergodox(KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_NUM,KC_KP_SLASH,KC_KP_ASTERISK,KC_KP_MINUS,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_KP_7,KC_KP_8,KC_KP_9,KC_KP_PLUS,KC_TRANSPARENT,KC_TRANSPARENT,KC_KP_4,KC_KP_5,KC_KP_6,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_KP_1,KC_KP_2,KC_KP_3,KC_ENTER,KC_TRANSPARENT,KC_KP_DOT,KC_KP_0,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT,KC_TRANSPARENT),
};
layer_state_t layer_state_set_user(layer_state_t state) {
uint8_t layer = get_highest_layer(state);
ergodox_led_all_off();
ergodox_board_led_1_off();
ergodox_board_led_2_off();
ergodox_board_led_3_off();
switch (layer) {
case 1:
ergodox_board_led_1_on();
break;
case 2:
ergodox_board_led_2_on();
break;
case 3:
ergodox_board_led_2_on();
break;
case 4:
ergodox_board_led_1_on();
ergodox_board_led_2_on();
break;
case 5:
ergodox_board_led_1_on();
ergodox_board_led_3_on();
break;
case 6:
ergodox_board_led_2_on();
ergodox_board_led_3_on();
break;
case 7:
ergodox_board_led_1_on();
ergodox_board_led_2_on();
ergodox_board_led_3_on();
break;
default:
break;
}
return state;
};

View File

@@ -0,0 +1,85 @@
/*
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
* ST32F103xB memory setup for use with the originaljm60 bootloader.
*/
MEMORY
{
flash0 : org = 0x08000000, len = 64k /* TODO */
flash1 : org = 0x00000000, len = 0
flash2 : org = 0x00000000, len = 0
flash3 : org = 0x00000000, len = 0
flash4 : org = 0x00000000, len = 0
flash5 : org = 0x00000000, len = 0
flash6 : org = 0x00000000, len = 0
flash7 : org = 0x00000000, len = 0
ram0 : org = 0x20000000, len = 20k
ram1 : org = 0x00000000, len = 0
ram2 : org = 0x00000000, len = 0
ram3 : org = 0x00000000, len = 0
ram4 : org = 0x00000000, len = 0
ram5 : org = 0x00000000, len = 0
ram6 : org = 0x00000000, len = 0
ram7 : org = 0x00000000, len = 0
}
/* For each data/text section two region are defined, a virtual region
and a load region (_LMA suffix).*/
/* Flash region to be used for exception vectors.*/
REGION_ALIAS("VECTORS_FLASH", flash0);
REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
/* Flash region to be used for constructors and destructors.*/
REGION_ALIAS("XTORS_FLASH", flash0);
REGION_ALIAS("XTORS_FLASH_LMA", flash0);
/* Flash region to be used for code text.*/
REGION_ALIAS("TEXT_FLASH", flash0);
REGION_ALIAS("TEXT_FLASH_LMA", flash0);
/* Flash region to be used for read only data.*/
REGION_ALIAS("RODATA_FLASH", flash0);
REGION_ALIAS("RODATA_FLASH_LMA", flash0);
/* Flash region to be used for various.*/
REGION_ALIAS("VARIOUS_FLASH", flash0);
REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
/* Flash region to be used for RAM(n) initialization data.*/
REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
/* RAM region to be used for Main stack. This stack accommodates the processing
of all exceptions and interrupts.*/
REGION_ALIAS("MAIN_STACK_RAM", ram0);
/* RAM region to be used for the process stack. This is the stack used by
the main() function.*/
REGION_ALIAS("PROCESS_STACK_RAM", ram0);
/* RAM region to be used for data segment.*/
REGION_ALIAS("DATA_RAM", ram0);
REGION_ALIAS("DATA_RAM_LMA", flash0);
/* RAM region to be used for BSS segment.*/
REGION_ALIAS("BSS_RAM", ram0);
/* RAM region to be used for the default heap.*/
REGION_ALIAS("HEAP_RAM", ram0);
/* Generic rules inclusion.*/
INCLUDE rules.ld

View File

@@ -0,0 +1,182 @@
#include "matrix.h"
#include <string.h>
#include "timer.h"
#include "wait.h"
#include "debug.h"
#include "i2c_master.h"
#include "ergodox_stm32.h"
#ifndef DEBOUNCE
#define DEBOUNCE 10
#endif
static uint8_t mcp23017_reset_loop = 0;
volatile matrix_row_t matrix[MATRIX_ROWS];
volatile matrix_row_t raw_matrix[MATRIX_ROWS];
volatile uint8_t debounce_matrix[MATRIX_ROWS * MATRIX_COLS];
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 void init_rows(void);
__attribute__((weak)) void matrix_init_user(void) {}
__attribute__((weak)) void matrix_scan_user(void) {}
__attribute__((weak)) void matrix_init_kb(void) {
matrix_init_user();
}
__attribute__((weak)) void matrix_scan_kb(void) {
matrix_scan_user();
}
void matrix_init(void) {
mcp23017_status = init_mcp23017();
(void) mcp23017_reset_loop;
init_rows();
unselect_rows();
init_cols();
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
raw_matrix[i] = 0;
for (uint8_t j = 0; j < MATRIX_COLS; ++j) {
debounce_matrix[i * MATRIX_COLS + j] = 0;
}
}
matrix_init_kb();
}
void matrix_power_up(void) {
mcp23017_status = init_mcp23017();
init_rows();
unselect_rows();
init_cols();
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
}
}
matrix_row_t debounce_mask(matrix_row_t rawcols, uint8_t row) {
matrix_row_t result = 0;
matrix_row_t change = rawcols ^raw_matrix[row];
raw_matrix[row] = rawcols;
for (uint8_t i = 0; i < MATRIX_COLS; ++i) {
if (debounce_matrix[row * MATRIX_COLS + i]) {
--debounce_matrix[row * MATRIX_COLS + i];
} else {
result |= (1 << i);
}
if (change & (1 << i)) {
debounce_matrix[row * MATRIX_COLS + i] = DEBOUNCE;
}
}
return result;
}
matrix_row_t debounce_read_cols(uint8_t row) {
// Read the row without debouncing filtering and store it for later usage.
matrix_row_t cols = read_cols(row);
// Get the Debounce mask.
matrix_row_t mask = debounce_mask(cols, row);
// debounce the row and return the result.
return (cols & mask) | (matrix[row] & ~mask);;
}
uint8_t matrix_scan(void) {
if (mcp23017_status) {
if (++mcp23017_reset_loop == 0) {
mcp23017_status = init_mcp23017();
if (!mcp23017_status) {
ergodox_blink_all_leds();
}
}
}
for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
select_row(i);
select_row(i + MATRIX_ROWS_PER_SIDE);
matrix[i] = debounce_read_cols(i);
matrix[i + MATRIX_ROWS_PER_SIDE] = debounce_read_cols(i + MATRIX_ROWS_PER_SIDE);
unselect_rows();
}
matrix_scan_kb();
return 0;
}
inline
bool matrix_is_on(uint8_t row, uint8_t col) {
return (matrix[row] & (1 << col));
}
inline
matrix_row_t matrix_get_row(uint8_t row) {
return matrix[row];
}
void matrix_print(void) {
}
static matrix_row_t read_cols(uint8_t row) {
if (row < MATRIX_ROWS_PER_SIDE) {
uint8_t data = 0xFF;
if (!mcp23017_status) {
uint8_t regAddr = I2C_GPIOB;
mcp23017_status = i2c_read_register(I2C_ADDR, regAddr, &data, 1, 10);
}
if (mcp23017_status) {
return 0;
}
return (~data) & 0x3F;
} else {
uint8_t data_p = (GPIOB -> IDR);
uint8_t data = data_p;
return ((~data) & 0x3f);
}
}
static void init_cols(void) {
palSetPadMode(GPIOB, 0, PAL_MODE_INPUT_PULLUP);
palSetPadMode(GPIOB, 1, PAL_MODE_INPUT_PULLUP);
palSetPadMode(GPIOB, 2, PAL_MODE_INPUT_PULLUP);
palSetPadMode(GPIOB, 3, PAL_MODE_INPUT_PULLUP);
palSetPadMode(GPIOB, 4, PAL_MODE_INPUT_PULLUP);
palSetPadMode(GPIOB, 5, PAL_MODE_INPUT_PULLUP);
}
static void init_rows(void) {
palSetPadMode(GPIOB, 8, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOB, 9, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOB, 10, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOB, 11, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOB, 12, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOB, 13, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOB, 14, PAL_MODE_OUTPUT_PUSHPULL);
}
static void unselect_rows(void) {
GPIOB->BSRR = 0b1111111 << 8;
}
static void select_row(uint8_t row) {
if (row < MATRIX_ROWS_PER_SIDE) {
if (!mcp23017_status) {
uint8_t data = (0xFF & ~(1 << row));
mcp23017_status = i2c_write_register(I2C_ADDR, I2C_GPIOA, &data, 1, 10);
}
} else {
GPIOB->BRR = 0x1 << (row+1);
}
}

View File

@@ -0,0 +1,209 @@
/*
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _MCUCONF_H_
#define _MCUCONF_H_
#define STM32F103_MCUCONF
/*
* STM32F103 drivers configuration.
* The following settings override the default settings present in
* the various device driver implementation headers.
* Note that the settings for each driver only have effect if the whole
* driver is enabled in halconf.h.
*
* IRQ priorities:
* 15...0 Lowest...Highest.
*
* DMA priorities:
* 0...3 Lowest...Highest.
*/
/*
* HAL driver system settings.
*/
#define STM32_NO_INIT FALSE
#define STM32_HSI_ENABLED TRUE
#define STM32_LSI_ENABLED FALSE
#define STM32_HSE_ENABLED TRUE
#define STM32_LSE_ENABLED FALSE
#define STM32_SW STM32_SW_PLL
#define STM32_PLLSRC STM32_PLLSRC_HSE
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE 9
#define STM32_HPRE STM32_HPRE_DIV1
#define STM32_PPRE1 STM32_PPRE1_DIV2
#define STM32_PPRE2 STM32_PPRE2_DIV2
#define STM32_ADCPRE STM32_ADCPRE_DIV4
#define STM32_USB_CLOCK_REQUIRED TRUE
#define STM32_USBPRE STM32_USBPRE_DIV1P5
#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
#define STM32_RTCSEL STM32_RTCSEL_HSEDIV
#define STM32_PVD_ENABLE FALSE
#define STM32_PLS STM32_PLS_LEV0
/*
* ADC driver system settings.
*/
#define STM32_ADC_USE_ADC1 FALSE
#define STM32_ADC_ADC1_DMA_PRIORITY 2
#define STM32_ADC_ADC1_IRQ_PRIORITY 6
/*
* CAN driver system settings.
*/
#define STM32_CAN_USE_CAN1 FALSE
#define STM32_CAN_CAN1_IRQ_PRIORITY 11
/*
* EXT driver system settings.
*/
#define STM32_EXT_EXTI0_IRQ_PRIORITY 6
#define STM32_EXT_EXTI1_IRQ_PRIORITY 6
#define STM32_EXT_EXTI2_IRQ_PRIORITY 6
#define STM32_EXT_EXTI3_IRQ_PRIORITY 6
#define STM32_EXT_EXTI4_IRQ_PRIORITY 6
#define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6
#define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6
#define STM32_EXT_EXTI16_IRQ_PRIORITY 6
#define STM32_EXT_EXTI17_IRQ_PRIORITY 6
#define STM32_EXT_EXTI18_IRQ_PRIORITY 6
#define STM32_EXT_EXTI19_IRQ_PRIORITY 6
/*
* GPT driver system settings.
*/
#define STM32_GPT_USE_TIM1 FALSE
#define STM32_GPT_USE_TIM2 FALSE
#define STM32_GPT_USE_TIM3 FALSE
#define STM32_GPT_USE_TIM4 FALSE
#define STM32_GPT_USE_TIM5 FALSE
#define STM32_GPT_USE_TIM8 FALSE
#define STM32_GPT_TIM1_IRQ_PRIORITY 7
#define STM32_GPT_TIM2_IRQ_PRIORITY 7
#define STM32_GPT_TIM3_IRQ_PRIORITY 7
#define STM32_GPT_TIM4_IRQ_PRIORITY 7
#define STM32_GPT_TIM5_IRQ_PRIORITY 7
#define STM32_GPT_TIM8_IRQ_PRIORITY 7
/*
* I2C driver system settings.
*/
#define STM32_I2C_USE_I2C1 TRUE
#define STM32_I2C_USE_I2C2 FALSE
#define STM32_I2C_BUSY_TIMEOUT 50
#define STM32_I2C_I2C1_IRQ_PRIORITY 5
#define STM32_I2C_I2C2_IRQ_PRIORITY 5
#define STM32_I2C_I2C1_DMA_PRIORITY 3
#define STM32_I2C_I2C2_DMA_PRIORITY 3
#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
/*
* ICU driver system settings.
*/
#define STM32_ICU_USE_TIM1 FALSE
#define STM32_ICU_USE_TIM2 FALSE
#define STM32_ICU_USE_TIM3 FALSE
#define STM32_ICU_USE_TIM4 FALSE
#define STM32_ICU_USE_TIM5 FALSE
#define STM32_ICU_USE_TIM8 FALSE
#define STM32_ICU_TIM1_IRQ_PRIORITY 7
#define STM32_ICU_TIM2_IRQ_PRIORITY 7
#define STM32_ICU_TIM3_IRQ_PRIORITY 7
#define STM32_ICU_TIM4_IRQ_PRIORITY 7
#define STM32_ICU_TIM5_IRQ_PRIORITY 7
#define STM32_ICU_TIM8_IRQ_PRIORITY 7
/*
* PWM driver system settings.
*/
#define STM32_PWM_USE_ADVANCED FALSE
#define STM32_PWM_USE_TIM1 FALSE
#define STM32_PWM_USE_TIM2 FALSE
#define STM32_PWM_USE_TIM3 FALSE
#define STM32_PWM_USE_TIM4 FALSE
#define STM32_PWM_USE_TIM5 FALSE
#define STM32_PWM_USE_TIM8 FALSE
#define STM32_PWM_TIM1_IRQ_PRIORITY 7
#define STM32_PWM_TIM2_IRQ_PRIORITY 7
#define STM32_PWM_TIM3_IRQ_PRIORITY 7
#define STM32_PWM_TIM4_IRQ_PRIORITY 7
#define STM32_PWM_TIM5_IRQ_PRIORITY 7
#define STM32_PWM_TIM8_IRQ_PRIORITY 7
/*
* RTC driver system settings.
*/
#define STM32_RTC_IRQ_PRIORITY 15
/*
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 FALSE
#define STM32_SERIAL_USE_USART2 FALSE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USE_UART4 FALSE
#define STM32_SERIAL_USE_UART5 FALSE
#define STM32_SERIAL_USART1_PRIORITY 12
#define STM32_SERIAL_USART2_PRIORITY 12
#define STM32_SERIAL_USART3_PRIORITY 12
#define STM32_SERIAL_UART4_PRIORITY 12
#define STM32_SERIAL_UART5_PRIORITY 12
/*
* SPI driver system settings.
*/
#define STM32_SPI_USE_SPI1 FALSE
#define STM32_SPI_USE_SPI2 FALSE
#define STM32_SPI_USE_SPI3 FALSE
#define STM32_SPI_SPI1_DMA_PRIORITY 1
#define STM32_SPI_SPI2_DMA_PRIORITY 1
#define STM32_SPI_SPI3_DMA_PRIORITY 1
#define STM32_SPI_SPI1_IRQ_PRIORITY 10
#define STM32_SPI_SPI2_IRQ_PRIORITY 10
#define STM32_SPI_SPI3_IRQ_PRIORITY 10
#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
/*
* ST driver system settings.
*/
#define STM32_ST_IRQ_PRIORITY 8
#define STM32_ST_USE_TIMER 2
/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE
#define STM32_UART_USE_USART2 FALSE
#define STM32_UART_USE_USART3 FALSE
#define STM32_UART_USART1_IRQ_PRIORITY 12
#define STM32_UART_USART2_IRQ_PRIORITY 12
#define STM32_UART_USART3_IRQ_PRIORITY 12
#define STM32_UART_USART1_DMA_PRIORITY 0
#define STM32_UART_USART2_DMA_PRIORITY 0
#define STM32_UART_USART3_DMA_PRIORITY 0
#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
/*
* USB driver system settings.
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
#endif /* _MCUCONF_H_ */

View File

@@ -0,0 +1,9 @@
# ergodox_stm32
* Keyboard Maintainer: [Codetector1374](https://github.com/Codetector1374)
Make example for this keyboard (after setting up your build environment):
make handwired/ergodox_stm32:default
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).

View File

@@ -0,0 +1,8 @@
# custom bootloader
MCU_LDSCRIPT = stm32f103_bootloader
BOARD = ST_NUCLEO64_F103RB
CUSTOM_MATRIX = yes
SRC += matrix.c
I2C_DRIVER_REQUIRED = yes