config.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Copyright 2022 David Hoelscher, customMK
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. // Bonsai C4 includes Vbus sensing; derived designs that use PA9 for other purposes
  18. // may disable Vbus sensing with #define BOARD_OTG_NOVBUSSENS 1
  19. #ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
  20. # define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
  21. #endif
  22. // FRAM configuration
  23. #ifndef EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN
  24. # define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN PAL_LINE(GPIOA, 0)
  25. # define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // 96MHz / 8 = 12MHz; max supported by MB85R64 is 20MHz
  26. # define EXTERNAL_EEPROM_BYTE_COUNT 8192
  27. # define EXTERNAL_EEPROM_PAGE_SIZE 64 // does not matter for FRAM, just sets the RAM buffer size in STM32F chip
  28. # define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191
  29. #endif
  30. // External flash configuration
  31. #ifndef EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN
  32. # define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN PAL_LINE(GPIOB, 12)
  33. # define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR 2 // 48MHz; max supported by W25Q128JV is 133MHz
  34. # define EXTERNAL_FLASH_BYTE_COUNT (16 * 1024 * 1024) //128Mbit or 16MByte
  35. # define EXTERNAL_FLASH_PAGE_SIZE 256
  36. # define EXTERNAL_FLASH_SPI_TIMEOUT 200000 //datasheet max is 200 seconds for flash chip erase
  37. #endif
  38. // SPI Configuration (needed for FRAM and FLASH)
  39. #ifndef SPI_DRIVER
  40. # define SPI_DRIVER SPID1
  41. #endif
  42. #ifndef SPI_SCK_PIN
  43. # define SPI_SCK_PIN PAL_LINE(GPIOB, 3)
  44. #endif
  45. #ifndef SPI_MOSI_PIN
  46. # define SPI_MOSI_PIN PAL_LINE(GPIOB, 5)
  47. #endif
  48. #ifndef SPI_MISO_PIN
  49. # define SPI_MISO_PIN PAL_LINE(GPIOB, 4)
  50. #endif
  51. // I2C Configuration
  52. #ifdef CONVERT_TO_BONSAI_C4
  53. # ifndef I2C1_SCL_PIN
  54. # define I2C1_SCL_PIN PAL_LINE(GPIOB, 6)
  55. # endif
  56. # ifndef I2C1_SDA_PIN
  57. # define I2C1_SDA_PIN PAL_LINE(GPIOB, 9)
  58. # endif
  59. #endif
  60. // WS2812-style LED control on pin A10
  61. #ifdef WS2812_DRIVER_PWM
  62. # ifndef RGB_DI_PIN
  63. # define RGB_DI_PIN PAL_LINE(GPIOA, 10)
  64. # endif
  65. # ifndef WS2812_PWM_DRIVER
  66. # define WS2812_PWM_DRIVER PWMD1
  67. # endif
  68. # ifndef WS2812_PWM_CHANNEL
  69. # define WS2812_PWM_CHANNEL 3
  70. # endif
  71. # ifndef WS2812_PWM_PAL_MODE
  72. # define WS2812_PWM_PAL_MODE 1
  73. # endif
  74. # ifndef WS2812_DMA_STREAM
  75. # define WS2812_DMA_STREAM STM32_DMA2_STREAM5
  76. # endif
  77. # ifndef WS2812_DMA_CHANNEL
  78. # define WS2812_DMA_CHANNEL 6
  79. # endif
  80. #endif
  81. #ifndef USB_VBUS_PIN
  82. # define USB_VBUS_PIN PAL_LINE(GPIOA, 9)
  83. #endif