From 8c67adc164d15d898b90fce6351190399f86d6f3 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 9 Apr 2025 12:52:11 -0400 Subject: [PATCH] Kconfig: Add new WANT_ADC option to reduce code size Make it possible to not compile in support for ADC on chips with small flash sizes. Signed-off-by: Kevin O'Connor --- src/Kconfig | 7 +++++++ src/Makefile | 2 +- src/atsamd/Makefile | 4 ++-- src/avr/Makefile | 2 +- src/hc32f460/Makefile | 2 +- src/lpc176x/Makefile | 4 ++-- src/pru/Makefile | 2 +- src/stm32/Makefile | 23 +++++++++++++---------- 8 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Kconfig b/src/Kconfig index fea53606..d87e0012 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -88,6 +88,10 @@ config USB_SERIAL_NUMBER endmenu # Optional features that can be disabled (for devices with small flash sizes) +config WANT_ADC + bool + depends on HAVE_GPIO_ADC + default y config WANT_SPI bool depends on HAVE_GPIO && HAVE_GPIO_SPI @@ -175,6 +179,9 @@ config NEED_SENSOR_BULK default y menu "Optional features (to reduce code size)" depends on HAVE_LIMITED_CODE_SIZE +config WANT_ADC + bool "Support micro-controller based ADC (analog to digital)" + depends on HAVE_GPIO_ADC config WANT_SPI bool "Support communicating with external chips via SPI bus" depends on HAVE_GPIO && HAVE_GPIO_SPI diff --git a/src/Makefile b/src/Makefile index a3bff2f4..ebebf14d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,7 +3,7 @@ src-y += sched.c command.c basecmd.c debugcmds.c 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_ADC) += adccmds.c src-$(CONFIG_WANT_SPI) += spicmds.c src-$(CONFIG_WANT_I2C) += i2ccmds.c src-$(CONFIG_WANT_HARD_PWM) += pwmcmds.c diff --git a/src/atsamd/Makefile b/src/atsamd/Makefile index df893d1a..2416200f 100644 --- a/src/atsamd/Makefile +++ b/src/atsamd/Makefile @@ -27,9 +27,9 @@ canbus-src-y := generic/canserial.c ../lib/fast-hash/fasthash.c 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_WANT_I2C) += atsamd/i2c.c +src-$(CONFIG_WANT_ADC) += atsamd/adc.c src-$(CONFIG_WANT_SPI) += atsamd/spi.c +src-$(CONFIG_WANT_I2C) += atsamd/i2c.c src-$(CONFIG_HAVE_SERCOM) += atsamd/sercom.c src-$(CONFIG_WANT_HARD_PWM) += atsamd/hard_pwm.c src-$(CONFIG_MACH_SAMC21) += atsamd/samd51_watchdog.c diff --git a/src/avr/Makefile b/src/avr/Makefile index f396f538..f667de3b 100644 --- a/src/avr/Makefile +++ b/src/avr/Makefile @@ -11,7 +11,7 @@ CFLAGS += $(CFLAGS-y) -mmcu=$(CONFIG_MCU) # Add avr source files 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_ADC) += avr/adc.c src-$(CONFIG_WANT_SPI) += avr/spi.c src-$(CONFIG_WANT_I2C) += avr/i2c.c src-$(CONFIG_WANT_HARD_PWM) += avr/hard_pwm.c diff --git a/src/hc32f460/Makefile b/src/hc32f460/Makefile index 87973074..2d2d5008 100644 --- a/src/hc32f460/Makefile +++ b/src/hc32f460/Makefile @@ -22,7 +22,7 @@ src-y += ../lib/hc32f460/driver/src/hc32f460_sram.c src-y += ../lib/hc32f460/driver/src/hc32f460_utility.c src-y += ../lib/hc32f460/driver/src/hc32f460_gpio.c src-y += ../lib/hc32f460/driver/src/hc32f460_pwc.c -src-$(CONFIG_HAVE_GPIO_ADC) += hc32f460/adc.c ../lib/hc32f460/driver/src/hc32f460_adc.c +src-$(CONFIG_WANT_ADC) += hc32f460/adc.c ../lib/hc32f460/driver/src/hc32f460_adc.c src-$(CONFIG_SERIAL) += hc32f460/serial.c generic/serial_irq.c ../lib/hc32f460/driver/src/hc32f460_usart.c src-$(CONFIG_WANT_HARD_PWM) += hc32f460/hard_pwm.c ../lib/hc32f460/driver/src/hc32f460_timera.c src-y += generic/armcm_boot.c generic/armcm_irq.c generic/armcm_timer.c diff --git a/src/lpc176x/Makefile b/src/lpc176x/Makefile index a36e6778..0e2b41cf 100644 --- a/src/lpc176x/Makefile +++ b/src/lpc176x/Makefile @@ -16,9 +16,9 @@ src-y += lpc176x/main.c lpc176x/gpio.c 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_WANT_I2C) += lpc176x/i2c.c +src-$(CONFIG_WANT_ADC) += lpc176x/adc.c src-$(CONFIG_WANT_SPI) += lpc176x/spi.c +src-$(CONFIG_WANT_I2C) += lpc176x/i2c.c src-$(CONFIG_USBSERIAL) += lpc176x/usbserial.c lpc176x/chipid.c src-$(CONFIG_USBSERIAL) += generic/usb_cdc.c src-$(CONFIG_SERIAL) += lpc176x/serial.c generic/serial_irq.c diff --git a/src/pru/Makefile b/src/pru/Makefile index 5c85f5e3..c9624d1e 100644 --- a/src/pru/Makefile +++ b/src/pru/Makefile @@ -17,7 +17,7 @@ CFLAGS_pru1.elf := $(CFLAGS) # Add source files src-y += pru/main.c pru/gpio.c generic/timer_irq.c -src-$(CONFIG_HAVE_GPIO_ADC) += pru/adc.c +src-$(CONFIG_WANT_ADC) += pru/adc.c pru0-y := pru/pru0.c generic/crc16_ccitt.c command.c pru0-y += ../lib/pru_rpmsg/pru_rpmsg.c ../lib/pru_rpmsg/pru_virtqueue.c diff --git a/src/stm32/Makefile b/src/stm32/Makefile index 39e206bd..6b0505a5 100644 --- a/src/stm32/Makefile +++ b/src/stm32/Makefile @@ -43,34 +43,37 @@ 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 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 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 +src-$(CONFIG_MACH_STM32F2) += stm32/gpioperiph.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 +src-$(CONFIG_MACH_STM32F4) += stm32/gpioperiph.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 +src-$(CONFIG_MACH_STM32F7) += stm32/gpioperiph.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 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/gpioperiph.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/gpioperiph.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 +adc-src-y := stm32/adc.c +adc-src-$(CONFIG_MACH_STM32F0) := stm32/stm32f0_adc.c +adc-src-$(CONFIG_MACH_N32G45x) := ../lib/n32g45x/n32g45x_adc.c stm32/n32g45x_adc.c +adc-src-$(CONFIG_MACH_STM32G0) := stm32/stm32f0_adc.c +adc-src-$(CONFIG_MACH_STM32G4) := stm32/stm32h7_adc.c +adc-src-$(CONFIG_MACH_STM32H7) := stm32/stm32h7_adc.c +adc-src-$(CONFIG_MACH_STM32L4) := stm32/stm32h7_adc.c +src-$(CONFIG_WANT_ADC) += $(adc-src-y) spi-src-y := stm32/spi.c spi-src-$(CONFIG_MACH_STM32H7) := stm32/stm32h7_spi.c src-$(CONFIG_WANT_SPI) += $(spi-src-y)