aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2025-04-09 12:36:24 -0400
committerKevin O'Connor <kevin@koconnor.net>2025-04-16 13:54:44 -0400
commit04e7eb20fd9b65addcbb4773fdb7b6be9dbf6195 (patch)
tree5a57fe1f0a283e8b5e07a257fdd2af85c493cd50 /src
parent868760f5b1013843aff7390bb94adfb4cb3fe679 (diff)
downloadkutter-04e7eb20fd9b65addcbb4773fdb7b6be9dbf6195.tar.gz
kutter-04e7eb20fd9b65addcbb4773fdb7b6be9dbf6195.tar.xz
kutter-04e7eb20fd9b65addcbb4773fdb7b6be9dbf6195.zip
Kconfig: Add new WANT_I2C option to reduce code size
Make it possible to not compile in support for I2C on chips with small flash sizes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/Kconfig37
-rw-r--r--src/Makefile4
-rw-r--r--src/atsamd/Makefile2
-rw-r--r--src/avr/Makefile2
-rw-r--r--src/lpc176x/Makefile2
-rw-r--r--src/rp2040/Makefile2
-rw-r--r--src/sensor_lis2dw.c6
-rw-r--r--src/stm32/Makefile21
8 files changed, 43 insertions, 33 deletions
diff --git a/src/Kconfig b/src/Kconfig
index e4ff5863..fea53606 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -96,6 +96,14 @@ config WANT_SOFTWARE_SPI
bool
depends on WANT_SPI
default y
+config WANT_I2C
+ bool
+ depends on HAVE_GPIO && HAVE_GPIO_I2C
+ default y
+config WANT_SOFTWARE_I2C
+ bool
+ depends on WANT_I2C
+ default y
config WANT_HARD_PWM
bool
depends on HAVE_GPIO_HARD_PWM
@@ -134,15 +142,15 @@ config WANT_ADXL345
default y
config WANT_LIS2DW
bool
- depends on WANT_SPI || HAVE_GPIO_I2C
+ depends on WANT_SPI || WANT_I2C
default y
config WANT_MPU9250
bool
- depends on HAVE_GPIO_I2C
+ depends on WANT_I2C
default y
config WANT_ICM20948
bool
- depends on HAVE_GPIO_I2C
+ depends on WANT_I2C
default y
config WANT_HX71X
bool
@@ -154,16 +162,12 @@ config WANT_ADS1220
default y
config WANT_LDC1612
bool
- depends on HAVE_GPIO_I2C
+ depends on WANT_I2C
default y
config WANT_SENSOR_ANGLE
bool
depends on WANT_SPI
default y
-config WANT_SOFTWARE_I2C
- bool
- depends on HAVE_GPIO && HAVE_GPIO_I2C
- default y
config NEED_SENSOR_BULK
bool
depends on WANT_ADXL345 || WANT_LIS2DW || WANT_MPU9250 || WANT_ICM20948 \
@@ -177,6 +181,12 @@ config WANT_SPI
config WANT_SOFTWARE_SPI
bool "Support software based SPI \"bit-banging\""
depends on WANT_SPI
+config WANT_I2C
+ bool "Support communicating with external chips via I2C bus"
+ depends on HAVE_GPIO && HAVE_GPIO_I2C
+config WANT_SOFTWARE_I2C
+ bool "Support software based I2C \"bit-banging\""
+ depends on WANT_I2C
config WANT_HARD_PWM
bool "Support hardware PWM (pulse width modulation)"
depends on HAVE_GPIO_HARD_PWM
@@ -206,13 +216,13 @@ config WANT_ADXL345
depends on WANT_SPI
config WANT_LIS2DW
bool "Support lis2dw and lis3dh 3-axis accelerometers"
- depends on WANT_SPI || HAVE_GPIO_I2C
+ depends on WANT_SPI || WANT_I2C
config WANT_MPU9250
bool "Support MPU accelerometers"
- depends on HAVE_GPIO_I2C
+ depends on WANT_I2C
config WANT_ICM20948
bool "Support ICM20948 accelerometer"
- depends on HAVE_GPIO_I2C
+ depends on WANT_I2C
config WANT_HX71X
bool "Support HX711 and HX717 ADC chips"
depends on HAVE_GPIO
@@ -221,13 +231,10 @@ config WANT_ADS1220
depends on WANT_SPI
config WANT_LDC1612
bool "Support ldc1612 eddy current sensor"
- depends on HAVE_GPIO_I2C
+ depends on WANT_I2C
config WANT_SENSOR_ANGLE
bool "Support angle sensors"
depends on WANT_SPI
-config WANT_SOFTWARE_I2C
- bool "Support software based I2C \"bit-banging\""
- depends on HAVE_GPIO && HAVE_GPIO_I2C
endmenu
# Generic configuration options for CANbus
diff --git a/src/Makefile b/src/Makefile
index f6641e12..a3bff2f4 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -5,9 +5,9 @@ src-$(CONFIG_HAVE_GPIO) += initial_pins.c gpiocmds.c stepper.c endstop.c \
trsync.c
src-$(CONFIG_HAVE_GPIO_ADC) += adccmds.c
src-$(CONFIG_WANT_SPI) += spicmds.c
-src-$(CONFIG_HAVE_GPIO_SDIO) += sdiocmds.c
-src-$(CONFIG_HAVE_GPIO_I2C) += i2ccmds.c
+src-$(CONFIG_WANT_I2C) += i2ccmds.c
src-$(CONFIG_WANT_HARD_PWM) += pwmcmds.c
+src-$(CONFIG_HAVE_GPIO_SDIO) += sdiocmds.c
src-$(CONFIG_WANT_BUTTONS) += buttons.c
src-$(CONFIG_WANT_TMCUART) += tmcuart.c
diff --git a/src/atsamd/Makefile b/src/atsamd/Makefile
index cfad6a1c..df893d1a 100644
--- a/src/atsamd/Makefile
+++ b/src/atsamd/Makefile
@@ -28,7 +28,7 @@ canbus-src-y += atsamd/fdcan.c atsamd/chipid.c
src-$(CONFIG_USBCANBUS) += $(canbus-src-y) atsamd/usbserial.c generic/usb_canbus.c
src-$(CONFIG_CANSERIAL) += $(canbus-src-y) generic/canbus.c
src-$(CONFIG_HAVE_GPIO_ADC) += atsamd/adc.c
-src-$(CONFIG_HAVE_GPIO_I2C) += atsamd/i2c.c
+src-$(CONFIG_WANT_I2C) += atsamd/i2c.c
src-$(CONFIG_WANT_SPI) += atsamd/spi.c
src-$(CONFIG_HAVE_SERCOM) += atsamd/sercom.c
src-$(CONFIG_WANT_HARD_PWM) += atsamd/hard_pwm.c
diff --git a/src/avr/Makefile b/src/avr/Makefile
index 02b6657d..f396f538 100644
--- a/src/avr/Makefile
+++ b/src/avr/Makefile
@@ -13,7 +13,7 @@ src-y += avr/main.c avr/timer.c
src-$(CONFIG_HAVE_GPIO) += avr/gpio.c
src-$(CONFIG_HAVE_GPIO_ADC) += avr/adc.c
src-$(CONFIG_WANT_SPI) += avr/spi.c
-src-$(CONFIG_HAVE_GPIO_I2C) += avr/i2c.c
+src-$(CONFIG_WANT_I2C) += avr/i2c.c
src-$(CONFIG_WANT_HARD_PWM) += avr/hard_pwm.c
src-$(CONFIG_AVR_WATCHDOG) += avr/watchdog.c
src-$(CONFIG_USBSERIAL) += avr/usbserial.c generic/usb_cdc.c
diff --git a/src/lpc176x/Makefile b/src/lpc176x/Makefile
index 9a6ecac4..a36e6778 100644
--- a/src/lpc176x/Makefile
+++ b/src/lpc176x/Makefile
@@ -17,7 +17,7 @@ src-y += generic/armcm_boot.c generic/armcm_irq.c generic/armcm_timer.c
src-y += generic/armcm_reset.c generic/crc16_ccitt.c
src-y += ../lib/lpc176x/device/system_LPC17xx.c
src-$(CONFIG_HAVE_GPIO_ADC) += lpc176x/adc.c
-src-$(CONFIG_HAVE_GPIO_I2C) += lpc176x/i2c.c
+src-$(CONFIG_WANT_I2C) += lpc176x/i2c.c
src-$(CONFIG_WANT_SPI) += lpc176x/spi.c
src-$(CONFIG_USBSERIAL) += lpc176x/usbserial.c lpc176x/chipid.c
src-$(CONFIG_USBSERIAL) += generic/usb_cdc.c
diff --git a/src/rp2040/Makefile b/src/rp2040/Makefile
index e9884f0e..359d99c1 100644
--- a/src/rp2040/Makefile
+++ b/src/rp2040/Makefile
@@ -30,7 +30,7 @@ src-$(CONFIG_USBCANBUS) += generic/canserial.c generic/usb_canbus.c
src-$(CONFIG_USBCANBUS) += ../lib/fast-hash/fasthash.c rp2040/usbserial.c
src-$(CONFIG_WANT_HARD_PWM) += rp2040/hard_pwm.c
src-$(CONFIG_WANT_SPI) += rp2040/spi.c
-src-$(CONFIG_HAVE_GPIO_I2C) += rp2040/i2c.c
+src-$(CONFIG_WANT_I2C) += rp2040/i2c.c
# rp2040 stage2 building
STAGE2_FILE := $(shell echo $(CONFIG_RP2040_STAGE2_FILE))
diff --git a/src/sensor_lis2dw.c b/src/sensor_lis2dw.c
index d4108667..bf4beba1 100644
--- a/src/sensor_lis2dw.c
+++ b/src/sensor_lis2dw.c
@@ -85,7 +85,7 @@ command_config_lis2dw(uint32_t *args)
shutdown("bus_type spi unsupported");
}
case I2C_SERIAL:
- if (CONFIG_HAVE_GPIO_I2C) {
+ if (CONFIG_WANT_I2C) {
ax->i2c = i2cdev_oid_lookup(args[1]);
ax->bus_type = I2C_SERIAL;
break;
@@ -147,7 +147,7 @@ lis2dw_query(struct lis2dw *ax, uint8_t oid)
for (uint32_t i = 0; i < BYTES_PER_SAMPLE; i++)
d[i] = msg[i + 1];
- } else if (CONFIG_HAVE_GPIO_I2C && ax->bus_type == I2C_SERIAL) {
+ } else if (CONFIG_WANT_I2C && ax->bus_type == I2C_SERIAL) {
uint8_t msg_reg[] = {LIS_AR_DATAX0};
if (ax->model == LIS3DH)
msg_reg[0] |= LIS_MS_I2C;
@@ -226,7 +226,7 @@ command_query_lis2dw_status(uint32_t *args)
spidev_transfer(ax->spi, 1, sizeof(msg), msg);
time2 = timer_read_time();
status = msg[1];
- } else if (CONFIG_HAVE_GPIO_I2C && ax->bus_type == I2C_SERIAL) {
+ } else if (CONFIG_WANT_I2C && ax->bus_type == I2C_SERIAL) {
uint8_t fifo_reg[1] = {LIS_FIFO_SAMPLES};
uint8_t fifo[1];
diff --git a/src/stm32/Makefile b/src/stm32/Makefile
index bb3fe7fc..39e206bd 100644
--- a/src/stm32/Makefile
+++ b/src/stm32/Makefile
@@ -43,39 +43,42 @@ src-y += generic/armcm_boot.c generic/armcm_irq.c generic/armcm_reset.c
src-$(CONFIG_MACH_STM32F0) += ../lib/stm32f0/system_stm32f0xx.c
src-$(CONFIG_MACH_STM32F0) += generic/timer_irq.c stm32/stm32f0_timer.c
src-$(CONFIG_MACH_STM32F0) += stm32/stm32f0.c stm32/gpioperiph.c
-src-$(CONFIG_MACH_STM32F0) += stm32/stm32f0_adc.c stm32/stm32f0_i2c.c
+src-$(CONFIG_MACH_STM32F0) += stm32/stm32f0_adc.c
src-$(CONFIG_MACH_STM32F103) += ../lib/stm32f1/system_stm32f1xx.c
src-$(CONFIG_MACH_STM32F103) += stm32/adc.c
src-$(CONFIG_MACH_N32G45x) += ../lib/stm32f1/system_stm32f1xx.c
src-$(CONFIG_MACH_N32G45x) += ../lib/n32g45x/n32g45x_adc.c stm32/n32g45x_adc.c
-src-$(CONFIG_MACH_STM32F1) += stm32/stm32f1.c generic/armcm_timer.c stm32/i2c.c
+src-$(CONFIG_MACH_STM32F1) += stm32/stm32f1.c generic/armcm_timer.c
src-$(CONFIG_MACH_STM32F2) += ../lib/stm32f2/system_stm32f2xx.c
src-$(CONFIG_MACH_STM32F2) += stm32/stm32f4.c generic/armcm_timer.c
-src-$(CONFIG_MACH_STM32F2) += stm32/gpioperiph.c stm32/adc.c stm32/i2c.c
+src-$(CONFIG_MACH_STM32F2) += stm32/gpioperiph.c stm32/adc.c
src-$(CONFIG_MACH_STM32F4) += ../lib/stm32f4/system_stm32f4xx.c
src-$(CONFIG_MACH_STM32F4) += stm32/stm32f4.c generic/armcm_timer.c
-src-$(CONFIG_MACH_STM32F4) += stm32/gpioperiph.c stm32/adc.c stm32/i2c.c
+src-$(CONFIG_MACH_STM32F4) += stm32/gpioperiph.c stm32/adc.c
src-$(CONFIG_MACH_STM32F7) += ../lib/stm32f7/system_stm32f7xx.c
src-$(CONFIG_MACH_STM32F7) += stm32/stm32f7.c generic/armcm_timer.c
-src-$(CONFIG_MACH_STM32F7) += stm32/gpioperiph.c stm32/adc.c stm32/stm32f0_i2c.c
+src-$(CONFIG_MACH_STM32F7) += stm32/gpioperiph.c stm32/adc.c
src-$(CONFIG_MACH_STM32G0) += generic/timer_irq.c stm32/stm32f0_timer.c
src-$(CONFIG_MACH_STM32G0) += stm32/stm32g0.c stm32/gpioperiph.c
-src-$(CONFIG_MACH_STM32G0) += stm32/stm32f0_adc.c stm32/stm32f0_i2c.c
+src-$(CONFIG_MACH_STM32G0) += stm32/stm32f0_adc.c
src-$(CONFIG_MACH_STM32G4) += ../lib/stm32g4/system_stm32g4xx.c
src-$(CONFIG_MACH_STM32G4) += stm32/stm32g4.c generic/armcm_timer.c
src-$(CONFIG_MACH_STM32G4) += stm32/gpioperiph.c stm32/stm32h7_adc.c
-src-$(CONFIG_MACH_STM32G4) += stm32/stm32f0_i2c.c
src-$(CONFIG_MACH_STM32H7) += ../lib/stm32h7/system_stm32h7xx.c
src-$(CONFIG_MACH_STM32H7) += stm32/stm32h7.c generic/armcm_timer.c
src-$(CONFIG_MACH_STM32H7) += stm32/gpioperiph.c stm32/stm32h7_adc.c
-src-$(CONFIG_MACH_STM32H7) += stm32/stm32f0_i2c.c
src-$(CONFIG_MACH_STM32L4) += ../lib/stm32l4/system_stm32l4xx.c
src-$(CONFIG_MACH_STM32L4) += stm32/stm32l4.c generic/armcm_timer.c
src-$(CONFIG_MACH_STM32L4) += stm32/gpioperiph.c
-src-$(CONFIG_MACH_STM32L4) += stm32/stm32h7_adc.c stm32/stm32f0_i2c.c
+src-$(CONFIG_MACH_STM32L4) += stm32/stm32h7_adc.c
spi-src-y := stm32/spi.c
spi-src-$(CONFIG_MACH_STM32H7) := stm32/stm32h7_spi.c
src-$(CONFIG_WANT_SPI) += $(spi-src-y)
+i2c-src-y := stm32/stm32f0_i2c.c
+i2c-src-$(CONFIG_MACH_STM32F1) := stm32/i2c.c
+i2c-src-$(CONFIG_MACH_STM32F2) := stm32/i2c.c
+i2c-src-$(CONFIG_MACH_STM32F4) := stm32/i2c.c
+src-$(CONFIG_WANT_I2C) += $(i2c-src-y)
sdio-src-y := stm32/sdio.c
src-$(CONFIG_HAVE_GPIO_SDIO) += $(sdio-src-y)
usb-src-$(CONFIG_HAVE_STM32_USBFS) := stm32/usbfs.c