Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedupe I2C, SPI, UART driver inclusions #22253

Merged
merged 5 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 89 additions & 96 deletions builddefs/common_features.mk

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions docs/i2c_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

The I2C Master drivers used in QMK have a set of common functions to allow portability between MCUs.

## Usage :id=usage

In most cases, the I2C Master driver code is automatically included if you are using a feature or driver which requires it, such as [OLED](feature_oled_driver.md).

However, if you need to use the driver standalone, add the following to your `rules.mk`:

```make
I2C_DRIVER_REQUIRED = yes
```

You can then call the I2C API by including `i2c_master.h` in your code.

## I2C Addressing :id=note-on-i2c-addresses

All of the addresses expected by this driver should be pushed to the upper 7 bits of the address byte. Setting
Expand Down
12 changes: 12 additions & 0 deletions docs/spi_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

The SPI Master drivers used in QMK have a set of common functions to allow portability between MCUs.

## Usage :id=usage

In most cases, the SPI Master driver code is automatically included if you are using a feature or driver which requires it, such as [OLED](feature_oled_driver.md).

However, if you need to use the driver standalone, add the following to your `rules.mk`:

```make
SPI_DRIVER_REQUIRED = yes
```

You can then call the SPI API by including `spi_master.h` in your code.

## AVR Configuration :id=avr-configuration

No special setup is required - just connect the `SS`, `SCK`, `MOSI` and `MISO` pins of your SPI devices to the matching pins on the MCU:
Expand Down
12 changes: 12 additions & 0 deletions docs/uart_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ The UART drivers used in QMK have a set of common functions to allow portability

Currently, this driver does not support enabling hardware flow control (the `RTS` and `CTS` pins) if available, but may do so in future.

## Usage :id=usage

In most cases, the UART driver code is automatically included if you are using a feature or driver which requires it.

However, if you need to use the driver standalone, add the following to your `rules.mk`:

```make
UART_DRIVER_REQUIRED = yes
```

You can then call the UART API by including `uart.h` in your code.

## AVR Configuration :id=avr-configuration

No special setup is required - just connect the `RX` and `TX` pins of your UART device to the opposite pins on the MCU:
Expand Down
2 changes: 1 addition & 1 deletion keyboards/3w6/rev1/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ NO_USB_STARTUP_CHECK = yes
LTO_ENABLE = no

SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/3w6/rev2/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ NO_USB_STARTUP_CHECK = yes
LTO_ENABLE = no

SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/40percentclub/ut47/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ AUDIO_ENABLE = no # Audio output
# custom matrix setup
CUSTOM_MATRIX = yes
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/aeboards/satellite/rev1/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ COMMON_VPATH += $(DRIVER_PATH)/issi
# project specific files
SRC += drivers/led/issi/is31fl3731.c

QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 0 additions & 2 deletions keyboards/anavi/knob1/rules.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
OLED_ENABLE = yes

OPT_DEFS += -DHAL_USE_I2C=TRUE
2 changes: 0 additions & 2 deletions keyboards/anavi/knobs3/rules.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
OLED_ENABLE = yes

OPT_DEFS += -DHAL_USE_I2C=TRUE
2 changes: 1 addition & 1 deletion keyboards/bajjak/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ AUDIO_SUPPORTED = no

# project specific files
SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/barleycorn_smd/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ AUDIO_ENABLE = no # Audio output
CUSTOM_MATRIX = lite

SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/bioi/g60/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ BLUETOOTH_ENABLE = yes

VIA_ENABLE = yes # VIA support should be enabled here due to the main() loop will be compiled first.

QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes
SRC += bluetooth_custom.c
2 changes: 1 addition & 1 deletion keyboards/bioi/g60ble/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ LTO_ENABLE = yes

BLUETOOTH_ENABLE = yes

QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes
SRC += bluetooth_custom.c
2 changes: 1 addition & 1 deletion keyboards/bioi/morgan65/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ BLUETOOTH_ENABLE = yes

VIA_ENABLE = yes # VIA support should be enabled here due to the main() loop will be compiled first.

QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes
SRC += bluetooth_custom.c
2 changes: 1 addition & 1 deletion keyboards/centromere/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ CUSTOM_MATRIX = lite

# project specific files
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes
3 changes: 2 additions & 1 deletion keyboards/clueboard/2x1800/2021/rules.mk
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
QUANTUM_LIB_SRC += max7219.c spi_master.c
SPI_DRIVER_REQUIRED = yes
QUANTUM_LIB_SRC += max7219.c
2 changes: 1 addition & 1 deletion keyboards/converter/palm_usb/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
CUSTOM_MATRIX = yes

SRC += matrix.c
QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes

DEFAULT_FOLDER = converter/palm_usb/stowaway
2 changes: 1 addition & 1 deletion keyboards/converter/sun_usb/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
CUSTOM_MATRIX = yes

SRC += matrix.c led.c
QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes

DEFAULT_FOLDER = converter/sun_usb/type5
4 changes: 2 additions & 2 deletions keyboards/dc01/left/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
AUDIO_ENABLE = no # Audio output

CUSTOM_MATRIX = yes # Use custom matrix
SRC += matrix.c \
i2c_master.c
SRC += matrix.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/dichotomy/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ NKRO_ENABLE = yes # Enable N-Key Rollover

# # project specific files
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/ergodox_ez/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RGB_MATRIX_ENABLE = no # enable later
# project specific files
SRC += matrix.c \
led_i2c.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes

# Disable unsupported hardware
AUDIO_SUPPORTED = no
Expand Down
2 changes: 1 addition & 1 deletion keyboards/ergodox_stm32/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ CUSTOM_MATRIX = yes # Custom matrix file
UNICODE_ENABLE = yes # Unicode

SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/fallacy/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ AUDIO_ENABLE = no # Audio output
# project specific files
SRC += indicators.c \
drivers/led/issi/is31fl3731-simple.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/fc660c/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NKRO_ENABLE = yes # Enable N-Key Rollover
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes

CUSTOM_MATRIX = yes
SRC += matrix.c ad5258.c
2 changes: 1 addition & 1 deletion keyboards/fc980c/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NKRO_ENABLE = yes # Enable N-Key Rollover
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes

CUSTOM_MATRIX = yes
SRC += matrix.c ad5258.c
2 changes: 1 addition & 1 deletion keyboards/ferris/0_1/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ NO_USB_STARTUP_CHECK = yes
LTO_ENABLE = yes

SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/ferris/0_2/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ NO_USB_STARTUP_CHECK = yes
LTO_ENABLE = no

SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes

DEFAULT_FOLDER = ferris/0_2/base
2 changes: 1 addition & 1 deletion keyboards/frobiac/blackbowl/rules.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CUSTOM_MATRIX = lite

# project specific files
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
SRC += matrix.c

PS2_MOUSE_ENABLE = yes
Expand Down
3 changes: 2 additions & 1 deletion keyboards/gboards/ergotaco/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ COMMAND_ENABLE = yes
# know what you're doing.
#
# No touchy, capiche?
SRC += matrix.c i2c_master.c
SRC += matrix.c
I2C_DRIVER_REQUIRED = yes
3 changes: 2 additions & 1 deletion keyboards/gboards/georgi/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ CUSTOM_MATRIX = yes
STENO_ENABLE = yes
LTO_ENABLE = yes

SRC += matrix.c i2c_master.c
SRC += matrix.c
I2C_DRIVER_REQUIRED = yes
3 changes: 2 additions & 1 deletion keyboards/gboards/gergo/keymaps/colemak/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ DEBUG_MATRIX = no
# know what you're doing.
#
# No touchy, capiche?
SRC += matrix.c i2c_master.c
SRC += matrix.c
I2C_DRIVER_REQUIRED = yes
ifneq ($(strip $(BALLSTEP)),)
OPT_DEFS += -DTRKSTEP=$(strip $(BALLSTEP))
endif
Expand Down
3 changes: 2 additions & 1 deletion keyboards/gboards/gergo/keymaps/default/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ DEBUG_MATRIX = yes
# know what you're doing.
#
# No touchy, capiche?
SRC += matrix.c i2c_master.c
SRC += matrix.c
I2C_DRIVER_REQUIRED = yes
ifneq ($(strip $(BALLSTEP)),)
OPT_DEFS += -DTRKSTEP=$(strip $(BALLSTEP))
endif
Expand Down
3 changes: 2 additions & 1 deletion keyboards/gboards/gergo/keymaps/germ/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ DEBUG_MATRIX = no
# know what you're doing.
#
# No touchy, capiche?
SRC += matrix.c i2c_master.c
SRC += matrix.c
I2C_DRIVER_REQUIRED = yes
ifneq ($(strip $(BALLSTEP)),)
OPT_DEFS += -DTRKSTEP=$(strip $(BALLSTEP))
endif
Expand Down
3 changes: 2 additions & 1 deletion keyboards/gboards/gergo/keymaps/gotham/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ DEBUG_MATRIX = yes
# know what you're doing.
#
# No touchy, capiche?
SRC += matrix.c i2c_master.c
SRC += matrix.c
I2C_DRIVER_REQUIRED = yes
ifneq ($(strip $(BALLSTEP)),)
OPT_DEFS += -DTRKSTEP=$(strip $(BALLSTEP))
endif
Expand Down
2 changes: 1 addition & 1 deletion keyboards/gboards/gergo/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ COMMAND_ENABLE = yes
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite

SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/gboards/gergoplex/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ AUDIO_ENABLE = no # Audio output
CUSTOM_MATRIX = yes

SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/geistmaschine/macropod/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CUSTOM_MATRIX = lite

VPATH += drivers/gpio
SRC += pca9555.c matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/glenpickle/chimera_ergo/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ CUSTOM_MATRIX = lite

# project specific files
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/glenpickle/chimera_ls/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CUSTOM_MATRIX = lite

# project specific files
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes

# Disable unsupported hardware
RGBLIGHT_SUPPORTED = no
Expand Down
2 changes: 1 addition & 1 deletion keyboards/glenpickle/chimera_ortho/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ CUSTOM_MATRIX = lite

# project specific files
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/glenpickle/chimera_ortho_plus/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ CUSTOM_MATRIX = lite

# project specific files
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c
UART_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/handwired/dactyl/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ SWAP_HANDS_ENABLE = yes # Allow swapping hands of keyboard
RGBLIGHT_ENABLE = no

# project specific files
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
SRC += matrix.c
2 changes: 1 addition & 1 deletion keyboards/handwired/dqz11n1g/rules.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Keyboard matrix uses shift-registers read via SPI
CUSTOM_MATRIX = lite
SRC += matrix.c
QUANTUM_LIB_SRC += spi_master.c
SPI_DRIVER_REQUIRED = yes

# Build Options
# change yes to no to disable
Expand Down
2 changes: 1 addition & 1 deletion keyboards/handwired/dygma/raise/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CUSTOM_MATRIX = lite
# alternate usb endpoints.
RAW_ENABLE = yes

QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
SRC += matrix.c

DEFAULT_FOLDER = handwired/dygma/raise/ansi
4 changes: 2 additions & 2 deletions keyboards/handwired/frenchdev/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ AUDIO_ENABLE = no # Audio output
RGBLIGHT_ENABLE = no

# project specific files
SRC = i2c_master.c \
matrix.c
SRC = matrix.c
I2C_DRIVER_REQUIRED = yes
3 changes: 2 additions & 1 deletion keyboards/handwired/lagrange/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ UNICODE_ENABLE = yes
SPLIT_KEYBOARD = yes
SPLIT_TRANSPORT = custom

SRC += transport.c spi_master.c
SRC += transport.c
SPI_DRIVER_REQUIRED = yes
2 changes: 0 additions & 2 deletions keyboards/handwired/onekey/kb2040/rules.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
OLED_ENABLE = yes

OPT_DEFS += -DHAL_USE_I2C=TRUE
2 changes: 1 addition & 1 deletion keyboards/handwired/onekey/keymaps/i2c_scanner/rules.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CONSOLE_ENABLE = yes

QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/handwired/pterodactyl/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ CUSTOM_MATRIX = yes
BLUETOOTH_ENABLE = yes

SRC += matrix.c
QUANTUM_LIB_SRC += i2c_master.c
I2C_DRIVER_REQUIRED = yes
2 changes: 1 addition & 1 deletion keyboards/hazel/bad_wings/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CAPS_WORD_ENABLE = yes

SRC += matrix.c

QUANTUM_LIB_SRC += spi_master.c
SPI_DRIVER_REQUIRED = yes
CUSTOM_MATRIX = lite

POINTING_DEVICE_DRIVER = cirque_pinnacle_spi
Expand Down
2 changes: 1 addition & 1 deletion keyboards/hotdox/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ RGBLIGHT_ENABLE = no

# project specific files
SRC = matrix.c \
i2c_master.c \
left.c
I2C_DRIVER_REQUIRED = yes
Loading