common_features.mk 23 KB

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