industry/scpi: add unit parser config options

Expose scpi-parser unit support through explicit Kconfig options instead of raw CFLAGS.

Map each option to the corresponding upstream USE_UNITS_* compile-time define, preserving the existing default unit set while allowing users to enable groups such as USE_UNITS_TIME.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
This commit is contained in:
Nightt 2026-06-24 11:52:41 +08:00 committed by Xiang Xiao
parent 085ca0606e
commit cea2f89f74
2 changed files with 82 additions and 1 deletions

View file

@ -7,10 +7,71 @@ config SCPI_PARSER
tristate "SCPI instrument side parser"
default n
if SCPI_PARSER
menu "SCPI parser unit support"
config SCPI_PARSER_UNITS_IMPERIAL
bool "Imperial units"
default n
config SCPI_PARSER_UNITS_ANGLE
bool "Angle units"
default n
config SCPI_PARSER_UNITS_PARTICLES
bool "Particle units"
default n
config SCPI_PARSER_UNITS_DISTANCE
bool "Distance units"
default n
config SCPI_PARSER_UNITS_MAGNETIC
bool "Magnetic units"
default n
config SCPI_PARSER_UNITS_LIGHT
bool "Light units"
default n
config SCPI_PARSER_UNITS_ENERGY_FORCE_MASS
bool "Energy, force, and mass units"
default n
config SCPI_PARSER_UNITS_TIME
bool "Time units"
default n
config SCPI_PARSER_UNITS_TEMPERATURE
bool "Temperature units"
default n
config SCPI_PARSER_UNITS_RATIO
bool "Ratio units"
default n
config SCPI_PARSER_UNITS_POWER
bool "Power units"
default y
config SCPI_PARSER_UNITS_FREQUENCY
bool "Frequency units"
default y
config SCPI_PARSER_UNITS_ELECTRIC
bool "Electric units"
default y
config SCPI_PARSER_UNITS_ELECTRIC_CHARGE_CONDUCTANCE
bool "Electric charge and conductance units"
default n
endmenu
config SCPI_PARSER_DEMO
bool "Enable the SCPI parser library demo"
default n
depends on SCPI_PARSER
if SCPI_PARSER_DEMO
@ -23,3 +84,5 @@ config SCPI_PARSER_DEMO_STACKSIZE
default DEFAULT_TASK_STACKSIZE
endif
endif

View file

@ -39,6 +39,24 @@ CFLAGS += -DHAVE_SNPRINTF
CFLAGS += -DHAVE_STRNDUP
CFLAGS += -DHAVE_STRNCASECMP
SCPI_UNIT = $(if $(filter y,$(CONFIG_SCPI_PARSER_UNITS_$(1))),1,0)
SCPI_UECC = $(call SCPI_UNIT,ELECTRIC_CHARGE_CONDUCTANCE)
CFLAGS += -DUSE_UNITS_IMPERIAL=$(call SCPI_UNIT,IMPERIAL)
CFLAGS += -DUSE_UNITS_ANGLE=$(call SCPI_UNIT,ANGLE)
CFLAGS += -DUSE_UNITS_PARTICLES=$(call SCPI_UNIT,PARTICLES)
CFLAGS += -DUSE_UNITS_DISTANCE=$(call SCPI_UNIT,DISTANCE)
CFLAGS += -DUSE_UNITS_MAGNETIC=$(call SCPI_UNIT,MAGNETIC)
CFLAGS += -DUSE_UNITS_LIGHT=$(call SCPI_UNIT,LIGHT)
CFLAGS += -DUSE_UNITS_ENERGY_FORCE_MASS=$(call SCPI_UNIT,ENERGY_FORCE_MASS)
CFLAGS += -DUSE_UNITS_TIME=$(call SCPI_UNIT,TIME)
CFLAGS += -DUSE_UNITS_TEMPERATURE=$(call SCPI_UNIT,TEMPERATURE)
CFLAGS += -DUSE_UNITS_RATIO=$(call SCPI_UNIT,RATIO)
CFLAGS += -DUSE_UNITS_POWER=$(call SCPI_UNIT,POWER)
CFLAGS += -DUSE_UNITS_FREQUENCY=$(call SCPI_UNIT,FREQUENCY)
CFLAGS += -DUSE_UNITS_ELECTRIC=$(call SCPI_UNIT,ELECTRIC)
CFLAGS += -DUSE_UNITS_ELECTRIC_CHARGE_CONDUCTANCE=$(SCPI_UECC)
ifneq ($(CONFIG_SCPI_PARSER_DEMO),)
MAINSRC = $(SCPI_UNPACK)/examples/test-interactive/main.c
CSRCS += scpi-def.c