common_features.mk 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  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. SERIAL_PATH := $(QUANTUM_PATH)/serial_link
  16. QUANTUM_SRC += \
  17. $(QUANTUM_DIR)/quantum.c \
  18. $(QUANTUM_DIR)/send_string.c \
  19. $(QUANTUM_DIR)/bitwise.c \
  20. $(QUANTUM_DIR)/led.c \
  21. $(QUANTUM_DIR)/keymap_common.c \
  22. $(QUANTUM_DIR)/keycode_config.c
  23. ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), yes)
  24. OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
  25. CONSOLE_ENABLE = yes
  26. else ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), api)
  27. OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
  28. endif
  29. ifeq ($(strip $(API_SYSEX_ENABLE)), yes)
  30. OPT_DEFS += -DAPI_SYSEX_ENABLE
  31. OPT_DEFS += -DAPI_ENABLE
  32. MIDI_ENABLE=yes
  33. SRC += $(QUANTUM_DIR)/api/api_sysex.c
  34. SRC += $(QUANTUM_DIR)/api.c
  35. endif
  36. ifeq ($(strip $(COMMAND_ENABLE)), yes)
  37. SRC += $(QUANTUM_DIR)/command.c
  38. OPT_DEFS += -DCOMMAND_ENABLE
  39. endif
  40. AUDIO_ENABLE ?= no
  41. ifeq ($(strip $(AUDIO_ENABLE)), yes)
  42. ifeq ($(PLATFORM),CHIBIOS)
  43. AUDIO_DRIVER ?= dac_basic
  44. ifeq ($(strip $(AUDIO_DRIVER)), dac_basic)
  45. OPT_DEFS += -DAUDIO_DRIVER_DAC
  46. else ifeq ($(strip $(AUDIO_DRIVER)), dac_additive)
  47. OPT_DEFS += -DAUDIO_DRIVER_DAC
  48. ## stm32f2 and above have a usable DAC unit, f1 do not, and need to use pwm instead
  49. else ifeq ($(strip $(AUDIO_DRIVER)), pwm_software)
  50. OPT_DEFS += -DAUDIO_DRIVER_PWM
  51. else ifeq ($(strip $(AUDIO_DRIVER)), pwm_hardware)
  52. OPT_DEFS += -DAUDIO_DRIVER_PWM
  53. endif
  54. else
  55. # fallback for all other platforms is pwm
  56. AUDIO_DRIVER ?= pwm_hardware
  57. OPT_DEFS += -DAUDIO_DRIVER_PWM
  58. endif
  59. OPT_DEFS += -DAUDIO_ENABLE
  60. MUSIC_ENABLE = yes
  61. SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
  62. SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
  63. SRC += $(QUANTUM_DIR)/audio/audio.c ## common audio code, hardware agnostic
  64. SRC += $(QUANTUM_DIR)/audio/driver_$(PLATFORM_KEY)_$(strip $(AUDIO_DRIVER)).c
  65. SRC += $(QUANTUM_DIR)/audio/voices.c
  66. SRC += $(QUANTUM_DIR)/audio/luts.c
  67. endif
  68. ifeq ($(strip $(SEQUENCER_ENABLE)), yes)
  69. OPT_DEFS += -DSEQUENCER_ENABLE
  70. MUSIC_ENABLE = yes
  71. SRC += $(QUANTUM_DIR)/sequencer/sequencer.c
  72. SRC += $(QUANTUM_DIR)/process_keycode/process_sequencer.c
  73. endif
  74. ifeq ($(strip $(MIDI_ENABLE)), yes)
  75. OPT_DEFS += -DMIDI_ENABLE
  76. MUSIC_ENABLE = yes
  77. SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
  78. endif
  79. MUSIC_ENABLE ?= no
  80. ifeq ($(MUSIC_ENABLE), yes)
  81. SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
  82. endif
  83. ifeq ($(strip $(STENO_ENABLE)), yes)
  84. OPT_DEFS += -DSTENO_ENABLE
  85. VIRTSER_ENABLE ?= yes
  86. SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
  87. endif
  88. ifeq ($(strip $(VIRTSER_ENABLE)), yes)
  89. OPT_DEFS += -DVIRTSER_ENABLE
  90. endif
  91. ifeq ($(strip $(MOUSEKEY_ENABLE)), yes)
  92. OPT_DEFS += -DMOUSEKEY_ENABLE
  93. OPT_DEFS += -DMOUSE_ENABLE
  94. SRC += $(QUANTUM_DIR)/mousekey.c
  95. endif
  96. ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
  97. OPT_DEFS += -DPOINTING_DEVICE_ENABLE
  98. OPT_DEFS += -DMOUSE_ENABLE
  99. SRC += $(QUANTUM_DIR)/pointing_device.c
  100. endif
  101. VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c spi
  102. EEPROM_DRIVER ?= vendor
  103. ifeq ($(filter $(EEPROM_DRIVER),$(VALID_EEPROM_DRIVER_TYPES)),)
  104. $(error EEPROM_DRIVER="$(EEPROM_DRIVER)" is not a valid EEPROM driver)
  105. else
  106. OPT_DEFS += -DEEPROM_ENABLE
  107. ifeq ($(strip $(EEPROM_DRIVER)), custom)
  108. OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_CUSTOM
  109. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  110. SRC += eeprom_driver.c
  111. else ifeq ($(strip $(EEPROM_DRIVER)), i2c)
  112. OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_I2C
  113. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  114. QUANTUM_LIB_SRC += i2c_master.c
  115. SRC += eeprom_driver.c eeprom_i2c.c
  116. else ifeq ($(strip $(EEPROM_DRIVER)), spi)
  117. OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_SPI
  118. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  119. QUANTUM_LIB_SRC += spi_master.c
  120. SRC += eeprom_driver.c eeprom_spi.c
  121. else ifeq ($(strip $(EEPROM_DRIVER)), transient)
  122. OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT
  123. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  124. SRC += eeprom_driver.c eeprom_transient.c
  125. else ifeq ($(strip $(EEPROM_DRIVER)), vendor)
  126. OPT_DEFS += -DEEPROM_VENDOR
  127. ifeq ($(PLATFORM),AVR)
  128. # Automatically provided by avr-libc, nothing required
  129. else ifeq ($(PLATFORM),CHIBIOS)
  130. ifeq ($(MCU_SERIES), STM32F3xx)
  131. SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
  132. SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
  133. OPT_DEFS += -DEEPROM_EMU_STM32F303xC
  134. OPT_DEFS += -DSTM32_EEPROM_ENABLE
  135. else ifeq ($(MCU_SERIES), STM32F1xx)
  136. SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
  137. SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
  138. OPT_DEFS += -DEEPROM_EMU_STM32F103xB
  139. OPT_DEFS += -DSTM32_EEPROM_ENABLE
  140. else ifeq ($(MCU_SERIES)_$(MCU_LDSCRIPT), STM32F0xx_STM32F072xB)
  141. SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
  142. SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
  143. OPT_DEFS += -DEEPROM_EMU_STM32F072xB
  144. OPT_DEFS += -DSTM32_EEPROM_ENABLE
  145. else ifeq ($(MCU_SERIES)_$(MCU_LDSCRIPT), STM32F0xx_STM32F042x6)
  146. # Stack sizes: Since this chip has limited RAM capacity, the stack area needs to be reduced.
  147. # This ensures that the EEPROM page buffer fits into RAM
  148. USE_PROCESS_STACKSIZE = 0x600
  149. USE_EXCEPTIONS_STACKSIZE = 0x300
  150. SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
  151. SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
  152. OPT_DEFS += -DEEPROM_EMU_STM32F042x6
  153. OPT_DEFS += -DSTM32_EEPROM_ENABLE
  154. else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),)
  155. OPT_DEFS += -DEEPROM_DRIVER
  156. COMMON_VPATH += $(DRIVER_PATH)/eeprom
  157. SRC += eeprom_driver.c eeprom_stm32_L0_L1.c
  158. else
  159. # This will effectively work the same as "transient" if not supported by the chip
  160. SRC += $(PLATFORM_COMMON_DIR)/eeprom_teensy.c
  161. endif
  162. else ifeq ($(PLATFORM),ARM_ATSAM)
  163. SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
  164. else ifeq ($(PLATFORM),TEST)
  165. SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
  166. endif
  167. endif
  168. endif
  169. RGBLIGHT_ENABLE ?= no
  170. VALID_RGBLIGHT_TYPES := WS2812 APA102 custom
  171. ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
  172. RGBLIGHT_DRIVER ?= custom
  173. endif
  174. ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
  175. RGBLIGHT_DRIVER ?= WS2812
  176. ifeq ($(filter $(RGBLIGHT_DRIVER),$(VALID_RGBLIGHT_TYPES)),)
  177. $(error RGBLIGHT_DRIVER="$(RGBLIGHT_DRIVER)" is not a valid RGB type)
  178. else
  179. COMMON_VPATH += $(QUANTUM_DIR)/rgblight
  180. POST_CONFIG_H += $(QUANTUM_DIR)/rgblight/rgblight_post_config.h
  181. OPT_DEFS += -DRGBLIGHT_ENABLE
  182. SRC += $(QUANTUM_DIR)/color.c
  183. SRC += $(QUANTUM_DIR)/rgblight/rgblight.c
  184. CIE1931_CURVE := yes
  185. RGB_KEYCODES_ENABLE := yes
  186. endif
  187. ifeq ($(strip $(RGBLIGHT_DRIVER)), WS2812)
  188. WS2812_DRIVER_REQUIRED := yes
  189. endif
  190. ifeq ($(strip $(RGBLIGHT_DRIVER)), APA102)
  191. APA102_DRIVER_REQUIRED := yes
  192. endif
  193. ifeq ($(strip $(RGBLIGHT_DRIVER)), custom)
  194. OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
  195. endif
  196. endif
  197. LED_MATRIX_ENABLE ?= no
  198. VALID_LED_MATRIX_TYPES := IS31FL3731 custom
  199. # TODO: IS31FL3733 IS31FL3737 IS31FL3741
  200. ifeq ($(strip $(LED_MATRIX_ENABLE)), yes)
  201. ifeq ($(filter $(LED_MATRIX_DRIVER),$(VALID_LED_MATRIX_TYPES)),)
  202. $(error "$(LED_MATRIX_DRIVER)" is not a valid matrix type)
  203. endif
  204. OPT_DEFS += -DLED_MATRIX_ENABLE
  205. ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162))
  206. # ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines
  207. OPT_DEFS += -DLIB8_ATTINY
  208. endif
  209. COMMON_VPATH += $(QUANTUM_DIR)/led_matrix
  210. COMMON_VPATH += $(QUANTUM_DIR)/led_matrix/animations
  211. COMMON_VPATH += $(QUANTUM_DIR)/led_matrix/animations/runners
  212. SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
  213. SRC += $(QUANTUM_DIR)/led_matrix/led_matrix.c
  214. SRC += $(QUANTUM_DIR)/led_matrix/led_matrix_drivers.c
  215. CIE1931_CURVE := yes
  216. ifeq ($(strip $(LED_MATRIX_DRIVER)), IS31FL3731)
  217. OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  218. COMMON_VPATH += $(DRIVER_PATH)/issi
  219. SRC += is31fl3731-simple.c
  220. QUANTUM_LIB_SRC += i2c_master.c
  221. endif
  222. endif
  223. RGB_MATRIX_ENABLE ?= no
  224. VALID_RGB_MATRIX_TYPES := AW20216 IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 WS2812 custom
  225. ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
  226. ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),)
  227. $(error "$(RGB_MATRIX_DRIVER)" is not a valid matrix type)
  228. endif
  229. OPT_DEFS += -DRGB_MATRIX_ENABLE
  230. ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162))
  231. # ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines
  232. OPT_DEFS += -DLIB8_ATTINY
  233. endif
  234. COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix
  235. COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations
  236. COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations/runners
  237. SRC += $(QUANTUM_DIR)/color.c
  238. SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix.c
  239. SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix_drivers.c
  240. CIE1931_CURVE := yes
  241. RGB_KEYCODES_ENABLE := yes
  242. ifeq ($(strip $(RGB_MATRIX_DRIVER)), AW20216)
  243. OPT_DEFS += -DAW20216 -DSTM32_SPI -DHAL_USE_SPI=TRUE
  244. COMMON_VPATH += $(DRIVER_PATH)/awinic
  245. SRC += aw20216.c
  246. QUANTUM_LIB_SRC += spi_master.c
  247. endif
  248. ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3731)
  249. OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  250. COMMON_VPATH += $(DRIVER_PATH)/issi
  251. SRC += is31fl3731.c
  252. QUANTUM_LIB_SRC += i2c_master.c
  253. endif
  254. ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3733)
  255. OPT_DEFS += -DIS31FL3733 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  256. COMMON_VPATH += $(DRIVER_PATH)/issi
  257. SRC += is31fl3733.c
  258. QUANTUM_LIB_SRC += i2c_master.c
  259. endif
  260. ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3737)
  261. OPT_DEFS += -DIS31FL3737 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  262. COMMON_VPATH += $(DRIVER_PATH)/issi
  263. SRC += is31fl3737.c
  264. QUANTUM_LIB_SRC += i2c_master.c
  265. endif
  266. ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3741)
  267. OPT_DEFS += -DIS31FL3741 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  268. COMMON_VPATH += $(DRIVER_PATH)/issi
  269. SRC += is31fl3741.c
  270. QUANTUM_LIB_SRC += i2c_master.c
  271. endif
  272. ifeq ($(strip $(RGB_MATRIX_DRIVER)), WS2812)
  273. OPT_DEFS += -DWS2812
  274. WS2812_DRIVER_REQUIRED := yes
  275. endif
  276. ifeq ($(strip $(RGB_MATRIX_DRIVER)), APA102)
  277. OPT_DEFS += -DAPA102
  278. APA102_DRIVER_REQUIRED := yes
  279. endif
  280. ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes)
  281. OPT_DEFS += -DRGB_MATRIX_CUSTOM_KB
  282. endif
  283. ifeq ($(strip $(RGB_MATRIX_CUSTOM_USER)), yes)
  284. OPT_DEFS += -DRGB_MATRIX_CUSTOM_USER
  285. endif
  286. endif
  287. ifeq ($(strip $(RGB_KEYCODES_ENABLE)), yes)
  288. SRC += $(QUANTUM_DIR)/process_keycode/process_rgb.c
  289. endif
  290. ifeq ($(strip $(PRINTING_ENABLE)), yes)
  291. OPT_DEFS += -DPRINTING_ENABLE
  292. SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
  293. SRC += $(TMK_DIR)/protocol/serial_uart.c
  294. endif
  295. ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
  296. SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c)
  297. SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
  298. SERIAL_DEFS += -DSERIAL_LINK_ENABLE
  299. COMMON_VPATH += $(SERIAL_PATH)
  300. SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
  301. OPT_DEFS += $(SERIAL_DEFS)
  302. VAPTH += $(SERIAL_PATH)
  303. endif
  304. VARIABLE_TRACE ?= no
  305. ifneq ($(strip $(VARIABLE_TRACE)),no)
  306. SRC += $(QUANTUM_DIR)/variable_trace.c
  307. OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
  308. ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
  309. OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
  310. endif
  311. endif
  312. ifeq ($(strip $(LCD_ENABLE)), yes)
  313. CIE1931_CURVE := yes
  314. endif
  315. # backward compat
  316. ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
  317. BACKLIGHT_DRIVER := custom
  318. endif
  319. VALID_BACKLIGHT_TYPES := pwm timer software custom
  320. BACKLIGHT_ENABLE ?= no
  321. ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
  322. BACKLIGHT_DRIVER ?= software
  323. else
  324. BACKLIGHT_DRIVER ?= pwm
  325. endif
  326. ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
  327. ifeq ($(filter $(BACKLIGHT_DRIVER),$(VALID_BACKLIGHT_TYPES)),)
  328. $(error BACKLIGHT_DRIVER="$(BACKLIGHT_DRIVER)" is not a valid backlight type)
  329. endif
  330. COMMON_VPATH += $(QUANTUM_DIR)/backlight
  331. SRC += $(QUANTUM_DIR)/backlight/backlight.c
  332. SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
  333. OPT_DEFS += -DBACKLIGHT_ENABLE
  334. ifeq ($(strip $(BACKLIGHT_DRIVER)), custom)
  335. OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
  336. else
  337. SRC += $(QUANTUM_DIR)/backlight/backlight_driver_common.c
  338. ifeq ($(strip $(BACKLIGHT_DRIVER)), pwm)
  339. SRC += $(QUANTUM_DIR)/backlight/backlight_$(PLATFORM_KEY).c
  340. else
  341. SRC += $(QUANTUM_DIR)/backlight/backlight_$(strip $(BACKLIGHT_DRIVER)).c
  342. endif
  343. endif
  344. endif
  345. VALID_WS2812_DRIVER_TYPES := bitbang pwm spi i2c
  346. WS2812_DRIVER ?= bitbang
  347. ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
  348. ifeq ($(filter $(WS2812_DRIVER),$(VALID_WS2812_DRIVER_TYPES)),)
  349. $(error WS2812_DRIVER="$(WS2812_DRIVER)" is not a valid WS2812 driver)
  350. endif
  351. OPT_DEFS += -DWS2812_DRIVER_$(strip $(shell echo $(WS2812_DRIVER) | tr '[:lower:]' '[:upper:]'))
  352. ifeq ($(strip $(WS2812_DRIVER)), bitbang)
  353. SRC += ws2812.c
  354. else
  355. SRC += ws2812_$(strip $(WS2812_DRIVER)).c
  356. ifeq ($(strip $(PLATFORM)), CHIBIOS)
  357. ifeq ($(strip $(WS2812_DRIVER)), pwm)
  358. OPT_DEFS += -DSTM32_DMA_REQUIRED=TRUE
  359. endif
  360. endif
  361. endif
  362. # add extra deps
  363. ifeq ($(strip $(WS2812_DRIVER)), i2c)
  364. QUANTUM_LIB_SRC += i2c_master.c
  365. endif
  366. endif
  367. ifeq ($(strip $(APA102_DRIVER_REQUIRED)), yes)
  368. COMMON_VPATH += $(DRIVER_PATH)/apa102
  369. SRC += apa102.c
  370. endif
  371. ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
  372. CIE1931_CURVE := yes
  373. endif
  374. ifeq ($(strip $(CIE1931_CURVE)), yes)
  375. OPT_DEFS += -DUSE_CIE1931_CURVE
  376. LED_TABLES := yes
  377. endif
  378. ifeq ($(strip $(LED_TABLES)), yes)
  379. SRC += $(QUANTUM_DIR)/led_tables.c
  380. endif
  381. ifeq ($(strip $(TERMINAL_ENABLE)), yes)
  382. SRC += $(QUANTUM_DIR)/process_keycode/process_terminal.c
  383. OPT_DEFS += -DTERMINAL_ENABLE
  384. OPT_DEFS += -DUSER_PRINT
  385. endif
  386. ifeq ($(strip $(WPM_ENABLE)), yes)
  387. SRC += $(QUANTUM_DIR)/wpm.c
  388. OPT_DEFS += -DWPM_ENABLE
  389. endif
  390. ifeq ($(strip $(ENCODER_ENABLE)), yes)
  391. SRC += $(QUANTUM_DIR)/encoder.c
  392. OPT_DEFS += -DENCODER_ENABLE
  393. endif
  394. ifeq ($(strip $(VELOCIKEY_ENABLE)), yes)
  395. OPT_DEFS += -DVELOCIKEY_ENABLE
  396. SRC += $(QUANTUM_DIR)/velocikey.c
  397. endif
  398. ifeq ($(strip $(VIA_ENABLE)), yes)
  399. DYNAMIC_KEYMAP_ENABLE := yes
  400. RAW_ENABLE := yes
  401. BOOTMAGIC_ENABLE := lite
  402. SRC += $(QUANTUM_DIR)/via.c
  403. OPT_DEFS += -DVIA_ENABLE
  404. endif
  405. ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes)
  406. OPT_DEFS += -DDYNAMIC_KEYMAP_ENABLE
  407. SRC += $(QUANTUM_DIR)/dynamic_keymap.c
  408. endif
  409. ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
  410. OPT_DEFS += -DDIP_SWITCH_ENABLE
  411. SRC += $(QUANTUM_DIR)/dip_switch.c
  412. endif
  413. VALID_MAGIC_TYPES := yes full lite
  414. BOOTMAGIC_ENABLE ?= no
  415. ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
  416. ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),)
  417. $(error BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic)
  418. endif
  419. ifneq ($(strip $(BOOTMAGIC_ENABLE)), full)
  420. OPT_DEFS += -DBOOTMAGIC_LITE
  421. QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_lite.c
  422. else
  423. OPT_DEFS += -DBOOTMAGIC_ENABLE
  424. QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_full.c
  425. endif
  426. endif
  427. COMMON_VPATH += $(QUANTUM_DIR)/bootmagic
  428. QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/magic.c
  429. VALID_CUSTOM_MATRIX_TYPES:= yes lite no
  430. CUSTOM_MATRIX ?= no
  431. ifneq ($(strip $(CUSTOM_MATRIX)), yes)
  432. ifeq ($(filter $(CUSTOM_MATRIX),$(VALID_CUSTOM_MATRIX_TYPES)),)
  433. $(error CUSTOM_MATRIX="$(CUSTOM_MATRIX)" is not a valid custom matrix type)
  434. endif
  435. # Include common stuff for all non custom matrix users
  436. QUANTUM_SRC += $(QUANTUM_DIR)/matrix_common.c
  437. # if 'lite' then skip the actual matrix implementation
  438. ifneq ($(strip $(CUSTOM_MATRIX)), lite)
  439. # Include the standard or split matrix code if needed
  440. ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
  441. QUANTUM_SRC += $(QUANTUM_DIR)/split_common/matrix.c
  442. else
  443. QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c
  444. endif
  445. endif
  446. endif
  447. # Support for translating old names to new names:
  448. ifeq ($(strip $(DEBOUNCE_TYPE)),sym_g)
  449. DEBOUNCE_TYPE:=sym_defer_g
  450. else ifeq ($(strip $(DEBOUNCE_TYPE)),eager_pk)
  451. DEBOUNCE_TYPE:=sym_eager_pk
  452. else ifeq ($(strip $(DEBOUNCE_TYPE)),sym_pk)
  453. DEBOUNCE_TYPE:=sym_defer_pk
  454. else ifeq ($(strip $(DEBOUNCE_TYPE)),eager_pr)
  455. DEBOUNCE_TYPE:=sym_eager_pr
  456. endif
  457. DEBOUNCE_DIR:= $(QUANTUM_DIR)/debounce
  458. # Debounce Modules. Set DEBOUNCE_TYPE=custom if including one manually.
  459. DEBOUNCE_TYPE?= sym_defer_g
  460. ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
  461. QUANTUM_SRC += $(DEBOUNCE_DIR)/$(strip $(DEBOUNCE_TYPE)).c
  462. endif
  463. ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
  464. POST_CONFIG_H += $(QUANTUM_DIR)/split_common/post_config.h
  465. OPT_DEFS += -DSPLIT_KEYBOARD
  466. CRC_ENABLE := yes
  467. # Include files used by all split keyboards
  468. QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_util.c
  469. # Determine which (if any) transport files are required
  470. ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
  471. QUANTUM_SRC += $(QUANTUM_DIR)/split_common/transport.c \
  472. $(QUANTUM_DIR)/split_common/transactions.c
  473. OPT_DEFS += -DSPLIT_COMMON_TRANSACTIONS
  474. # Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
  475. # Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
  476. ifeq ($(PLATFORM),AVR)
  477. ifneq ($(NO_I2C),yes)
  478. QUANTUM_LIB_SRC += i2c_master.c \
  479. i2c_slave.c
  480. endif
  481. endif
  482. SERIAL_DRIVER ?= bitbang
  483. OPT_DEFS += -DSERIAL_DRIVER_$(strip $(shell echo $(SERIAL_DRIVER) | tr '[:lower:]' '[:upper:]'))
  484. ifeq ($(strip $(SERIAL_DRIVER)), bitbang)
  485. QUANTUM_LIB_SRC += serial.c
  486. else
  487. QUANTUM_LIB_SRC += serial_$(strip $(SERIAL_DRIVER)).c
  488. endif
  489. endif
  490. COMMON_VPATH += $(QUANTUM_PATH)/split_common
  491. endif
  492. ifeq ($(strip $(CRC_ENABLE)), yes)
  493. OPT_DEFS += -DCRC_ENABLE
  494. SRC += crc.c
  495. endif
  496. HAPTIC_ENABLE ?= no
  497. ifneq ($(strip $(HAPTIC_ENABLE)),no)
  498. COMMON_VPATH += $(DRIVER_PATH)/haptic
  499. SRC += haptic.c
  500. OPT_DEFS += -DHAPTIC_ENABLE
  501. endif
  502. ifneq ($(filter DRV2605L, $(HAPTIC_ENABLE)), )
  503. SRC += DRV2605L.c
  504. QUANTUM_LIB_SRC += i2c_master.c
  505. OPT_DEFS += -DDRV2605L
  506. endif
  507. ifneq ($(filter SOLENOID, $(HAPTIC_ENABLE)), )
  508. SRC += solenoid.c
  509. OPT_DEFS += -DSOLENOID_ENABLE
  510. endif
  511. ifeq ($(strip $(HD44780_ENABLE)), yes)
  512. SRC += drivers/avr/hd44780.c
  513. OPT_DEFS += -DHD44780_ENABLE
  514. endif
  515. ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
  516. OPT_DEFS += -DOLED_DRIVER_ENABLE
  517. COMMON_VPATH += $(DRIVER_PATH)/oled
  518. QUANTUM_LIB_SRC += i2c_master.c
  519. SRC += oled_driver.c
  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. include $(DRIVER_PATH)/qwiic/qwiic.mk
  529. ifeq ($(strip $(UCIS_ENABLE)), yes)
  530. OPT_DEFS += -DUCIS_ENABLE
  531. UNICODE_COMMON := yes
  532. SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
  533. endif
  534. ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
  535. OPT_DEFS += -DUNICODEMAP_ENABLE
  536. UNICODE_COMMON := yes
  537. SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
  538. endif
  539. ifeq ($(strip $(UNICODE_ENABLE)), yes)
  540. OPT_DEFS += -DUNICODE_ENABLE
  541. UNICODE_COMMON := yes
  542. SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
  543. endif
  544. ifeq ($(strip $(UNICODE_COMMON)), yes)
  545. SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
  546. endif
  547. SPACE_CADET_ENABLE ?= yes
  548. ifeq ($(strip $(SPACE_CADET_ENABLE)), yes)
  549. SRC += $(QUANTUM_DIR)/process_keycode/process_space_cadet.c
  550. OPT_DEFS += -DSPACE_CADET_ENABLE
  551. endif
  552. MAGIC_ENABLE ?= yes
  553. ifeq ($(strip $(MAGIC_ENABLE)), yes)
  554. SRC += $(QUANTUM_DIR)/process_keycode/process_magic.c
  555. OPT_DEFS += -DMAGIC_KEYCODE_ENABLE
  556. endif
  557. GRAVE_ESC_ENABLE ?= yes
  558. ifeq ($(strip $(GRAVE_ESC_ENABLE)), yes)
  559. SRC += $(QUANTUM_DIR)/process_keycode/process_grave_esc.c
  560. OPT_DEFS += -DGRAVE_ESC_ENABLE
  561. endif
  562. ifeq ($(strip $(DYNAMIC_MACRO_ENABLE)), yes)
  563. SRC += $(QUANTUM_DIR)/process_keycode/process_dynamic_macro.c
  564. OPT_DEFS += -DDYNAMIC_MACRO_ENABLE
  565. endif
  566. ifeq ($(strip $(COMBO_ENABLE)), yes)
  567. SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c
  568. OPT_DEFS += -DCOMBO_ENABLE
  569. endif
  570. ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
  571. SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
  572. OPT_DEFS += -DTAP_DANCE_ENABLE
  573. endif
  574. ifeq ($(strip $(KEY_LOCK_ENABLE)), yes)
  575. SRC += $(QUANTUM_DIR)/process_keycode/process_key_lock.c
  576. OPT_DEFS += -DKEY_LOCK_ENABLE
  577. endif
  578. ifeq ($(strip $(LEADER_ENABLE)), yes)
  579. SRC += $(QUANTUM_DIR)/process_keycode/process_leader.c
  580. OPT_DEFS += -DLEADER_ENABLE
  581. endif
  582. ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
  583. SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
  584. OPT_DEFS += -DAUTO_SHIFT_ENABLE
  585. ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes)
  586. OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
  587. endif
  588. endif
  589. JOYSTICK_ENABLE ?= no
  590. ifneq ($(strip $(JOYSTICK_ENABLE)), no)
  591. OPT_DEFS += -DJOYSTICK_ENABLE
  592. SRC += $(QUANTUM_DIR)/process_keycode/process_joystick.c
  593. SRC += $(QUANTUM_DIR)/joystick.c
  594. endif
  595. ifeq ($(strip $(JOYSTICK_ENABLE)), analog)
  596. OPT_DEFS += -DANALOG_JOYSTICK_ENABLE
  597. SRC += analog.c
  598. endif
  599. ifeq ($(strip $(JOYSTICK_ENABLE)), digital)
  600. OPT_DEFS += -DDIGITAL_JOYSTICK_ENABLE
  601. endif
  602. USBPD_ENABLE ?= no
  603. VALID_USBPD_DRIVER_TYPES = custom vendor
  604. USBPD_DRIVER ?= vendor
  605. ifeq ($(strip $(USBPD_ENABLE)), yes)
  606. ifeq ($(filter $(strip $(USBPD_DRIVER)),$(VALID_USBPD_DRIVER_TYPES)),)
  607. $(error USBPD_DRIVER="$(USBPD_DRIVER)" is not a valid USBPD driver)
  608. else
  609. OPT_DEFS += -DUSBPD_ENABLE
  610. ifeq ($(strip $(USBPD_DRIVER)), vendor)
  611. # Vendor-specific implementations
  612. OPT_DEFS += -DUSBPD_VENDOR
  613. ifeq ($(strip $(MCU_SERIES)), STM32G4xx)
  614. OPT_DEFS += -DUSBPD_STM32G4
  615. SRC += usbpd_stm32g4.c
  616. else
  617. $(error There is no vendor-provided USBPD driver available)
  618. endif
  619. else ifeq ($(strip $(USBPD_DRIVER)), custom)
  620. OPT_DEFS += -DUSBPD_CUSTOM
  621. # Board designers can add their own driver to $(SRC)
  622. endif
  623. endif
  624. endif