common_features.mk 21 KB

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