Add Bonsai C4 converter (#17711)
This commit is contained in:
parent
29f47f4cf3
commit
a645301c82
|
@ -60,6 +60,12 @@
|
|||
"bootloader": "tinyuf2",
|
||||
"board": "STEMCELL",
|
||||
"pin_compatible": "promicro"
|
||||
},
|
||||
"bonsai_c4": {
|
||||
"processor": "STM32F411",
|
||||
"bootloader": "stm32-dfu",
|
||||
"board": "GENERIC_STM32_F411XE",
|
||||
"pin_compatible": "promicro"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
},
|
||||
"development_board": {
|
||||
"type": "string",
|
||||
"enum": ["promicro", "elite_c", "proton_c", "kb2040", "promicro_rp2040", "blok", "bit_c_pro", "stemcell", "bluepill", "blackpill_f401", "blackpill_f411"]
|
||||
"enum": ["promicro", "elite_c", "proton_c", "kb2040", "promicro_rp2040", "blok", "bit_c_pro", "stemcell", "bluepill", "blackpill_f401", "blackpill_f411", "bonsai_c4"]
|
||||
},
|
||||
"pin_compatible": {
|
||||
"type": "string",
|
||||
|
|
|
@ -16,6 +16,7 @@ Currently the following converters are available:
|
|||
| `promicro` | `blok` |
|
||||
| `promicro` | `bit_c_pro` |
|
||||
| `promicro` | `stemcell` |
|
||||
| `promicro` | `bonsai_c4` |
|
||||
|
||||
See below for more in depth information on each converter.
|
||||
|
||||
|
@ -50,14 +51,15 @@ Once a converter is enabled, it exposes the `CONVERT_TO_<target_uppercase>` flag
|
|||
|
||||
If a board currently supported in QMK uses a [Pro Micro](https://www.sparkfun.com/products/12640) (or compatible board), the supported alternative controllers are:
|
||||
|
||||
| Device | Target |
|
||||
|------------------------------------------------------------------------|-------------------|
|
||||
| [Proton C](https://qmk.fm/proton-c/) | `proton_c` |
|
||||
| [Adafruit KB2040](https://learn.adafruit.com/adafruit-kb2040) | `kb2040` |
|
||||
| [SparkFun Pro Micro - RP2040](https://www.sparkfun.com/products/18288) | `promicro_rp2040` |
|
||||
| [Blok](https://boardsource.xyz/store/628b95b494dfa308a6581622) | `blok` |
|
||||
| [Bit-C PRO](https://nullbits.co/bit-c-pro) | `bit_c_pro` |
|
||||
| [STeMCell](https://github.com/megamind4089/STeMCell) | `stemcell` |
|
||||
| Device | Target |
|
||||
|------------------------------------------------------------------------------------------|-------------------|
|
||||
| [Proton C](https://qmk.fm/proton-c/) | `proton_c` |
|
||||
| [Adafruit KB2040](https://learn.adafruit.com/adafruit-kb2040) | `kb2040` |
|
||||
| [SparkFun Pro Micro - RP2040](https://www.sparkfun.com/products/18288) | `promicro_rp2040` |
|
||||
| [Blok](https://boardsource.xyz/store/628b95b494dfa308a6581622) | `blok` |
|
||||
| [Bit-C PRO](https://nullbits.co/bit-c-pro) | `bit_c_pro` |
|
||||
| [STeMCell](https://github.com/megamind4089/STeMCell) | `stemcell` |
|
||||
| [customMK Bonsai C4](https://shop.custommk.com/products/bonsai-c4-microcontroller-board) | `bonsai_c4` |
|
||||
|
||||
Converter summary:
|
||||
|
||||
|
@ -69,6 +71,7 @@ Converter summary:
|
|||
| `blok` | `-e CONVERT_TO=blok` | `CONVERT_TO=blok` | `#ifdef CONVERT_TO_BLOK` |
|
||||
| `bit_c_pro` | `-e CONVERT_TO=bit_c_pro` | `CONVERT_TO=bit_c_pro` | `#ifdef CONVERT_TO_BIT_C_PRO` |
|
||||
| `stemcell` | `-e CONVERT_TO=stemcell` | `CONVERT_TO=stemcell` | `#ifdef CONVERT_TO_STEMCELL` |
|
||||
| `bonsai_c4` | `-e CONVERT_TO=bonsai_c4` | `CONVERT_TO=bonsai_c4` | `#ifdef CONVERT_TO_BONSAI_C4` |
|
||||
|
||||
### Proton C :id=proton_c
|
||||
|
||||
|
@ -121,3 +124,15 @@ The following additional flags has to be used while compiling, based on the pin
|
|||
| D2 | Not needed |
|
||||
| D1 | -e STMC_IS=yes|
|
||||
| D0 | Not needed |
|
||||
|
||||
### Bonsai C4 :id=bonsai_c4
|
||||
|
||||
The Bonsai C4 only has one on-board LED (B2), and by default, both the Pro Micro TXLED (D5) and RXLED (B0) are mapped to it. If you want only one of them mapped, you can undefine one and redefine it to another pin by adding these line to your `config.h`:
|
||||
|
||||
```c
|
||||
#undef B0
|
||||
// If Vbus detection is unused, we can send RXLED to the Vbus detect pin instead
|
||||
#define B0 PAL_LINE(GPIOA, 9)
|
||||
```
|
||||
|
||||
No peripherals are enabled by default at this time, but example code to enable SPI, I2C, PWM, and Serial communications can be found [here](/keyboards/custommk/bonsai_c4_template)
|
|
@ -0,0 +1,23 @@
|
|||
/* Copyright 2022 customMK
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
// Set up SPI slave select pin
|
||||
void keyboard_post_init_kb(void) {
|
||||
#ifdef EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN
|
||||
setPinOutput(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN);
|
||||
writePinHigh(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN);
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/* Copyright 2022 customMK
|
||||
*
|
||||
* 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 "config_common.h"
|
||||
|
||||
// This file includes example #defines to enable commonly-used functionality
|
||||
// (SPI, PWM backlight, etc.) on specific pins. Capabilities you want to include
|
||||
// should be added to the config.h for your keyboard. Not all capabilities are
|
||||
// shown; for example:
|
||||
// I2C is not shown because the QMK defaults are sufficient for SCL on B6 and SDA on B7
|
||||
// Serial communications (for split keyboards) is not shown because QMK defaults work
|
||||
// for either pins A15 or B6
|
||||
|
||||
// If you need to change pins for PWM, SPI, I2C, or Serial communications, be aware that
|
||||
// doing this may require changing the driver, channel, PAL (Pin ALternate function) mode,
|
||||
// DMA stream, and/or DMA channel.
|
||||
|
||||
|
||||
// Bonsai C4 wires up pin A9 for Vbus sensing pin by default. For spilt keyboards, this
|
||||
// can be used to determine which half of the keyboard is plugged into USB.
|
||||
// For boards using Bonsai C4 merely as a reference design, the VBUS sense pin A9
|
||||
// can be used for purposes other than Vbus sensing (e.g. the switch
|
||||
// matrix).
|
||||
//
|
||||
// If A9 is needed for Vbus sensing, uncomment the line
|
||||
// below. Most keyboards using Bonsai C4 can leave the line below
|
||||
// commented out.
|
||||
//
|
||||
// #undef BOARD_OTG_NOVBUSSENS
|
||||
|
||||
// FRAM configuration
|
||||
#define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN A0
|
||||
#define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // 96MHz / 8 = 12MHz; max supported by MB85R64 is 20MHz
|
||||
#define EXTERNAL_EEPROM_PAGE_SIZE 64 // does not matter for FRAM, just sets the RAM buffer size in STM32F chip
|
||||
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191
|
||||
|
||||
// External flash configuration
|
||||
#define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN B12
|
||||
#define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR 1 // 96MHz; max supported by W25Q128JV is 133MHz
|
||||
#define EXTERNAL_FLASH_BYTE_COUNT (16 * 1024 * 1024) //128Mbit or 16MByte
|
||||
#define EXTERNAL_FLASH_PAGE_SIZE 256
|
||||
#define EXTERNAL_FLASH_SPI_TIMEOUT 200000 //datasheet max is 200 seconds for flash chip erase
|
||||
|
||||
// SPI Configuration (needed for FRAM and FLASH)
|
||||
#define SPI_DRIVER SPID1
|
||||
#define SPI_SCK_PIN B3
|
||||
#define SPI_MOSI_PIN B5
|
||||
#define SPI_MISO_PIN B4
|
||||
|
||||
// Example code to set up PWM backlight on pin A6
|
||||
// If a different pin is used, a different PWM driver/channel settings may be necessary
|
||||
#define BACKLIGHT_PIN A6
|
||||
#define BACKLIGHT_PWM_DRIVER PWMD3
|
||||
#define BACKLIGHT_PWM_CHANNEL 1
|
||||
|
||||
// Example code for WS2812 underglow
|
||||
// Only pin A10 is wired to send 5V signals to the WS2812
|
||||
// This also usually requires adding special wiring during board assembly
|
||||
#define RGB_DI_PIN A10
|
||||
#define WS2812_PWM_DRIVER PWMD1
|
||||
#define WS2812_PWM_CHANNEL 3
|
||||
#define WS2812_PWM_PAL_MODE 1
|
||||
#define WS2812_DMA_STREAM STM32_DMA2_STREAM5
|
||||
#define WS2812_DMA_CHANNEL 6
|
|
@ -0,0 +1,35 @@
|
|||
/* Copyright 2021 customMK
|
||||
*
|
||||
* 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
|
||||
|
||||
// If you are using I2C (e.g. for OLED), include this line
|
||||
#define HAL_USE_I2C TRUE
|
||||
|
||||
// If you are using PWM (e.g. for WS2812, backlight, etc.) include this line
|
||||
#define HAL_USE_PWM TRUE
|
||||
|
||||
// If you are using serial comms for split communications, include these lines
|
||||
#define HAL_USE_SERIAL TRUE
|
||||
#define SERIAL_BUFFERS_SIZE 256
|
||||
|
||||
// If you are using SPI (e.g. for FRAM, flash, etc.) include these lines
|
||||
#define HAL_USE_SPI TRUE
|
||||
#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
|
||||
// This enables interrupt-driven mode
|
||||
#define SPI_USE_WAIT TRUE
|
||||
|
||||
#include_next <halconf.h>
|
|
@ -0,0 +1,35 @@
|
|||
/* Copyright 2022 customMK
|
||||
*
|
||||
* 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 <mcuconf.h>
|
||||
|
||||
// Used for underglow in example code
|
||||
#undef STM32_PWM_USE_TIM1 //timer 1 channel 3
|
||||
#define STM32_PWM_USE_TIM1 TRUE
|
||||
|
||||
// Used for backlight in examples
|
||||
#undef STM32_PWM_USE_TIM3 //timer 3 channel 1
|
||||
#define STM32_PWM_USE_TIM3 TRUE
|
||||
|
||||
// Used for FRAM and flash in example code
|
||||
#undef STM32_SPI_USE_SPI1
|
||||
#define STM32_SPI_USE_SPI1 TRUE
|
||||
|
||||
// Used for Split comms in example code
|
||||
#undef STM32_SERIAL_USE_USART1
|
||||
#define STM32_SERIAL_USE_USART1 TRUE
|
|
@ -0,0 +1,10 @@
|
|||
# Bonsai C4 template code
|
||||
|
||||
Currently, the converter for Pro Micro to Bonsai C4 only does pin mapping. This is sufficient for simple keyboards and also a good start for
|
||||
incorporating into more advanced keyboards with other features (like RGB, OLED, backlighting, split communiciations, etc.). However, to make
|
||||
use of the more advanced features--including using the FRAM and flash memory chip included on Bonsai C4--various peripheral hardware must
|
||||
be configured. Pro Micro does not requrie such configuration because such functionality is more limited and hard-wired to specific pins.
|
||||
|
||||
The code here provides examples that can be used to operate SPI, I2C, PWM, and Serial comms. In addition to using the converter, you will
|
||||
need to take code (as-needed) and add it to existing config.h files, or add in new halconf.h and mcuconf.h files. If you are changing which
|
||||
pins are used for certain functions, you should verify the new pins support that functionality, and check all assingments to ensure the correct settings are used (including as-applicable driver, channel, PAL (Pin ALternate function) mode, DMA stream, and/or DMA channel).
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2022 customMK
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
// Left side (front)
|
||||
#define D3 PAL_LINE(GPIOB, 7)
|
||||
#define D2 PAL_LINE(GPIOA, 15)
|
||||
// GND
|
||||
// GND
|
||||
#define D1 PAL_LINE(GPIOB, 9)
|
||||
#define D0 PAL_LINE(GPIOB, 6)
|
||||
#define D4 PAL_LINE(GPIOA, 4)
|
||||
#define C6 PAL_LINE(GPIOB, 8)
|
||||
#define D7 PAL_LINE(GPIOA, 3)
|
||||
#define E6 PAL_LINE(GPIOB, 10)
|
||||
#define B4 PAL_LINE(GPIOA, 8)
|
||||
#define B5 PAL_LINE(GPIOB, 0)
|
||||
|
||||
// Right side (front)
|
||||
// RAW
|
||||
// GND
|
||||
// RESET
|
||||
// VCC
|
||||
#define F4 PAL_LINE(GPIOA, 7)
|
||||
#define F5 PAL_LINE(GPIOA, 6)
|
||||
#define F6 PAL_LINE(GPIOA, 5)
|
||||
#define F7 PAL_LINE(GPIOA, 1)
|
||||
#define B1 PAL_LINE(GPIOB, 13)
|
||||
#define B3 PAL_LINE(GPIOB, 14)
|
||||
#define B2 PAL_LINE(GPIOB, 15)
|
||||
#define B6 PAL_LINE(GPIOB, 1)
|
||||
|
||||
// LEDs (only D5/B2 uses an actual LED)
|
||||
// Setting both RX and TX LEDs to the same pin as there
|
||||
// is only one LED availble
|
||||
// If this is undesirable, either B0 or B5 can be redefined by
|
||||
// using #undef and #define to change its assignment
|
||||
#define B0 PAL_LINE(GPIOB, 2)
|
||||
#define D5 PAL_LINE(GPIOB, 2)
|
|
@ -0,0 +1,4 @@
|
|||
# Proton C MCU settings for converting AVR projects
|
||||
MCU := STM32F411
|
||||
BOARD := GENERIC_STM32_F411XE
|
||||
BOOTLOADER := stm32-dfu
|
Loading…
Reference in New Issue