diff --git a/data/mappings/defaults.hjson b/data/mappings/defaults.hjson index ea9f6972c5a..10657e5aa06 100644 --- a/data/mappings/defaults.hjson +++ b/data/mappings/defaults.hjson @@ -70,7 +70,7 @@ "bonsai_c4": { "processor": "STM32F411", "bootloader": "stm32-dfu", - "board": "GENERIC_STM32_F411XE", + "board": "BONSAI_C4", "pin_compatible": "promicro" } } diff --git a/docs/feature_converters.md b/docs/feature_converters.md index 3dabae915d5..0fa677f8732 100644 --- a/docs/feature_converters.md +++ b/docs/feature_converters.md @@ -157,8 +157,6 @@ The Bonsai C4 only has one on-board LED (B2), and by default, both the Pro Micro #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). - ## Elite-C If a board currently supported in QMK uses an [Elite-C](https://keeb.io/products/elite-c-low-profile-version-usb-c-pro-micro-replacement-atmega32u4), the supported alternative controllers are: diff --git a/keyboards/custommk/bonsai_c4_template/bonsai_c4_template.c b/keyboards/custommk/bonsai_c4_template/bonsai_c4_template.c deleted file mode 100644 index 2129a712cf3..00000000000 --- a/keyboards/custommk/bonsai_c4_template/bonsai_c4_template.c +++ /dev/null @@ -1,23 +0,0 @@ -/* 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 . - */ - -// 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 -} diff --git a/keyboards/custommk/bonsai_c4_template/config.h b/keyboards/custommk/bonsai_c4_template/config.h deleted file mode 100644 index 192e9b07556..00000000000 --- a/keyboards/custommk/bonsai_c4_template/config.h +++ /dev/null @@ -1,79 +0,0 @@ -/* 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 . - */ - -#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 diff --git a/keyboards/custommk/bonsai_c4_template/halconf.h b/keyboards/custommk/bonsai_c4_template/halconf.h deleted file mode 100644 index a90ea163f36..00000000000 --- a/keyboards/custommk/bonsai_c4_template/halconf.h +++ /dev/null @@ -1,35 +0,0 @@ -/* 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 . - */ - -#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 \ No newline at end of file diff --git a/keyboards/custommk/bonsai_c4_template/mcuconf.h b/keyboards/custommk/bonsai_c4_template/mcuconf.h deleted file mode 100644 index 4f926bd7deb..00000000000 --- a/keyboards/custommk/bonsai_c4_template/mcuconf.h +++ /dev/null @@ -1,35 +0,0 @@ -/* 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 . - */ - -#pragma once - -#include_next - -// 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 \ No newline at end of file diff --git a/keyboards/custommk/bonsai_c4_template/readme.md b/keyboards/custommk/bonsai_c4_template/readme.md deleted file mode 100644 index 0c0fd8ed0ce..00000000000 --- a/keyboards/custommk/bonsai_c4_template/readme.md +++ /dev/null @@ -1,10 +0,0 @@ -# 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). diff --git a/platforms/chibios/boards/BONSAI_C4/board/board.mk b/platforms/chibios/boards/BONSAI_C4/board/board.mk new file mode 100644 index 00000000000..bb00b1a2b0d --- /dev/null +++ b/platforms/chibios/boards/BONSAI_C4/board/board.mk @@ -0,0 +1,9 @@ +# List of all the board related files. +BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE/board.c + +# Required include directories +BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE + +# Shared variables +ALLCSRC += $(BOARDSRC) +ALLINC += $(BOARDINC) diff --git a/platforms/chibios/boards/BONSAI_C4/configs/board.h b/platforms/chibios/boards/BONSAI_C4/configs/board.h new file mode 100644 index 00000000000..f1ee51c91f5 --- /dev/null +++ b/platforms/chibios/boards/BONSAI_C4/configs/board.h @@ -0,0 +1,20 @@ +/* Copyright 2020 Nick Brassel (tzarc) + * + * 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 . + */ +#pragma once + +#include_next "board.h" + +#undef STM32_HSE_BYPASS \ No newline at end of file diff --git a/platforms/chibios/boards/BONSAI_C4/configs/config.h b/platforms/chibios/boards/BONSAI_C4/configs/config.h new file mode 100644 index 00000000000..e412f73d3d7 --- /dev/null +++ b/platforms/chibios/boards/BONSAI_C4/configs/config.h @@ -0,0 +1,92 @@ +/* Copyright 2022 David Hoelscher, 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 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 . + */ +#pragma once + +// Bonsai C4 includes Vbus sensing; derived designs that use PA9 for other purposes +// may disable Vbus sensing with #define BOARD_OTG_NOVBUSSENS 1 + +#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP +# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE +#endif + +// FRAM configuration +#ifndef EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN +# define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN PAL_LINE(GPIOA, 0) +# define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // 96MHz / 8 = 12MHz; max supported by MB85R64 is 20MHz +# define EXTERNAL_EEPROM_BYTE_COUNT 8192 +# 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 +#endif + +// External flash configuration +#ifndef EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN +# define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN PAL_LINE(GPIOB, 12) +# define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR 2 // 48MHz; 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 +#endif + +// SPI Configuration (needed for FRAM and FLASH) +#ifndef SPI_DRIVER +# define SPI_DRIVER SPID1 +#endif +#ifndef SPI_SCK_PIN +# define SPI_SCK_PIN PAL_LINE(GPIOB, 3) +#endif +#ifndef SPI_MOSI_PIN +# define SPI_MOSI_PIN PAL_LINE(GPIOB, 5) +#endif +#ifndef SPI_MISO_PIN +# define SPI_MISO_PIN PAL_LINE(GPIOB, 4) +#endif + + +// I2C Configuration +#ifdef CONVERT_TO_BONSAI_C4 +# ifndef I2C1_SCL_PIN +# define I2C1_SCL_PIN PAL_LINE(GPIOB, 6) +# endif +# ifndef I2C1_SDA_PIN +# define I2C1_SDA_PIN PAL_LINE(GPIOB, 9) +# endif +#endif + +// WS2812-style LED control on pin A10 +#ifdef WS2812_DRIVER_PWM +# ifndef RGB_DI_PIN +# define RGB_DI_PIN PAL_LINE(GPIOA, 10) +# endif +# ifndef WS2812_PWM_DRIVER +# define WS2812_PWM_DRIVER PWMD1 +# endif +# ifndef WS2812_PWM_CHANNEL +# define WS2812_PWM_CHANNEL 3 +# endif +# ifndef WS2812_PWM_PAL_MODE +# define WS2812_PWM_PAL_MODE 1 +# endif +# ifndef WS2812_DMA_STREAM +# define WS2812_DMA_STREAM STM32_DMA2_STREAM5 +# endif +# ifndef WS2812_DMA_CHANNEL +# define WS2812_DMA_CHANNEL 6 +# endif +#endif + +#ifndef USB_VBUS_PIN +# define USB_VBUS_PIN PAL_LINE(GPIOA, 9) +#endif \ No newline at end of file diff --git a/platforms/chibios/boards/BONSAI_C4/configs/halconf.h b/platforms/chibios/boards/BONSAI_C4/configs/halconf.h new file mode 100644 index 00000000000..7887e7c9ba5 --- /dev/null +++ b/platforms/chibios/boards/BONSAI_C4/configs/halconf.h @@ -0,0 +1,49 @@ +/* Copyright 2022 David Hoelscher, 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 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 . + */ +#pragma once + +#ifndef HAL_USE_SPI +# define HAL_USE_SPI TRUE +#endif + +#ifndef HAL_USE_I2C +# define HAL_USE_I2C TRUE +#endif + +#ifdef SPLIT_KEYBOARD +# ifndef HAL_USE_SERIAL +# define HAL_USE_SERIAL TRUE +# endif +# ifndef SERIAL_BUFFERS_SIZE +# define SERIAL_BUFFERS_SIZE 256 +# endif +#endif + +#ifdef WS2812_DRIVER_PWM +# ifndef HAL_USE_PWM +# define HAL_USE_PWM TRUE +# endif +#endif + +#ifndef SPI_SELECT_MODE +# define SPI_SELECT_MODE SPI_SELECT_MODE_PAD +#endif + +#ifndef SPI_USE_WAIT +# define SPI_USE_WAIT TRUE +#endif + +#include_next \ No newline at end of file diff --git a/platforms/chibios/boards/BONSAI_C4/configs/mcuconf.h b/platforms/chibios/boards/BONSAI_C4/configs/mcuconf.h new file mode 100644 index 00000000000..2f9e627c7e5 --- /dev/null +++ b/platforms/chibios/boards/BONSAI_C4/configs/mcuconf.h @@ -0,0 +1,249 @@ +/* + ChibiOS - Copyright (C) 2006..2020 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 + +/* + * STM32F4xx 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. + */ + +#define STM32F4xx_MCUCONF +#define STM32F411_MCUCONF + +/* + * HAL driver system settings. + */ +#define STM32_NO_INIT FALSE +#define STM32_PVD_ENABLE FALSE +#define STM32_PLS STM32_PLS_LEV0 +#define STM32_BKPRAM_ENABLE FALSE +#define STM32_HSI_ENABLED TRUE +#define STM32_LSI_ENABLED TRUE +#define STM32_HSE_ENABLED TRUE +#define STM32_LSE_ENABLED FALSE +#define STM32_CLOCK48_REQUIRED TRUE +#define STM32_SW STM32_SW_PLL +#define STM32_PLLSRC STM32_PLLSRC_HSE +#define STM32_PLLM_VALUE 4 +#define STM32_PLLN_VALUE 96 +#define STM32_PLLP_VALUE 2 +#define STM32_PLLQ_VALUE 4 +#define STM32_HPRE STM32_HPRE_DIV1 +#define STM32_PPRE1 STM32_PPRE1_DIV2 +#define STM32_PPRE2 STM32_PPRE2_DIV1 +#define STM32_RTCSEL STM32_RTCSEL_LSI +#define STM32_RTCPRE_VALUE 8 +#define STM32_MCO1SEL STM32_MCO1SEL_HSI +#define STM32_MCO1PRE STM32_MCO1PRE_DIV1 +#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK +#define STM32_MCO2PRE STM32_MCO2PRE_DIV5 +#define STM32_I2SSRC STM32_I2SSRC_CKIN +#define STM32_PLLI2SN_VALUE 192 +#define STM32_PLLI2SR_VALUE 5 + +/* + * IRQ system settings. + */ +#define STM32_IRQ_EXTI0_PRIORITY 6 +#define STM32_IRQ_EXTI1_PRIORITY 6 +#define STM32_IRQ_EXTI2_PRIORITY 6 +#define STM32_IRQ_EXTI3_PRIORITY 6 +#define STM32_IRQ_EXTI4_PRIORITY 6 +#define STM32_IRQ_EXTI5_9_PRIORITY 6 +#define STM32_IRQ_EXTI10_15_PRIORITY 6 +#define STM32_IRQ_EXTI16_PRIORITY 6 +#define STM32_IRQ_EXTI17_PRIORITY 15 +#define STM32_IRQ_EXTI18_PRIORITY 6 +#define STM32_IRQ_EXTI19_PRIORITY 6 +#define STM32_IRQ_EXTI20_PRIORITY 6 +#define STM32_IRQ_EXTI21_PRIORITY 15 +#define STM32_IRQ_EXTI22_PRIORITY 15 + +#define STM32_IRQ_TIM1_BRK_TIM9_PRIORITY 7 +#define STM32_IRQ_TIM1_UP_TIM10_PRIORITY 7 +#define STM32_IRQ_TIM1_TRGCO_TIM11_PRIORITY 7 +#define STM32_IRQ_TIM1_CC_PRIORITY 7 +#define STM32_IRQ_TIM2_PRIORITY 7 +#define STM32_IRQ_TIM3_PRIORITY 7 +#define STM32_IRQ_TIM4_PRIORITY 7 +#define STM32_IRQ_TIM5_PRIORITY 7 + +#define STM32_IRQ_USART1_PRIORITY 12 +#define STM32_IRQ_USART2_PRIORITY 12 +#define STM32_IRQ_USART6_PRIORITY 12 + +/* + * ADC driver system settings. + */ +#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4 +#define STM32_ADC_USE_ADC1 FALSE +#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4) +#define STM32_ADC_ADC1_DMA_PRIORITY 2 +#define STM32_ADC_IRQ_PRIORITY 6 +#define STM32_ADC_ADC1_DMA_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_TIM9 FALSE +#define STM32_GPT_USE_TIM10 FALSE +#define STM32_GPT_USE_TIM11 FALSE + +/* + * I2C driver system settings. + */ +#define STM32_I2C_USE_I2C1 TRUE +#define STM32_I2C_USE_I2C2 FALSE +#define STM32_I2C_USE_I2C3 FALSE +#define STM32_I2C_BUSY_TIMEOUT 50 +#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) +#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) +#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) +#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) +#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) +#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) +#define STM32_I2C_I2C1_IRQ_PRIORITY 5 +#define STM32_I2C_I2C2_IRQ_PRIORITY 5 +#define STM32_I2C_I2C3_IRQ_PRIORITY 5 +#define STM32_I2C_I2C1_DMA_PRIORITY 3 +#define STM32_I2C_I2C2_DMA_PRIORITY 3 +#define STM32_I2C_I2C3_DMA_PRIORITY 3 +#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") + +/* + * I2S driver system settings. + */ +#define STM32_I2S_USE_SPI2 FALSE +#define STM32_I2S_USE_SPI3 FALSE +#define STM32_I2S_SPI2_IRQ_PRIORITY 10 +#define STM32_I2S_SPI3_IRQ_PRIORITY 10 +#define STM32_I2S_SPI2_DMA_PRIORITY 1 +#define STM32_I2S_SPI3_DMA_PRIORITY 1 +#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) +#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) +#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) +#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) +#define STM32_I2S_DMA_ERROR_HOOK(i2sp) 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_TIM9 FALSE +#define STM32_ICU_USE_TIM10 FALSE +#define STM32_ICU_USE_TIM11 FALSE + +/* + * PWM driver system settings. + */ +#define STM32_PWM_USE_TIM1 TRUE +#define STM32_PWM_USE_TIM2 FALSE +#define STM32_PWM_USE_TIM3 TRUE +#define STM32_PWM_USE_TIM4 FALSE +#define STM32_PWM_USE_TIM5 FALSE +#define STM32_PWM_USE_TIM9 FALSE +#define STM32_PWM_USE_TIM10 FALSE +#define STM32_PWM_USE_TIM11 FALSE + +/* + * RTC driver system settings. + */ +#define STM32_RTC_PRESA_VALUE 32 +#define STM32_RTC_PRESS_VALUE 1024 +#define STM32_RTC_CR_INIT 0 +#define STM32_RTC_TAMPCR_INIT 0 + +/* + * SERIAL driver system settings. + */ +#define STM32_SERIAL_USE_USART1 TRUE +#define STM32_SERIAL_USE_USART2 FALSE +#define STM32_SERIAL_USE_USART6 FALSE + +/* + * SPI driver system settings. + */ +#define STM32_SPI_USE_SPI1 TRUE +#define STM32_SPI_USE_SPI2 FALSE +#define STM32_SPI_USE_SPI3 FALSE +#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0) +#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3) +#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) +#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) +#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) +#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) +#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_USART6 FALSE +#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) +#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) +#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5) +#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) +#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) +#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) +#define STM32_UART_USART1_DMA_PRIORITY 0 +#define STM32_UART_USART2_DMA_PRIORITY 0 +#define STM32_UART_USART6_DMA_PRIORITY 0 +#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") + +/* + * USB driver system settings. + */ +#define STM32_USB_USE_OTG1 TRUE +#define STM32_USB_OTG1_IRQ_PRIORITY 14 +#define STM32_USB_OTG1_RX_FIFO_SIZE 512 +#define STM32_USB_HOST_WAKEUP_DURATION 2 + +/* + * WDG driver system settings. + */ +#define STM32_WDG_USE_IWDG FALSE + +#endif /* MCUCONF_H */ \ No newline at end of file diff --git a/platforms/chibios/converters/promicro_to_bonsai_c4/converter.mk b/platforms/chibios/converters/promicro_to_bonsai_c4/converter.mk index 7410209b670..005b7a81601 100644 --- a/platforms/chibios/converters/promicro_to_bonsai_c4/converter.mk +++ b/platforms/chibios/converters/promicro_to_bonsai_c4/converter.mk @@ -1,4 +1,4 @@ # Proton C MCU settings for converting AVR projects MCU := STM32F411 -BOARD := GENERIC_STM32_F411XE -BOOTLOADER := stm32-dfu \ No newline at end of file +BOARD := BONSAI_C4 +BOOTLOADER := stm32-dfu diff --git a/platforms/chibios/converters/promicro_to_bonsai_c4/post_converter.mk b/platforms/chibios/converters/promicro_to_bonsai_c4/post_converter.mk new file mode 100644 index 00000000000..5f49b17f8a6 --- /dev/null +++ b/platforms/chibios/converters/promicro_to_bonsai_c4/post_converter.mk @@ -0,0 +1,5 @@ +BACKLIGHT_DRIVER ?= pwm +WS2812_DRIVER ?= pwm +SERIAL_DRIVER ?= usart +FLASH_DRIVER ?= spi +EEPROM_DRIVER ?= spi \ No newline at end of file