common_features.mk 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. # Copyright 2017 Fred Sundvik
  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 2 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 <http://www.gnu.org/licenses/>.
  15. QUANTUM_SRC += \
  16. $(QUANTUM_DIR)/quantum.c \
  17. $(QUANTUM_DIR)/send_string.c \
  18. $(QUANTUM_DIR)/bitwise.c \
  19. $(QUANTUM_DIR)/led.c \
  20. $(QUANTUM_DIR)/action.c \
  21. $(QUANTUM_DIR)/action_layer.c \
  22. $(QUANTUM_DIR)/action_tapping.c \
  23. $(QUANTUM_DIR)/action_util.c \
  24. $(QUANTUM_DIR)/eeconfig.c \
  25. $(QUANTUM_DIR)/keyboard.c \
  26. $(QUANTUM_DIR)/keymap_common.c \
  27. $(QUANTUM_DIR)/keycode_config.c \
  28. $(QUANTUM_DIR)/sync_timer.c \
  29. $(QUANTUM_DIR)/logging/debug.c \
  30. $(QUANTUM_DIR)/logging/sendchar.c \
  31. VPATH += $(QUANTUM_DIR)/logging
  32. # Fall back to lib/printf if there is no platform provided print
  33. ifeq ("$(wildcard $(PLATFORM_PATH)/$(PLATFORM_KEY)/printf.mk)","")
  34. include $(QUANTUM_PATH)/logging/print.mk
  35. else
  36. include $(PLATFORM_PATH)/$(PLATFORM_KEY)/printf.mk
  37. endif
  38. ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), yes)
  39. OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
  40. CONSOLE_ENABLE = yes
  41. else ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), api)
  42. OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
  43. endif
  44. AUDIO_ENABLE ?= no
  45. ifeq ($(strip $(AUDIO_ENABLE)), yes)
  46. ifeq ($(PLATFORM),CHIBIOS)
  47. AUDIO_DRIVER ?= dac_basic
  48. ifeq ($(strip $(AUDIO_DRIVER)), dac_basic)
  49. OPT_DEFS += -DAUDIO_DRIVER_DAC
  50. else ifeq ($(strip $(AUDIO_DRIVER)), dac_additive)
  51. OPT_DEFS += -DAUDIO_DRIVER_DAC
  52. ## stm32f2 and above have a usable DAC unit, f1 do not, and need to use pwm instead
  53. else ifeq ($(strip $(AUDIO_DRIVER)), pwm_software)
  54. OPT_DEFS += -DAUDIO_DRIVER_PWM
  55. else ifeq ($(strip $(AUDIO_DRIVER)), pwm_hardware)
  56. OPT_DEFS += -DAUDIO_DRIVER_PWM
  57. endif
  58. else
  59. # fallback for all other platforms is pwm
  60. AUDIO_DRIVER ?= pwm_hardware
  61. OPT_DEFS += -DAUDIO_DRIVER_PWM
  62. endif
  63. OPT_DEFS += -DAUDIO_ENABLE
  64. MUSIC_ENABLE = yes
  65. SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
  66. SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
  67. SRC += $(QUANTUM_DIR)/audio/audio.c ## common audio code, hardware agnostic
  68. SRC += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/audio_$(strip $(AUDIO_DRIVER)).c
  69. SRC += $(QUANTUM_DIR)/audio/voices.c
  70. SRC += $(QUANTUM_DIR)/audio/luts.c
  71. endif
  72. ifeq ($(strip $(SEQUENCER_ENABLE)), yes)
  73. OPT_DEFS += -DSEQUENCER_ENABLE
  74. MUSIC_ENABLE = yes
  75. SRC += $(QUANTUM_DIR)/sequencer/sequencer.c
  76. SRC += $(QUANTUM_DIR)/process_keycode/process_sequencer.c
  77. endif
  78. ifeq ($(strip $(MIDI_ENABLE)), yes)
  79. OPT_DEFS += -DMIDI_ENABLE
  80. MUSIC_ENABLE = yes
  81. SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
  82. endif
  83. MUSIC_ENABLE ?= no
  84. ifeq ($(MUSIC_ENABLE), yes)
  85. SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
  86. endif
  87. ifeq ($(strip $(STENO_ENABLE)), yes)
  88. OPT_DEFS += -DSTENO_ENABLE
  89. VIRTSER_ENABLE ?= yes
  90. SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
  91. endif
  92. ifeq ($(strip $(VIRTSER_ENABLE)), yes)
  93. OPT_DEFS += -DVIRTSER_ENABLE
  94. endif
  95. ifeq ($(strip $(MOUSEKEY_ENABLE)), yes)
  96. OPT_DEFS += -DMOUSEKEY_ENABLE
  97. MOUSE_ENABLE := yes
  98. SRC += $(QUANTUM_DIR)/mousekey.c
  99. endif
  100. VALID_POINTING_DEVICE_DRIVER_TYPES := adns5050 adns9800 analog_joystick cirque_pinnacle_i2c cirque_pinnacle_spi pmw3360 pmw3389 pimoroni_trackball custom
  101. POINTING_DEVICE_DRIVER ?= custom
  102. ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
  103. ifeq ($(filter $(POINTING_DEVICE_DRIVER),$(VALID_POINTING_DEVICE_DRIVER_TYPES)),)
  104. $(error POINTING_DEVICE_DRIVER="$(POINTING_DEVICE_DRIVER)" is not a valid pointing device type)
  105. else
  106. OPT_DEFS += -DPOINTING_DEVICE_ENABLE
  107. MOUSE_ENABLE := yes
  108. SRC += $(QUANTUM_DIR)/pointing_device.c
  109. SRC += $(QUANTUM_DIR)/pointing_device_drivers.c
  110. ifneq ($(strip $(POINTING_DEVICE_DRIVER)), custom)
  111. SRC += drivers/sensors/$(strip $(POINTING_DEVICE_DRIVER)).c
  112. OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(shell echo $(POINTING_DEVICE_DRIVER) | tr '[:lower:]' '[:upper:]'))
  113. endif
  114. OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(POINTING_DEVICE_DRIVER))
  115. ifeq ($(strip $(POINTING_DEVICE_DRIVER)), adns9800)
  116. OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
  117. QUANTUM_LIB_SRC += spi_master.c
  118. else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), analog_joystick)
  119. OPT_DEFS += -DSTM32_ADC -DHAL_USE_ADC=TRUE
  120. LIB_SRC += analog.c
  121. else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), cirque_pinnacle_i2c)
  122. OPT_DEFS += -DSTM32_I2C -DHAL_USE_I2C=TRUE
  123. SRC += drivers/sensors/cirque_pinnacle.c
  124. QUANTUM_LIB_SRC += i2c_master.c
  125. else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), cirque_pinnacle_spi)
  126. OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
  127. SRC += drivers/sensors/cirque_pinnacle.c
  128. QUANTUM_LIB_SRC += spi_master.c
  129. else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pimoroni_trackball)
  130. OPT_DEFS += -DSTM32_SPI -DHAL_USE_I2C=TRUE
  131. QUANTUM_LIB_SRC += i2c_master.c
  132. else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pmw3360)
  133. OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
  134. QUANTUM_LIB_SRC += spi_master.c
  135. else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pmw3389)
  136. OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
  137. QUANTUM_LIB_SRC += spi_master.c
  138. endif
  139. endif
  140. endif
  141. VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c spi
  142. EEPROM_DRIVER ?= vendor
  143. ifeq ($(filter $(EEPROM_DRIVER),$(VALID_EEPROM_DRIVER_TYPES)),)
  144. $(error EEPROM_DRIVER="$(EEPROM_DRIVER)" is not a valid EEPROM driver)
  145. else
  146. OPT_DEFS += -DEEPROM_ENABLE
  147. ifeq ($(strip $(EEPROM_DRIVER)), custom)
  148. # Custom EEPROM implementation -- only needs to implement init/erase/read_block/write_block
  149. OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_CUSTOM
  150. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  151. SRC += eeprom_driver.c
  152. else ifeq ($(strip $(EEPROM_DRIVER)), i2c)
  153. # External I2C EEPROM implementation
  154. OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_I2C
  155. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  156. QUANTUM_LIB_SRC += i2c_master.c
  157. SRC += eeprom_driver.c eeprom_i2c.c
  158. else ifeq ($(strip $(EEPROM_DRIVER)), spi)
  159. # External SPI EEPROM implementation
  160. OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_SPI
  161. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  162. QUANTUM_LIB_SRC += spi_master.c
  163. SRC += eeprom_driver.c eeprom_spi.c
  164. else ifeq ($(strip $(EEPROM_DRIVER)), transient)
  165. # Transient EEPROM implementation -- no data storage but provides runtime area for it
  166. OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT
  167. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  168. SRC += eeprom_driver.c eeprom_transient.c
  169. else ifeq ($(strip $(EEPROM_DRIVER)), vendor)
  170. # Vendor-implemented EEPROM
  171. OPT_DEFS += -DEEPROM_VENDOR
  172. ifeq ($(PLATFORM),AVR)
  173. # Automatically provided by avr-libc, nothing required
  174. else ifeq ($(PLATFORM),CHIBIOS)
  175. ifneq ($(filter STM32F3xx_% STM32F1xx_% %_STM32F401xC %_STM32F401xE %_STM32F405xG %_STM32F411xE %_STM32F072xB %_STM32F042x6 %_GD32VF103xB %_GD32VF103x8, $(MCU_SERIES)_$(MCU_LDSCRIPT)),)
  176. # Emulated EEPROM
  177. OPT_DEFS += -DEEPROM_DRIVER
  178. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  179. SRC += eeprom_driver.c
  180. SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
  181. SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
  182. else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),)
  183. # True EEPROM on STM32L0xx, L1xx
  184. OPT_DEFS += -DEEPROM_DRIVER
  185. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  186. COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/eeprom
  187. SRC += eeprom_driver.c
  188. SRC += eeprom_stm32_L0_L1.c
  189. else ifneq ($(filter $(MCU_SERIES),KL2x K20x),)
  190. # Teensy EEPROM implementations
  191. SRC += eeprom_teensy.c
  192. else
  193. # Fall back to transient, i.e. non-persistent
  194. OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT
  195. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  196. SRC += eeprom_driver.c eeprom_transient.c
  197. endif
  198. else ifeq ($(PLATFORM),ARM_ATSAM)
  199. # arm_atsam EEPROM
  200. SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
  201. else ifeq ($(PLATFORM),TEST)
  202. # Test harness "EEPROM"
  203. SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
  204. endif
  205. endif
  206. endif
  207. RGBLIGHT_ENABLE ?= no
  208. VALID_RGBLIGHT_TYPES := WS2812 APA102 custom
  209. ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
  210. RGBLIGHT_DRIVER ?= custom
  211. endif
  212. ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
  213. RGBLIGHT_DRIVER ?= WS2812
  214. ifeq ($(filter $(RGBLIGHT_DRIVER),$(VALID_RGBLIGHT_TYPES)),)
  215. $(error RGBLIGHT_DRIVER="$(RGBLIGHT_DRIVER)" is not a valid RGB type)
  216. else
  217. COMMON_VPATH += $(QUANTUM_DIR)/rgblight
  218. POST_CONFIG_H += $(QUANTUM_DIR)/rgblight/rgblight_post_config.h
  219. OPT_DEFS += -DRGBLIGHT_ENABLE
  220. SRC += $(QUANTUM_DIR)/color.c
  221. SRC += $(QUANTUM_DIR)/rgblight/rgblight.c
  222. CIE1931_CURVE := yes
  223. RGB_KEYCODES_ENABLE := yes
  224. endif
  225. ifeq ($(strip $(RGBLIGHT_DRIVER)), WS2812)
  226. WS2812_DRIVER_REQUIRED := yes
  227. endif
  228. ifeq ($(strip $(RGBLIGHT_DRIVER)), APA102)
  229. APA102_DRIVER_REQUIRED := yes
  230. endif
  231. ifeq ($(strip $(RGBLIGHT_DRIVER)), custom)
  232. OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
  233. endif
  234. endif
  235. LED_MATRIX_ENABLE ?= no
  236. VALID_LED_MATRIX_TYPES := IS31FL3731 custom
  237. # TODO: IS31FL3733 IS31FL3737 IS31FL3741
  238. ifeq ($(strip $(LED_MATRIX_ENABLE)), yes)
  239. ifeq ($(filter $(LED_MATRIX_DRIVER),$(VALID_LED_MATRIX_TYPES)),)
  240. $(error "$(LED_MATRIX_DRIVER)" is not a valid matrix type)
  241. endif
  242. OPT_DEFS += -DLED_MATRIX_ENABLE
  243. ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162))
  244. # ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines
  245. OPT_DEFS += -DLIB8_ATTINY
  246. endif
  247. COMMON_VPATH += $(QUANTUM_DIR)/led_matrix
  248. COMMON_VPATH += $(QUANTUM_DIR)/led_matrix/animations
  249. COMMON_VPATH += $(QUANTUM_DIR)/led_matrix/animations/runners
  250. SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
  251. SRC += $(QUANTUM_DIR)/led_matrix/led_matrix.c
  252. SRC += $(QUANTUM_DIR)/led_matrix/led_matrix_drivers.c
  253. SRC += $(LIB_PATH)/lib8tion/lib8tion.c
  254. CIE1931_CURVE := yes
  255. ifeq ($(strip $(LED_MATRIX_DRIVER)), IS31FL3731)
  256. OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  257. COMMON_VPATH += $(DRIVER_PATH)/led/issi
  258. SRC += is31fl3731-simple.c
  259. QUANTUM_LIB_SRC += i2c_master.c
  260. endif
  261. endif
  262. RGB_MATRIX_ENABLE ?= no
  263. VALID_RGB_MATRIX_TYPES := AW20216 IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 CKLED2001 WS2812 custom
  264. ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
  265. ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),)
  266. $(error "$(RGB_MATRIX_DRIVER)" is not a valid matrix type)
  267. endif
  268. OPT_DEFS += -DRGB_MATRIX_ENABLE
  269. ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162))
  270. # ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines
  271. OPT_DEFS += -DLIB8_ATTINY
  272. endif
  273. COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix
  274. COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations
  275. COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations/runners
  276. SRC += $(QUANTUM_DIR)/color.c
  277. SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix.c
  278. SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix_drivers.c
  279. SRC += $(LIB_PATH)/lib8tion/lib8tion.c
  280. CIE1931_CURVE := yes
  281. RGB_KEYCODES_ENABLE := yes
  282. ifeq ($(strip $(RGB_MATRIX_DRIVER)), AW20216)
  283. OPT_DEFS += -DAW20216 -DSTM32_SPI -DHAL_USE_SPI=TRUE
  284. COMMON_VPATH += $(DRIVER_PATH)/led
  285. SRC += aw20216.c
  286. QUANTUM_LIB_SRC += spi_master.c
  287. endif
  288. ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3731)
  289. OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  290. COMMON_VPATH += $(DRIVER_PATH)/led/issi
  291. SRC += is31fl3731.c
  292. QUANTUM_LIB_SRC += i2c_master.c
  293. endif
  294. ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3733)
  295. OPT_DEFS += -DIS31FL3733 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  296. COMMON_VPATH += $(DRIVER_PATH)/led/issi
  297. SRC += is31fl3733.c
  298. QUANTUM_LIB_SRC += i2c_master.c
  299. endif
  300. ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3737)
  301. OPT_DEFS += -DIS31FL3737 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  302. COMMON_VPATH += $(DRIVER_PATH)/led/issi
  303. SRC += is31fl3737.c
  304. QUANTUM_LIB_SRC += i2c_master.c
  305. endif
  306. ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3741)
  307. OPT_DEFS += -DIS31FL3741 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  308. COMMON_VPATH += $(DRIVER_PATH)/led/issi
  309. SRC += is31fl3741.c
  310. QUANTUM_LIB_SRC += i2c_master.c
  311. endif
  312. ifeq ($(strip $(RGB_MATRIX_DRIVER)), CKLED2001)
  313. OPT_DEFS += -DCKLED2001 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  314. COMMON_VPATH += $(DRIVER_PATH)/led
  315. SRC += ckled2001.c
  316. QUANTUM_LIB_SRC += i2c_master.c
  317. endif
  318. ifeq ($(strip $(RGB_MATRIX_DRIVER)), WS2812)
  319. OPT_DEFS += -DWS2812
  320. WS2812_DRIVER_REQUIRED := yes
  321. endif
  322. ifeq ($(strip $(RGB_MATRIX_DRIVER)), APA102)
  323. OPT_DEFS += -DAPA102
  324. APA102_DRIVER_REQUIRED := yes
  325. endif
  326. ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes)
  327. OPT_DEFS += -DRGB_MATRIX_CUSTOM_KB
  328. endif
  329. ifeq ($(strip $(RGB_MATRIX_CUSTOM_USER)), yes)
  330. OPT_DEFS += -DRGB_MATRIX_CUSTOM_USER
  331. endif
  332. endif
  333. ifeq ($(strip $(RGB_KEYCODES_ENABLE)), yes)
  334. SRC += $(QUANTUM_DIR)/process_keycode/process_rgb.c
  335. endif
  336. ifeq ($(strip $(PRINTING_ENABLE)), yes)
  337. OPT_DEFS += -DPRINTING_ENABLE
  338. SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
  339. QUANTUM_LIB_SRC += uart.c
  340. endif
  341. VARIABLE_TRACE ?= no
  342. ifneq ($(strip $(VARIABLE_TRACE)),no)
  343. SRC += $(QUANTUM_DIR)/variable_trace.c
  344. OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
  345. ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
  346. OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
  347. endif
  348. endif
  349. ifeq ($(strip $(SLEEP_LED_ENABLE)), yes)
  350. SRC += $(PLATFORM_COMMON_DIR)/sleep_led.c
  351. OPT_DEFS += -DSLEEP_LED_ENABLE
  352. NO_SUSPEND_POWER_DOWN := yes
  353. endif
  354. VALID_BACKLIGHT_TYPES := pwm timer software custom
  355. BACKLIGHT_ENABLE ?= no
  356. ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
  357. BACKLIGHT_DRIVER ?= software
  358. else
  359. BACKLIGHT_DRIVER ?= pwm
  360. endif
  361. ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
  362. ifeq ($(filter $(BACKLIGHT_DRIVER),$(VALID_BACKLIGHT_TYPES)),)
  363. $(error BACKLIGHT_DRIVER="$(BACKLIGHT_DRIVER)" is not a valid backlight type)
  364. endif
  365. COMMON_VPATH += $(QUANTUM_DIR)/backlight
  366. SRC += $(QUANTUM_DIR)/backlight/backlight.c
  367. SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
  368. OPT_DEFS += -DBACKLIGHT_ENABLE
  369. ifeq ($(strip $(BACKLIGHT_DRIVER)), custom)
  370. OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
  371. else
  372. SRC += $(QUANTUM_DIR)/backlight/backlight_driver_common.c
  373. ifeq ($(strip $(BACKLIGHT_DRIVER)), pwm)
  374. SRC += $(QUANTUM_DIR)/backlight/backlight_$(PLATFORM_KEY).c
  375. else
  376. SRC += $(QUANTUM_DIR)/backlight/backlight_$(strip $(BACKLIGHT_DRIVER)).c
  377. endif
  378. endif
  379. endif
  380. VALID_WS2812_DRIVER_TYPES := bitbang pwm spi i2c
  381. WS2812_DRIVER ?= bitbang
  382. ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
  383. ifeq ($(filter $(WS2812_DRIVER),$(VALID_WS2812_DRIVER_TYPES)),)
  384. $(error WS2812_DRIVER="$(WS2812_DRIVER)" is not a valid WS2812 driver)
  385. endif
  386. OPT_DEFS += -DWS2812_DRIVER_$(strip $(shell echo $(WS2812_DRIVER) | tr '[:lower:]' '[:upper:]'))
  387. ifeq ($(strip $(WS2812_DRIVER)), bitbang)
  388. SRC += ws2812.c
  389. else
  390. SRC += ws2812_$(strip $(WS2812_DRIVER)).c
  391. ifeq ($(strip $(PLATFORM)), CHIBIOS)
  392. ifeq ($(strip $(WS2812_DRIVER)), pwm)
  393. OPT_DEFS += -DSTM32_DMA_REQUIRED=TRUE
  394. endif
  395. endif
  396. endif
  397. # add extra deps
  398. ifeq ($(strip $(WS2812_DRIVER)), i2c)
  399. QUANTUM_LIB_SRC += i2c_master.c
  400. endif
  401. endif
  402. ifeq ($(strip $(APA102_DRIVER_REQUIRED)), yes)
  403. COMMON_VPATH += $(DRIVER_PATH)/led
  404. SRC += apa102.c
  405. endif
  406. ifeq ($(strip $(CIE1931_CURVE)), yes)
  407. OPT_DEFS += -DUSE_CIE1931_CURVE
  408. LED_TABLES := yes
  409. endif
  410. ifeq ($(strip $(LED_TABLES)), yes)
  411. SRC += $(QUANTUM_DIR)/led_tables.c
  412. endif
  413. ifeq ($(strip $(TERMINAL_ENABLE)), yes)
  414. SRC += $(QUANTUM_DIR)/process_keycode/process_terminal.c
  415. OPT_DEFS += -DTERMINAL_ENABLE
  416. OPT_DEFS += -DUSER_PRINT
  417. endif
  418. ifeq ($(strip $(VIA_ENABLE)), yes)
  419. DYNAMIC_KEYMAP_ENABLE := yes
  420. RAW_ENABLE := yes
  421. BOOTMAGIC_ENABLE := yes
  422. SRC += $(QUANTUM_DIR)/via.c
  423. OPT_DEFS += -DVIA_ENABLE
  424. endif
  425. VALID_MAGIC_TYPES := yes
  426. BOOTMAGIC_ENABLE ?= no
  427. ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
  428. ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),)
  429. $(error BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic)
  430. endif
  431. ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
  432. OPT_DEFS += -DBOOTMAGIC_LITE
  433. QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_lite.c
  434. endif
  435. endif
  436. COMMON_VPATH += $(QUANTUM_DIR)/bootmagic
  437. QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/magic.c
  438. VALID_CUSTOM_MATRIX_TYPES:= yes lite no
  439. CUSTOM_MATRIX ?= no
  440. ifneq ($(strip $(CUSTOM_MATRIX)), yes)
  441. ifeq ($(filter $(CUSTOM_MATRIX),$(VALID_CUSTOM_MATRIX_TYPES)),)
  442. $(error CUSTOM_MATRIX="$(CUSTOM_MATRIX)" is not a valid custom matrix type)
  443. endif
  444. # Include common stuff for all non custom matrix users
  445. QUANTUM_SRC += $(QUANTUM_DIR)/matrix_common.c
  446. # if 'lite' then skip the actual matrix implementation
  447. ifneq ($(strip $(CUSTOM_MATRIX)), lite)
  448. # Include the standard or split matrix code if needed
  449. QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c
  450. endif
  451. endif
  452. # Debounce Modules. Set DEBOUNCE_TYPE=custom if including one manually.
  453. DEBOUNCE_TYPE ?= sym_defer_g
  454. ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
  455. QUANTUM_SRC += $(QUANTUM_DIR)/debounce/$(strip $(DEBOUNCE_TYPE)).c
  456. endif
  457. ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
  458. POST_CONFIG_H += $(QUANTUM_DIR)/split_common/post_config.h
  459. OPT_DEFS += -DSPLIT_KEYBOARD
  460. CRC_ENABLE := yes
  461. # Include files used by all split keyboards
  462. QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_util.c
  463. # Determine which (if any) transport files are required
  464. ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
  465. QUANTUM_SRC += $(QUANTUM_DIR)/split_common/transport.c \
  466. $(QUANTUM_DIR)/split_common/transactions.c
  467. OPT_DEFS += -DSPLIT_COMMON_TRANSACTIONS
  468. # Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
  469. # Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
  470. ifeq ($(PLATFORM),AVR)
  471. ifneq ($(NO_I2C),yes)
  472. QUANTUM_LIB_SRC += i2c_master.c \
  473. i2c_slave.c
  474. endif
  475. endif
  476. SERIAL_DRIVER ?= bitbang
  477. OPT_DEFS += -DSERIAL_DRIVER_$(strip $(shell echo $(SERIAL_DRIVER) | tr '[:lower:]' '[:upper:]'))
  478. ifeq ($(strip $(SERIAL_DRIVER)), bitbang)
  479. QUANTUM_LIB_SRC += serial.c
  480. else
  481. QUANTUM_LIB_SRC += serial_$(strip $(SERIAL_DRIVER)).c
  482. endif
  483. endif
  484. COMMON_VPATH += $(QUANTUM_PATH)/split_common
  485. endif
  486. ifeq ($(strip $(CRC_ENABLE)), yes)
  487. OPT_DEFS += -DCRC_ENABLE
  488. SRC += crc.c
  489. endif
  490. ifeq ($(strip $(HAPTIC_ENABLE)),yes)
  491. COMMON_VPATH += $(DRIVER_PATH)/haptic
  492. ifneq ($(filter DRV2605L, $(HAPTIC_DRIVER)), )
  493. SRC += DRV2605L.c
  494. QUANTUM_LIB_SRC += i2c_master.c
  495. OPT_DEFS += -DDRV2605L
  496. endif
  497. ifneq ($(filter SOLENOID, $(HAPTIC_DRIVER)), )
  498. SRC += solenoid.c
  499. OPT_DEFS += -DSOLENOID_ENABLE
  500. endif
  501. endif
  502. ifeq ($(strip $(HD44780_ENABLE)), yes)
  503. SRC += platforms/avr/drivers/hd44780.c
  504. OPT_DEFS += -DHD44780_ENABLE
  505. endif
  506. VALID_OLED_DRIVER_TYPES := SSD1306 custom
  507. OLED_DRIVER ?= SSD1306
  508. ifeq ($(strip $(OLED_ENABLE)), yes)
  509. ifeq ($(filter $(OLED_DRIVER),$(VALID_OLED_DRIVER_TYPES)),)
  510. $(error OLED_DRIVER="$(OLED_DRIVER)" is not a valid OLED driver)
  511. else
  512. OPT_DEFS += -DOLED_ENABLE
  513. COMMON_VPATH += $(DRIVER_PATH)/oled
  514. OPT_DEFS += -DOLED_DRIVER_$(strip $(shell echo $(OLED_DRIVER) | tr '[:lower:]' '[:upper:]'))
  515. ifeq ($(strip $(OLED_DRIVER)), SSD1306)
  516. SRC += ssd1306_sh1106.c
  517. QUANTUM_LIB_SRC += i2c_master.c
  518. endif
  519. endif
  520. endif
  521. ifeq ($(strip $(ST7565_ENABLE)), yes)
  522. OPT_DEFS += -DST7565_ENABLE
  523. COMMON_VPATH += $(DRIVER_PATH)/oled # For glcdfont.h
  524. COMMON_VPATH += $(DRIVER_PATH)/lcd
  525. QUANTUM_LIB_SRC += spi_master.c
  526. SRC += st7565.c
  527. endif
  528. ifeq ($(strip $(UCIS_ENABLE)), yes)
  529. OPT_DEFS += -DUCIS_ENABLE
  530. UNICODE_COMMON := yes
  531. SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
  532. endif
  533. ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
  534. OPT_DEFS += -DUNICODEMAP_ENABLE
  535. UNICODE_COMMON := yes
  536. SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
  537. endif
  538. ifeq ($(strip $(UNICODE_ENABLE)), yes)
  539. OPT_DEFS += -DUNICODE_ENABLE
  540. UNICODE_COMMON := yes
  541. SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
  542. endif
  543. ifeq ($(strip $(UNICODE_COMMON)), yes)
  544. OPT_DEFS += -DUNICODE_COMMON_ENABLE
  545. SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
  546. endif
  547. MAGIC_ENABLE ?= yes
  548. ifeq ($(strip $(MAGIC_ENABLE)), yes)
  549. SRC += $(QUANTUM_DIR)/process_keycode/process_magic.c
  550. OPT_DEFS += -DMAGIC_KEYCODE_ENABLE
  551. endif
  552. ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
  553. SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
  554. OPT_DEFS += -DAUTO_SHIFT_ENABLE
  555. ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes)
  556. OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
  557. endif
  558. endif
  559. ifeq ($(strip $(PS2_MOUSE_ENABLE)), yes)
  560. PS2_ENABLE := yes
  561. SRC += ps2_mouse.c
  562. OPT_DEFS += -DPS2_MOUSE_ENABLE
  563. OPT_DEFS += -DMOUSE_ENABLE
  564. endif
  565. ifeq ($(strip $(PS2_USE_BUSYWAIT)), yes)
  566. PS2_ENABLE := yes
  567. SRC += ps2_busywait.c
  568. SRC += ps2_io_avr.c
  569. OPT_DEFS += -DPS2_USE_BUSYWAIT
  570. endif
  571. ifeq ($(strip $(PS2_USE_INT)), yes)
  572. PS2_ENABLE := yes
  573. SRC += ps2_interrupt.c
  574. SRC += ps2_io.c
  575. OPT_DEFS += -DPS2_USE_INT
  576. endif
  577. ifeq ($(strip $(PS2_USE_USART)), yes)
  578. PS2_ENABLE := yes
  579. SRC += ps2_usart.c
  580. SRC += ps2_io.c
  581. OPT_DEFS += -DPS2_USE_USART
  582. endif
  583. ifeq ($(strip $(PS2_ENABLE)), yes)
  584. COMMON_VPATH += $(DRIVER_PATH)/ps2
  585. COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/ps2
  586. OPT_DEFS += -DPS2_ENABLE
  587. endif
  588. JOYSTICK_ENABLE ?= no
  589. VALID_JOYSTICK_TYPES := analog digital
  590. JOYSTICK_DRIVER ?= analog
  591. ifeq ($(strip $(JOYSTICK_ENABLE)), yes)
  592. ifeq ($(filter $(JOYSTICK_DRIVER),$(VALID_JOYSTICK_TYPES)),)
  593. $(error "$(JOYSTICK_DRIVER)" is not a valid joystick driver)
  594. endif
  595. OPT_DEFS += -DJOYSTICK_ENABLE
  596. SRC += $(QUANTUM_DIR)/process_keycode/process_joystick.c
  597. SRC += $(QUANTUM_DIR)/joystick.c
  598. ifeq ($(strip $(JOYSTICK_DRIVER)), analog)
  599. OPT_DEFS += -DANALOG_JOYSTICK_ENABLE
  600. SRC += analog.c
  601. endif
  602. ifeq ($(strip $(JOYSTICK_DRIVER)), digital)
  603. OPT_DEFS += -DDIGITAL_JOYSTICK_ENABLE
  604. endif
  605. endif
  606. USBPD_ENABLE ?= no
  607. VALID_USBPD_DRIVER_TYPES = custom vendor
  608. USBPD_DRIVER ?= vendor
  609. ifeq ($(strip $(USBPD_ENABLE)), yes)
  610. ifeq ($(filter $(strip $(USBPD_DRIVER)),$(VALID_USBPD_DRIVER_TYPES)),)
  611. $(error USBPD_DRIVER="$(USBPD_DRIVER)" is not a valid USBPD driver)
  612. else
  613. OPT_DEFS += -DUSBPD_ENABLE
  614. ifeq ($(strip $(USBPD_DRIVER)), vendor)
  615. # Vendor-specific implementations
  616. OPT_DEFS += -DUSBPD_VENDOR
  617. ifeq ($(strip $(MCU_SERIES)), STM32G4xx)
  618. OPT_DEFS += -DUSBPD_STM32G4
  619. SRC += usbpd_stm32g4.c
  620. else
  621. $(error There is no vendor-provided USBPD driver available)
  622. endif
  623. else ifeq ($(strip $(USBPD_DRIVER)), custom)
  624. OPT_DEFS += -DUSBPD_CUSTOM
  625. # Board designers can add their own driver to $(SRC)
  626. endif
  627. endif
  628. endif
  629. BLUETOOTH_ENABLE ?= no
  630. VALID_BLUETOOTH_DRIVER_TYPES := BluefruitLE RN42 custom
  631. ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
  632. ifeq ($(filter $(strip $(BLUETOOTH_DRIVER)),$(VALID_BLUETOOTH_DRIVER_TYPES)),)
  633. $(error "$(BLUETOOTH_DRIVER)" is not a valid Bluetooth driver type)
  634. endif
  635. OPT_DEFS += -DBLUETOOTH_ENABLE
  636. NO_USB_STARTUP_CHECK := yes
  637. COMMON_VPATH += $(DRIVER_PATH)/bluetooth
  638. SRC += outputselect.c
  639. ifeq ($(strip $(BLUETOOTH_DRIVER)), BluefruitLE)
  640. OPT_DEFS += -DBLUETOOTH_BLUEFRUIT_LE
  641. SRC += analog.c
  642. SRC += $(DRIVER_PATH)/bluetooth/bluefruit_le.cpp
  643. QUANTUM_LIB_SRC += spi_master.c
  644. endif
  645. ifeq ($(strip $(BLUETOOTH_DRIVER)), RN42)
  646. OPT_DEFS += -DBLUETOOTH_RN42
  647. SRC += $(DRIVER_PATH)/bluetooth/rn42.c
  648. QUANTUM_LIB_SRC += uart.c
  649. endif
  650. endif