common_features.mk 24 KB

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