Peter's keyboard firmware (QMK) https://qmk.fm/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

425 lines
12KB

  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_DIR := $(QUANTUM_DIR)/serial_link
  16. SERIAL_PATH := $(QUANTUM_PATH)/serial_link
  17. SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c)
  18. SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
  19. SERIAL_DEFS += -DSERIAL_LINK_ENABLE
  20. COMMON_VPATH += $(SERIAL_PATH)
  21. ifeq ($(strip $(API_SYSEX_ENABLE)), yes)
  22. OPT_DEFS += -DAPI_SYSEX_ENABLE
  23. SRC += $(QUANTUM_DIR)/api/api_sysex.c
  24. OPT_DEFS += -DAPI_ENABLE
  25. SRC += $(QUANTUM_DIR)/api.c
  26. MIDI_ENABLE=yes
  27. endif
  28. MUSIC_ENABLE := 0
  29. ifeq ($(strip $(AUDIO_ENABLE)), yes)
  30. OPT_DEFS += -DAUDIO_ENABLE
  31. MUSIC_ENABLE := 1
  32. SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
  33. SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
  34. ifeq ($(PLATFORM),AVR)
  35. SRC += $(QUANTUM_DIR)/audio/audio.c
  36. else
  37. SRC += $(QUANTUM_DIR)/audio/audio_arm.c
  38. endif
  39. SRC += $(QUANTUM_DIR)/audio/voices.c
  40. SRC += $(QUANTUM_DIR)/audio/luts.c
  41. endif
  42. ifeq ($(strip $(MIDI_ENABLE)), yes)
  43. OPT_DEFS += -DMIDI_ENABLE
  44. MUSIC_ENABLE := 1
  45. SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
  46. endif
  47. ifeq ($(MUSIC_ENABLE), 1)
  48. SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
  49. endif
  50. ifeq ($(strip $(COMBO_ENABLE)), yes)
  51. OPT_DEFS += -DCOMBO_ENABLE
  52. SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c
  53. endif
  54. ifeq ($(strip $(STENO_ENABLE)), yes)
  55. OPT_DEFS += -DSTENO_ENABLE
  56. VIRTSER_ENABLE := yes
  57. SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
  58. endif
  59. ifeq ($(strip $(VIRTSER_ENABLE)), yes)
  60. OPT_DEFS += -DVIRTSER_ENABLE
  61. endif
  62. ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes)
  63. OPT_DEFS += -DFAUXCLICKY_ENABLE
  64. SRC += $(QUANTUM_DIR)/fauxclicky.c
  65. endif
  66. ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
  67. OPT_DEFS += -DPOINTING_DEVICE_ENABLE
  68. OPT_DEFS += -DMOUSE_ENABLE
  69. SRC += $(QUANTUM_DIR)/pointing_device.c
  70. endif
  71. ifeq ($(strip $(UCIS_ENABLE)), yes)
  72. OPT_DEFS += -DUCIS_ENABLE
  73. UNICODE_COMMON = yes
  74. SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
  75. endif
  76. ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
  77. OPT_DEFS += -DUNICODEMAP_ENABLE
  78. UNICODE_COMMON = yes
  79. SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
  80. endif
  81. ifeq ($(strip $(UNICODE_ENABLE)), yes)
  82. OPT_DEFS += -DUNICODE_ENABLE
  83. UNICODE_COMMON = yes
  84. SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
  85. endif
  86. ifeq ($(strip $(UNICODE_COMMON)), yes)
  87. SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
  88. endif
  89. ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
  90. POST_CONFIG_H += $(QUANTUM_DIR)/rgblight_post_config.h
  91. OPT_DEFS += -DRGBLIGHT_ENABLE
  92. SRC += $(QUANTUM_DIR)/color.c
  93. SRC += $(QUANTUM_DIR)/rgblight.c
  94. CIE1931_CURVE = yes
  95. LED_BREATHING_TABLE = yes
  96. ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
  97. OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
  98. else
  99. WS2812_DRIVER_REQUIRED = yes
  100. endif
  101. endif
  102. VALID_MATRIX_TYPES := yes IS31FL3731 IS31FL3733 IS31FL3737 WS2812 custom
  103. LED_MATRIX_ENABLE ?= no
  104. ifneq ($(strip $(LED_MATRIX_ENABLE)), no)
  105. ifeq ($(filter $(LED_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
  106. $(error LED_MATRIX_ENABLE="$(LED_MATRIX_ENABLE)" is not a valid matrix type)
  107. else
  108. OPT_DEFS += -DLED_MATRIX_ENABLE -DBACKLIGHT_ENABLE -DBACKLIGHT_CUSTOM_DRIVER
  109. SRC += $(QUANTUM_DIR)/led_matrix.c
  110. SRC += $(QUANTUM_DIR)/led_matrix_drivers.c
  111. endif
  112. endif
  113. ifeq ($(strip $(LED_MATRIX_ENABLE)), IS31FL3731)
  114. OPT_DEFS += -DIS31FL3731
  115. COMMON_VPATH += $(DRIVER_PATH)/issi
  116. SRC += is31fl3731-simple.c
  117. QUANTUM_LIB_SRC += i2c_master.c
  118. endif
  119. RGB_MATRIX_ENABLE ?= no
  120. ifneq ($(strip $(RGB_MATRIX_ENABLE)), no)
  121. ifeq ($(filter $(RGB_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
  122. $(error RGB_MATRIX_ENABLE="$(RGB_MATRIX_ENABLE)" is not a valid matrix type)
  123. endif
  124. OPT_DEFS += -DRGB_MATRIX_ENABLE
  125. SRC += $(QUANTUM_DIR)/color.c
  126. SRC += $(QUANTUM_DIR)/rgb_matrix.c
  127. SRC += $(QUANTUM_DIR)/rgb_matrix_drivers.c
  128. CIE1931_CURVE = yes
  129. endif
  130. ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
  131. RGB_MATRIX_ENABLE = IS31FL3731
  132. endif
  133. ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3731)
  134. OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  135. COMMON_VPATH += $(DRIVER_PATH)/issi
  136. SRC += is31fl3731.c
  137. QUANTUM_LIB_SRC += i2c_master.c
  138. endif
  139. ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3733)
  140. OPT_DEFS += -DIS31FL3733 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  141. COMMON_VPATH += $(DRIVER_PATH)/issi
  142. SRC += is31fl3733.c
  143. QUANTUM_LIB_SRC += i2c_master.c
  144. endif
  145. ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3737)
  146. OPT_DEFS += -DIS31FL3737 -DSTM32_I2C -DHAL_USE_I2C=TRUE
  147. COMMON_VPATH += $(DRIVER_PATH)/issi
  148. SRC += is31fl3737.c
  149. QUANTUM_LIB_SRC += i2c_master.c
  150. endif
  151. ifeq ($(strip $(RGB_MATRIX_ENABLE)), WS2812)
  152. OPT_DEFS += -DWS2812
  153. WS2812_DRIVER_REQUIRED = yes
  154. endif
  155. ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes)
  156. OPT_DEFS += -DRGB_MATRIX_CUSTOM_KB
  157. endif
  158. ifeq ($(strip $(RGB_MATRIX_CUSTOM_USER)), yes)
  159. OPT_DEFS += -DRGB_MATRIX_CUSTOM_USER
  160. endif
  161. ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
  162. OPT_DEFS += -DTAP_DANCE_ENABLE
  163. SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
  164. endif
  165. ifeq ($(strip $(KEY_LOCK_ENABLE)), yes)
  166. OPT_DEFS += -DKEY_LOCK_ENABLE
  167. SRC += $(QUANTUM_DIR)/process_keycode/process_key_lock.c
  168. endif
  169. ifeq ($(strip $(PRINTING_ENABLE)), yes)
  170. OPT_DEFS += -DPRINTING_ENABLE
  171. SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
  172. SRC += $(TMK_DIR)/protocol/serial_uart.c
  173. endif
  174. ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
  175. OPT_DEFS += -DAUTO_SHIFT_ENABLE
  176. SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
  177. ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes)
  178. OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
  179. endif
  180. endif
  181. ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
  182. SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
  183. OPT_DEFS += $(SERIAL_DEFS)
  184. VAPTH += $(SERIAL_PATH)
  185. endif
  186. ifneq ($(strip $(VARIABLE_TRACE)),)
  187. SRC += $(QUANTUM_DIR)/variable_trace.c
  188. OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
  189. ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
  190. OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
  191. endif
  192. endif
  193. ifeq ($(strip $(LCD_ENABLE)), yes)
  194. CIE1931_CURVE = yes
  195. endif
  196. # backward compat
  197. ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
  198. BACKLIGHT_ENABLE = custom
  199. endif
  200. VALID_BACKLIGHT_TYPES := yes software custom
  201. BACKLIGHT_ENABLE ?= no
  202. ifneq ($(strip $(BACKLIGHT_ENABLE)), no)
  203. ifeq ($(filter $(BACKLIGHT_ENABLE),$(VALID_BACKLIGHT_TYPES)),)
  204. $(error BACKLIGHT_ENABLE="$(BACKLIGHT_ENABLE)" is not a valid backlight type)
  205. endif
  206. ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
  207. CIE1931_CURVE = yes
  208. endif
  209. COMMON_VPATH += $(QUANTUM_DIR)/backlight
  210. SRC += $(QUANTUM_DIR)/backlight/backlight.c
  211. OPT_DEFS += -DBACKLIGHT_ENABLE
  212. ifeq ($(strip $(BACKLIGHT_ENABLE)), software)
  213. SRC += $(QUANTUM_DIR)/backlight/backlight_soft.c
  214. else
  215. ifeq ($(strip $(BACKLIGHT_ENABLE)), custom)
  216. OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
  217. endif
  218. ifeq ($(PLATFORM),AVR)
  219. SRC += $(QUANTUM_DIR)/backlight/backlight_avr.c
  220. else
  221. SRC += $(QUANTUM_DIR)/backlight/backlight_arm.c
  222. endif
  223. endif
  224. endif
  225. VALID_WS2812_DRIVER_TYPES := bitbang pwm spi i2c
  226. WS2812_DRIVER ?= bitbang
  227. ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
  228. ifeq ($(filter $(WS2812_DRIVER),$(VALID_WS2812_DRIVER_TYPES)),)
  229. $(error WS2812_DRIVER="$(WS2812_DRIVER)" is not a valid WS2812 driver)
  230. endif
  231. ifeq ($(strip $(WS2812_DRIVER)), bitbang)
  232. SRC += ws2812.c
  233. else
  234. SRC += ws2812_$(strip $(WS2812_DRIVER)).c
  235. endif
  236. # add extra deps
  237. ifeq ($(strip $(WS2812_DRIVER)), i2c)
  238. QUANTUM_LIB_SRC += i2c_master.c
  239. endif
  240. endif
  241. ifeq ($(strip $(CIE1931_CURVE)), yes)
  242. OPT_DEFS += -DUSE_CIE1931_CURVE
  243. LED_TABLES = yes
  244. endif
  245. ifeq ($(strip $(LED_BREATHING_TABLE)), yes)
  246. OPT_DEFS += -DUSE_LED_BREATHING_TABLE
  247. LED_TABLES = yes
  248. endif
  249. ifeq ($(strip $(LED_TABLES)), yes)
  250. SRC += $(QUANTUM_DIR)/led_tables.c
  251. endif
  252. ifeq ($(strip $(TERMINAL_ENABLE)), yes)
  253. SRC += $(QUANTUM_DIR)/process_keycode/process_terminal.c
  254. OPT_DEFS += -DTERMINAL_ENABLE
  255. OPT_DEFS += -DUSER_PRINT
  256. endif
  257. ifeq ($(strip $(USB_HID_ENABLE)), yes)
  258. include $(TMK_DIR)/protocol/usb_hid.mk
  259. endif
  260. ifeq ($(strip $(ENCODER_ENABLE)), yes)
  261. SRC += $(QUANTUM_DIR)/encoder.c
  262. OPT_DEFS += -DENCODER_ENABLE
  263. endif
  264. HAPTIC_ENABLE ?= no
  265. ifneq ($(strip $(HAPTIC_ENABLE)),no)
  266. COMMON_VPATH += $(DRIVER_PATH)/haptic
  267. SRC += haptic.c
  268. OPT_DEFS += -DHAPTIC_ENABLE
  269. endif
  270. ifneq ($(filter DRV2605L, $(HAPTIC_ENABLE)), )
  271. SRC += DRV2605L.c
  272. QUANTUM_LIB_SRC += i2c_master.c
  273. OPT_DEFS += -DDRV2605L
  274. endif
  275. ifneq ($(filter SOLENOID, $(HAPTIC_ENABLE)), )
  276. SRC += solenoid.c
  277. OPT_DEFS += -DSOLENOID_ENABLE
  278. endif
  279. ifeq ($(strip $(HD44780_ENABLE)), yes)
  280. SRC += drivers/avr/hd44780.c
  281. OPT_DEFS += -DHD44780_ENABLE
  282. endif
  283. ifeq ($(strip $(VELOCIKEY_ENABLE)), yes)
  284. OPT_DEFS += -DVELOCIKEY_ENABLE
  285. SRC += $(QUANTUM_DIR)/velocikey.c
  286. endif
  287. ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes)
  288. OPT_DEFS += -DDYNAMIC_KEYMAP_ENABLE
  289. SRC += $(QUANTUM_DIR)/dynamic_keymap.c
  290. endif
  291. ifeq ($(strip $(LEADER_ENABLE)), yes)
  292. SRC += $(QUANTUM_DIR)/process_keycode/process_leader.c
  293. OPT_DEFS += -DLEADER_ENABLE
  294. endif
  295. include $(DRIVER_PATH)/qwiic/qwiic.mk
  296. QUANTUM_SRC:= \
  297. $(QUANTUM_DIR)/quantum.c \
  298. $(QUANTUM_DIR)/keymap_common.c \
  299. $(QUANTUM_DIR)/keycode_config.c
  300. # Include the standard or split matrix code if needed
  301. ifneq ($(strip $(CUSTOM_MATRIX)), yes)
  302. ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
  303. QUANTUM_SRC += $(QUANTUM_DIR)/split_common/matrix.c
  304. else
  305. QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c
  306. endif
  307. endif
  308. DEBOUNCE_DIR:= $(QUANTUM_DIR)/debounce
  309. # Debounce Modules. Set DEBOUNCE_TYPE=custom if including one manually.
  310. DEBOUNCE_TYPE?= sym_g
  311. ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
  312. QUANTUM_SRC += $(DEBOUNCE_DIR)/$(strip $(DEBOUNCE_TYPE)).c
  313. endif
  314. ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
  315. POST_CONFIG_H += $(QUANTUM_DIR)/split_common/post_config.h
  316. OPT_DEFS += -DSPLIT_KEYBOARD
  317. # Include files used by all split keyboards
  318. QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_util.c
  319. # Determine which (if any) transport files are required
  320. ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
  321. QUANTUM_SRC += $(QUANTUM_DIR)/split_common/transport.c
  322. # Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
  323. # Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
  324. QUANTUM_LIB_SRC += $(QUANTUM_DIR)/split_common/serial.c \
  325. i2c_master.c \
  326. i2c_slave.c
  327. endif
  328. COMMON_VPATH += $(QUANTUM_PATH)/split_common
  329. endif
  330. ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
  331. OPT_DEFS += -DOLED_DRIVER_ENABLE
  332. COMMON_VPATH += $(DRIVER_PATH)/oled
  333. QUANTUM_LIB_SRC += i2c_master.c
  334. SRC += oled_driver.c
  335. endif
  336. SPACE_CADET_ENABLE ?= yes
  337. ifeq ($(strip $(SPACE_CADET_ENABLE)), yes)
  338. SRC += $(QUANTUM_DIR)/process_keycode/process_space_cadet.c
  339. OPT_DEFS += -DSPACE_CADET_ENABLE
  340. endif
  341. MAGIC_ENABLE ?= yes
  342. ifeq ($(strip $(MAGIC_ENABLE)), yes)
  343. SRC += $(QUANTUM_DIR)/process_keycode/process_magic.c
  344. OPT_DEFS += -DMAGIC_KEYCODE_ENABLE
  345. endif
  346. ifeq ($(strip $(DYNAMIC_MACRO_ENABLE)), yes)
  347. SRC += $(QUANTUM_DIR)/process_keycode/process_dynamic_macro.c
  348. OPT_DEFS += -DDYNAMIC_MACRO_ENABLE
  349. endif
  350. ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
  351. SRC += $(QUANTUM_DIR)/dip_switch.c
  352. OPT_DEFS += -DDIP_SWITCH_ENABLE
  353. endif