Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Sofle config with APM32 support. #24867

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions keyboards/sofle/apm32/chconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* 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/cannonkeys/tsukuyomi/chconf.h -r platforms/chibios/common/configs/chconf.h`
*/

#pragma once

#define CH_CFG_ST_FREQUENCY 10000

#define CH_CFG_OPTIMIZE_SPEED FALSE

#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE

#include_next <chconf.h>

59 changes: 59 additions & 0 deletions keyboards/sofle/apm32/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* Copyright
* 2021 solartempest
* 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

#define DEBUG_TO_SCREEN 1

#define EE_HANDS

//#define SPLIT_USB_DETECT
//#define SPLIT_MASTER_TIMER 2000

#define MASTER_RIGHT

// OLED settings
#undef OLED_ENABLE
#define OLED_ENABLE
#define OLED_TIMEOUT 80000
#define OLED_BRIGHTNESS 90

//#define OLED_IC OLED_IC_SSD1306
#define OLED_DC_PIN B6
#define OLED_CS_PIN B7

#define I2C1_SCL_PIN B6
#define I2C1_SDA_PIN B7
#define I2C_DRIVER I2CD1

#define SERIAL_USART_HALF_DUPLEX // Enable full duplex operation mode.
#define SERIAL_USART_DRIVER SD2
#define SERIAL_USART_TX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7
#define SERIAL_USART_RX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7
#define SERIAL_USART_TIMEOUT 100 // USART driver timeout. default 100
#define SERIAL_USART_SPEED 921600


#define BACKLIGHT_PWM_DRIVER PWMD3
#define BACKLIGHT_PWM_CHANNEL 1
#define BACKLIGHT_PAL_MODE 1

#define WS2812_SPI_DRIVER SPID2
#define WS2812_SPI_MOSI_PAL_MODE 0
#define WS2812_SPI_SCK_PAL_MODE 0
#define WS2812_SPI_SCK_PIN B13
37 changes: 37 additions & 0 deletions keyboards/sofle/apm32/halconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* 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/sofle/apm32/halconf.h -r platforms/chibios/common/configs/halconf.h`
*/

#pragma once

// For OLED?
#define HAL_USE_I2C TRUE

// Backlight
#define HAL_USE_PWM TRUE

// For RGB?
#define HAL_USE_SPI TRUE

// For split comms?
#define HAL_USE_SERIAL TRUE

#include_next <halconf.h>

164 changes: 164 additions & 0 deletions keyboards/sofle/apm32/keyboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
"keyboard_name": "Sofle",
"manufacturer": "JosefAdamcik",
"processor": "STM32F072",
"bootloader": "stm32-dfu",
"usb": {
"pid": "0x1289",
"device_version": "0.0.2"
},
"matrix_pins": {
"cols": ["A2", "A4", "A5", "B0", "B1", "B2"],
"rows": ["B10", "B10", "A7", "A6", "C13"]
},
"diode_direction": "COL2ROW",
"rgblight": {
"led_count": 76,
"default": {
"on": true
},
"driver": "ws2812",
"split": true,
"split_count": [37, 37],
"animations": {
"breathing": true,
"rainbow_mood": true,
"rainbow_swirl": true,
"snake": true,
"knight": true,
"christmas": true,
"static_gradient": true,
"rgb_test": true,
"alternating": true,
"twinkle": true
}
},
"ws2812": {
"pin": "B15",
"driver": "spi"
},
"features": {
"bootmagic": false,
"mousekey": false,
"extrakey": false,
"console": true,
"command": true,
"nkro": false,
"backlight": false,
"oled": true,
"rgblight": true
},
"encoder": {
"rotary": [
{"pin_a": "A1", "pin_b": "A0"}
]
},
"split": {
"enabled": true,
"encoder": {
"right": {
"rotary": [
{"pin_a": "A1", "pin_b": "A0", "resolution": 2}
]
}
},
"serial": {
"pin": "A2",
"driver": "usart"
},
"matrix_pins": {
"right": {
"cols": ["B9", "C13", "C14", "C15", "A7", "A6"],
"rows": ["A15", "B3", "B4", "B5", "B8"]
}
},
"transport": {
"sync": {
"matrix_state": true,
"oled": true,
"wpm": true
}
}
},
"qmk": {
"locking": {
"enabled": true,
"resync": true
}
},
"layouts": {
"LAYOUT": {
"layout": [
{"matrix": [0, 0], "x": 0, "y": 0.5},
{"matrix": [0, 1], "x": 1, "y": 0.375},
{"matrix": [0, 2], "x": 2, "y": 0.125},
{"matrix": [0, 3], "x": 3, "y": 0},
{"matrix": [0, 4], "x": 4, "y": 0.125},
{"matrix": [0, 5], "x": 5, "y": 0.25},

{"matrix": [5, 5], "x": 10.5, "y": 0.25},
{"matrix": [5, 4], "x": 11.5, "y": 0.125},
{"matrix": [5, 3], "x": 12.5, "y": 0},
{"matrix": [5, 2], "x": 13.5, "y": 0.125},
{"matrix": [5, 1], "x": 14.5, "y": 0.375},
{"matrix": [5, 0], "x": 15.5, "y": 0.5},

{"matrix": [1, 0], "x": 0, "y": 1.5},
{"matrix": [1, 1], "x": 1, "y": 1.375},
{"matrix": [1, 2], "x": 2, "y": 1.125},
{"matrix": [1, 3], "x": 3, "y": 1},
{"matrix": [1, 4], "x": 4, "y": 1.125},
{"matrix": [1, 5], "x": 5, "y": 1.25},

{"matrix": [6, 5], "x": 10.5, "y": 1.25},
{"matrix": [6, 4], "x": 11.5, "y": 1.125},
{"matrix": [6, 3], "x": 12.5, "y": 1},
{"matrix": [6, 2], "x": 13.5, "y": 1.125},
{"matrix": [6, 1], "x": 14.5, "y": 1.375},
{"matrix": [6, 0], "x": 15.5, "y": 1.5},

{"matrix": [2, 0], "x": 0, "y": 2.5},
{"matrix": [2, 1], "x": 1, "y": 2.375},
{"matrix": [2, 2], "x": 2, "y": 2.125},
{"matrix": [2, 3], "x": 3, "y": 2},
{"matrix": [2, 4], "x": 4, "y": 2.125},
{"matrix": [2, 5], "x": 5, "y": 2.25},

{"matrix": [7, 5], "x": 10.5, "y": 2.25},
{"matrix": [7, 4], "x": 11.5, "y": 2.125},
{"matrix": [7, 3], "x": 12.5, "y": 2},
{"matrix": [7, 2], "x": 13.5, "y": 2.125},
{"matrix": [7, 1], "x": 14.5, "y": 2.375},
{"matrix": [7, 0], "x": 15.5, "y": 2.5},

{"matrix": [3, 0], "x": 0, "y": 3.5},
{"matrix": [3, 1], "x": 1, "y": 3.375},
{"matrix": [3, 2], "x": 2, "y": 3.125},
{"matrix": [3, 3], "x": 3, "y": 3},
{"matrix": [3, 4], "x": 4, "y": 3.125},
{"matrix": [3, 5], "x": 5, "y": 3.25},
{"matrix": [4, 0], "x": 6, "y": 2.75},

{"matrix": [9, 5], "x": 9.5, "y": 2.75},
{"matrix": [8, 5], "x": 10.5, "y": 3.25},
{"matrix": [8, 4], "x": 11.5, "y": 3.125},
{"matrix": [8, 3], "x": 12.5, "y": 3},
{"matrix": [8, 2], "x": 13.5, "y": 3.125},
{"matrix": [8, 1], "x": 14.5, "y": 3.375},
{"matrix": [8, 0], "x": 15.5, "y": 3.5},

{"matrix": [4, 1], "x": 1.5, "y": 4.375},
{"matrix": [4, 2], "x": 2.5, "y": 4.125},
{"matrix": [4, 3], "x": 3.5, "y": 4.15},
{"matrix": [4, 4], "x": 4.5, "y": 4.25},
{"matrix": [4, 5], "x": 6, "y": 4.25, "h": 1.5},

{"matrix": [9, 4], "x": 9.5, "y": 4.25, "h": 1.5},
{"matrix": [9, 3], "x": 11, "y": 4.25},
{"matrix": [9, 2], "x": 12, "y": 4.15},
{"matrix": [9, 1], "x": 13, "y": 4.125},
{"matrix": [9, 0], "x": 14, "y": 4.375}
]
}
}
}
51 changes: 51 additions & 0 deletions keyboards/sofle/apm32/mcuconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* 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 3 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 <https://www.gnu.org/licenses/>.
*/

#pragma once

#include_next <mcuconf.h>

// TX on A2
#undef STM32_SERIAL_USE_USART2
#define STM32_SERIAL_USE_USART2 TRUE

#undef STM32_PWM_USE_TIM3
#define STM32_PWM_USE_TIM3 TRUE

#undef STM32_SPI_USE_SPI2
#define STM32_SPI_USE_SPI2 TRUE

#undef STM32_I2C_USE_DMA
#define STM32_I2C_USE_DMA FALSE

// For OLED?
#undef STM32_I2C_USE_I2C1
#define STM32_I2C_USE_I2C1 TRUE

#undef STM32_I2C_USE_I2C2
#define STM32_I2C_USE_I2C2 TRUE

//undef STM32_SPI_USE_SPI2
//#define STM32_SPI_USE_SPI2 TRUE

/*
#undef STM32_I2C_USE_DMA
#define STM32_I2C_USE_DMA FALSE

#undef STM32_PWM_USE_TIM3
#define STM32_PWM_USE_TIM3 YES

*/
2 changes: 2 additions & 0 deletions keyboards/sofle/apm32/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Wildcard to allow APM32 MCU
DFU_SUFFIX_ARGS = -v FFFF -p FFFF
25 changes: 25 additions & 0 deletions keyboards/sofle/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@ enum custom_keycodes {
KC_LEND
};

// Debug function, should be removed in working config.
void keyboard_post_init_user(void) {
// Customise these values to desired behaviour
debug_enable=true;
debug_matrix=true;
//debug_keyboard=true;
//debug_mouse=true;
printf("Keyboard booting up...\n");
wait_ms(2000);
oled_init(OLED_ROTATION_0);
printf("OLED initialised...\n");
}


void i2c_init(void) {
printf("In I2C init...\n");
gpio_set_pin_input(B6); // Try releasing special pins for a short time
gpio_set_pin_input(B7);
wait_ms(10); // Wait for the release to happen

palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP); // Set B6 to I2C function
palSetPadMode(GPIOB, 7, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP); // Set B7 to I2C function
printf("I2C initialised...\n");
}

#define KC_QWERTY PDF(_QWERTY)
#define KC_COLEMAK PDF(_COLEMAK)

Expand Down
Loading