diff --git a/.gitignore b/.gitignore index cf41face..d7441e60 100644 --- a/.gitignore +++ b/.gitignore @@ -73,9 +73,11 @@ eagle.epf obj_* inc/commandslist.h inc/comps/* +inc/shared_comps/* src/hal_tbl.c src/conf_templates.c stm32f303/inc/commandslist.h stm32f303/inc/comps/* +stm32f303/inc/shared_comps/* stm32f303/src/hal_tbl.c toolchain-user.mak diff --git a/Makefile b/Makefile index 0dc011b2..8cf2f8fb 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,8 @@ TARGET = $(OBJDIR)/stmbl # Define all C source files (dependencies are generated automatically) INCDIRS += inc INCDIRS += inc/comps +INCDIRS += inc/comps/hw +INCDIRS += inc/shared_comps INCDIRS += shared SOURCES += src/main.c @@ -29,96 +31,97 @@ SOURCES += src/hal_tbl.c HWVERSION = v4 ifeq ($(HWVERSION),v3) - COMPS += src/comps/hw/io3.c - COMPS += src/comps/hvf1.c - COMPS += shared/comps/pmsm.c - COMPS += shared/comps/curpid.c - COMPS += shared/comps/dq.c - COMPS += shared/comps/idq.c - SOURCES += shared/common_f1.c + SRC_COMPS += src/comps/hw/io3.c + SRC_COMPS += src/comps/hvf1.c + SHARED_COMPS += shared/comps/pmsm.c + SHARED_COMPS += shared/comps/curpid.c + SHARED_COMPS += shared/comps/dq.c + SHARED_COMPS += shared/comps/idq.c + SHARED_COMPS += shared/common_f1.c CFLAGS += -DV3 else - COMPS += src/comps/hw/io4.c - COMPS += src/comps/hv.c + SRC_COMPS += src/comps/hw/io4.c + SRC_COMPS += src/comps/hv.c #TODO: need backport to v3 - COMPS += src/comps/enc_cmd.c - COMPS += src/comps/o_fb.c - COMPS += src/comps/sserial.c - COMPS += src/comps/yaskawa.c - COMPS += src/comps/encs.c - COMPS += src/comps/encf.c - COMPS += src/comps/endat.c + SRC_COMPS += src/comps/enc_cmd.c + SRC_COMPS += src/comps/o_fb.c + SRC_COMPS += src/comps/sserial.c + SRC_COMPS += src/comps/yaskawa.c + SRC_COMPS += src/comps/encs.c + SRC_COMPS += src/comps/encf.c + SRC_COMPS += src/comps/endat.c CFLAGS += -DV4 endif -COMPS += src/comps/usart.c -COMPS += src/comps/encm.c -COMPS += src/comps/dmm.c -COMPS += src/comps/smartabs.c -COMPS += src/comps/adc.c -COMPS += src/comps/enc_fb.c -COMPS += src/comps/conf.c -COMPS += src/comps/res.c -COMPS += src/comps/hx711.c +SRC_COMPS += src/comps/usart.c +SRC_COMPS += src/comps/encm.c +SRC_COMPS += src/comps/dmm.c +SRC_COMPS += src/comps/smartabs.c +SRC_COMPS += src/comps/adc.c +SRC_COMPS += src/comps/enc_fb.c +SRC_COMPS += src/comps/conf.c +SRC_COMPS += src/comps/res.c +SRC_COMPS += src/comps/hx711.c -COMPS += shared/comps/sim.c -COMPS += shared/comps/term.c -COMPS += shared/comps/svm.c +SHARED_COMPS += shared/comps/sim.c +SHARED_COMPS += shared/comps/term.c +SHARED_COMPS += shared/comps/svm.c -COMPS += shared/comps/vel.c -COMPS += shared/comps/rev.c -COMPS += shared/comps/hal_test.c -# COMPS += shared/comps/dc.c -COMPS += shared/comps/ypid.c -COMPS += shared/comps/fault.c -COMPS += shared/comps/pid.c -COMPS += shared/comps/spid.c -COMPS += shared/comps/pe.c -COMPS += shared/comps/pmsm_limits.c -COMPS += shared/comps/pmsm_ttc.c -COMPS += shared/comps/dc_limits.c -COMPS += shared/comps/dc_ttc.c -COMPS += shared/comps/acim_ttc.c -COMPS += shared/comps/uvw.c -COMPS += shared/comps/fanuc.c -COMPS += shared/comps/fb_switch.c -COMPS += shared/comps/reslimit.c -COMPS += shared/comps/iit.c -COMPS += shared/comps/vel_int.c -COMPS += shared/comps/linrev.c -COMPS += shared/comps/psi.c -COMPS += shared/comps/stp.c -#COMPS += shared/comps/uf.c -COMPS += shared/comps/uf2.c -COMPS += shared/comps/ramp.c -COMPS += shared/comps/scale.c -COMPS += shared/comps/idx_home.c -COMPS += shared/comps/move.c -# COMPS += shared/comps/ac.c -COMPS += shared/comps/not.c -COMPS += shared/comps/and.c -COMPS += shared/comps/or.c -COMPS += shared/comps/jog.c -COMPS += shared/comps/velbuf.c -COMPS += shared/comps/avg.c -COMPS += shared/comps/mux.c -COMPS += shared/comps/veltopos.c -# COMPS += shared/comps/wobl.c -COMPS += shared/comps/debounce.c -COMPS += shared/comps/pos_filter.c -COMPS += shared/comps/rl.c -COMPS += shared/comps/mad.c -COMPS += shared/comps/sensorless.c -COMPS += shared/comps/field.c -COMPS += shared/comps/gain.c -COMPS += shared/comps/rlpsij.c -COMPS += shared/comps/veltime.c -COMPS += shared/comps/mpid.c -COMPS += shared/comps/fmove.c -COMPS += shared/comps/home.c -COMPS += shared/comps/en.c -COMPS += shared/comps/th.c +SHARED_COMPS += shared/comps/vel.c +SHARED_COMPS += shared/comps/rev.c +SHARED_COMPS += shared/comps/hal_test.c +# SHARED_COMPS += shared/comps/dc.c +SHARED_COMPS += shared/comps/ypid.c +SHARED_COMPS += shared/comps/fault.c +SHARED_COMPS += shared/comps/pid.c +SHARED_COMPS += shared/comps/spid.c +SHARED_COMPS += shared/comps/pe.c +SHARED_COMPS += shared/comps/pmsm_limits.c +SHARED_COMPS += shared/comps/pmsm_ttc.c +SHARED_COMPS += shared/comps/dc_limits.c +SHARED_COMPS += shared/comps/dc_ttc.c +SHARED_COMPS += shared/comps/acim_ttc.c +SHARED_COMPS += shared/comps/uvw.c +SHARED_COMPS += shared/comps/fanuc.c +SHARED_COMPS += shared/comps/fb_switch.c +SHARED_COMPS += shared/comps/reslimit.c +SHARED_COMPS += shared/comps/iit.c +SHARED_COMPS += shared/comps/vel_int.c +SHARED_COMPS += shared/comps/linrev.c +SHARED_COMPS += shared/comps/psi.c +SHARED_COMPS += shared/comps/stp.c +#SHARED_COMPS += shared/comps/uf.c +SHARED_COMPS += shared/comps/uf2.c +SHARED_COMPS += shared/comps/ramp.c +SHARED_COMPS += shared/comps/scale.c +SHARED_COMPS += shared/comps/idx_home.c +SHARED_COMPS += shared/comps/move.c +# SHARED_COMPS += shared/comps/ac.c +SHARED_COMPS += shared/comps/not.c +SHARED_COMPS += shared/comps/and.c +SHARED_COMPS += shared/comps/or.c +SHARED_COMPS += shared/comps/jog.c +SHARED_COMPS += shared/comps/velbuf.c +SHARED_COMPS += shared/comps/avg.c +SHARED_COMPS += shared/comps/mux.c +SHARED_COMPS += shared/comps/veltopos.c +# SHARED_COMPS += shared/comps/wobl.c +SHARED_COMPS += shared/comps/debounce.c +SHARED_COMPS += shared/comps/pos_filter.c +SHARED_COMPS += shared/comps/rl.c +SHARED_COMPS += shared/comps/mad.c +SHARED_COMPS += shared/comps/sensorless.c +SHARED_COMPS += shared/comps/field.c +SHARED_COMPS += shared/comps/gain.c +SHARED_COMPS += shared/comps/rlpsij.c +SHARED_COMPS += shared/comps/veltime.c +SHARED_COMPS += shared/comps/mpid.c +SHARED_COMPS += shared/comps/fmove.c +SHARED_COMPS += shared/comps/home.c +SHARED_COMPS += shared/comps/en.c +SHARED_COMPS += shared/comps/th.c +COMPS = $(SRC_COMPS) $(SHARED_COMPS) SOURCES += $(COMPS) # SOURCES += src/eeprom.c @@ -194,6 +197,8 @@ CPPFLAGS += -DHSE_VALUE=8000000 LDSCRIPT = stm32_flash.ld #============================================================================ +SRC_COMP_OBJECTS = $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SRC_COMPS)))) +SHARED_COMP_OBJECTS = $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SHARED_COMPS)))) OBJECTS += $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SOURCES)))) OBJECTS += hv_firmware.o CPPFLAGS += $(addprefix -I,$(INCDIRS)) @@ -289,18 +294,27 @@ bin: tbl $(TARGET).bin lss: $(TARGET).lss sym: $(TARGET).sym -$(OBJECTS): src/hal_tbl.c - $(OBJDIR)/shared/commands.o: inc/commandslist.h inc/commandslist.h: tools/create_cmd.py $(SOURCES) @echo Generating commands list @$(PYTHON) tools/create_cmd.py inc/commandslist.h $(SOURCES) -src/hal_tbl.c &: tools/create_hal_tbl.py $(COMPS) +src/hal_tbl.c: tools/create_hal_tbl.py $(COMPS) @echo Generating HAL table - @$(PYTHON) tools/create_hal_tbl.py . $(COMPS) - @$(PYTHON) tools/inc_comps.py . $(COMPS) + @$(PYTHON) tools/create_hal_tbl.py src/hal_tbl.c $(COMPS) + +$(SRC_COMP_OBJECTS): $(OBJDIR)/src/comps/%.o: inc/comps/%_comp.h + +$(SHARED_COMP_OBJECTS): $(OBJDIR)/shared/comps/%.o: inc/shared_comps/%_comp.h + +inc/comps/%_comp.h: src/comps/%.c + @echo Generating H: $< + @$(PYTHON) tools/create_comp_h.py $@ $< + +inc/shared_comps/%_comp.h: shared/comps/%.c + @echo Generating H: $< + @$(PYTHON) tools/create_comp_h.py $@ $< src/conf_templates.c: tools/create_config.py $(CONFIG_TEMPLATES) @echo Generating config @@ -407,6 +421,7 @@ clean: rm -rf $(OBJDIR) rm -rf inc/commandslist.h rm -rf inc/comps/* + rm -rf inc/shared_comps/* rm -rf src/conf_templates.c rm -rf src/hal_tbl.c @$(MAKE) -f bootloader/Makefile clean diff --git a/shared/comps/acim_ttc.c b/shared/comps/acim_ttc.c index 8709bffd..ba7d9501 100644 --- a/shared/comps/acim_ttc.c +++ b/shared/comps/acim_ttc.c @@ -1,4 +1,4 @@ -#include "comps/acim_ttc_comp.h" +#include "acim_ttc_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/and.c b/shared/comps/and.c index ad0db223..5da0a7fa 100644 --- a/shared/comps/and.c +++ b/shared/comps/and.c @@ -1,4 +1,4 @@ -#include "comps/and_comp.h" +#include "and_comp.h" #include "hal.h" HAL_COMP(and); diff --git a/shared/comps/avg.c b/shared/comps/avg.c index cfb669d4..d28245c5 100644 --- a/shared/comps/avg.c +++ b/shared/comps/avg.c @@ -1,4 +1,4 @@ -#include "comps/avg_comp.h" +#include "avg_comp.h" #include "hal.h" #include "defines.h" diff --git a/shared/comps/curpid.c b/shared/comps/curpid.c index 972fc352..9b117764 100644 --- a/shared/comps/curpid.c +++ b/shared/comps/curpid.c @@ -1,4 +1,4 @@ -#include "comps/curpid_comp.h" +#include "curpid_comp.h" #include "commands.h" #include "common.h" #include "hal.h" diff --git a/shared/comps/dc_limits.c b/shared/comps/dc_limits.c index bfcefe4e..77c7cad6 100644 --- a/shared/comps/dc_limits.c +++ b/shared/comps/dc_limits.c @@ -1,4 +1,4 @@ -#include "comps/dc_limits_comp.h" +#include "dc_limits_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/dc_ttc.c b/shared/comps/dc_ttc.c index 5b6d0626..7d0e26db 100644 --- a/shared/comps/dc_ttc.c +++ b/shared/comps/dc_ttc.c @@ -1,4 +1,4 @@ -#include "comps/dc_ttc_comp.h" +#include "dc_ttc_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/debounce.c b/shared/comps/debounce.c index a29d55f9..e3d2c609 100644 --- a/shared/comps/debounce.c +++ b/shared/comps/debounce.c @@ -1,4 +1,4 @@ -#include "comps/debounce_comp.h" +#include "debounce_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/dq.c b/shared/comps/dq.c index 30c4b9b1..43f80a72 100644 --- a/shared/comps/dq.c +++ b/shared/comps/dq.c @@ -1,4 +1,4 @@ -#include "comps/dq_comp.h" +#include "dq_comp.h" #include "commands.h" #include "common.h" #include "hal.h" diff --git a/shared/comps/en.c b/shared/comps/en.c index c18691b0..c1a4afe0 100644 --- a/shared/comps/en.c +++ b/shared/comps/en.c @@ -1,4 +1,4 @@ -#include "comps/en_comp.h" +#include "en_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/fanuc.c b/shared/comps/fanuc.c index 297461e5..a9d782d8 100644 --- a/shared/comps/fanuc.c +++ b/shared/comps/fanuc.c @@ -1,4 +1,4 @@ -#include "comps/fanuc_comp.h" +#include "fanuc_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/fault.c b/shared/comps/fault.c index 9f414e96..999a88cd 100644 --- a/shared/comps/fault.c +++ b/shared/comps/fault.c @@ -1,4 +1,4 @@ -#include "comps/fault_comp.h" +#include "fault_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/fb_switch.c b/shared/comps/fb_switch.c index 86b82379..6c71879d 100644 --- a/shared/comps/fb_switch.c +++ b/shared/comps/fb_switch.c @@ -1,4 +1,4 @@ -#include "comps/fb_switch_comp.h" +#include "fb_switch_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/field.c b/shared/comps/field.c index 56aacda3..07eb0f79 100644 --- a/shared/comps/field.c +++ b/shared/comps/field.c @@ -1,4 +1,4 @@ -#include "comps/field_comp.h" +#include "field_comp.h" /* * This file is part of the stmbl project. * diff --git a/shared/comps/fmove.c b/shared/comps/fmove.c index a545cc7b..87d10c1d 100644 --- a/shared/comps/fmove.c +++ b/shared/comps/fmove.c @@ -1,4 +1,4 @@ -#include "comps/fmove_comp.h" +#include "fmove_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/gain.c b/shared/comps/gain.c index 7f0d34c9..57b3ba99 100644 --- a/shared/comps/gain.c +++ b/shared/comps/gain.c @@ -1,4 +1,4 @@ -#include "comps/gain_comp.h" +#include "gain_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/hal_test.c b/shared/comps/hal_test.c index b13c5284..20f93135 100644 --- a/shared/comps/hal_test.c +++ b/shared/comps/hal_test.c @@ -1,4 +1,4 @@ -#include "comps/hal_test_comp.h" +#include "hal_test_comp.h" #include "hal.h" HAL_COMP(hal_test); diff --git a/shared/comps/home.c b/shared/comps/home.c index 8e196541..85d8c778 100644 --- a/shared/comps/home.c +++ b/shared/comps/home.c @@ -1,4 +1,4 @@ -#include "comps/home_comp.h" +#include "home_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/idq.c b/shared/comps/idq.c index 99f9a87f..29e29807 100644 --- a/shared/comps/idq.c +++ b/shared/comps/idq.c @@ -1,4 +1,4 @@ -#include "comps/idq_comp.h" +#include "idq_comp.h" #include "commands.h" #include "common.h" #include "hal.h" diff --git a/shared/comps/idx_home.c b/shared/comps/idx_home.c index 374df928..4be9e00d 100644 --- a/shared/comps/idx_home.c +++ b/shared/comps/idx_home.c @@ -1,4 +1,4 @@ -#include "comps/idx_home_comp.h" +#include "idx_home_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/iit.c b/shared/comps/iit.c index 919a3b95..bb4a56eb 100644 --- a/shared/comps/iit.c +++ b/shared/comps/iit.c @@ -1,4 +1,4 @@ -#include "comps/iit_comp.h" +#include "iit_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/jog.c b/shared/comps/jog.c index 32fd8d50..01207ca1 100644 --- a/shared/comps/jog.c +++ b/shared/comps/jog.c @@ -1,4 +1,4 @@ -#include "comps/jog_comp.h" +#include "jog_comp.h" #include "commands.h" #include "hal.h" #include "defines.h" diff --git a/shared/comps/linrev.c b/shared/comps/linrev.c index c5b8373b..07c36d68 100644 --- a/shared/comps/linrev.c +++ b/shared/comps/linrev.c @@ -1,4 +1,4 @@ -#include "comps/linrev_comp.h" +#include "linrev_comp.h" //Calculate motor angle from position in machine units /* diff --git a/shared/comps/mad.c b/shared/comps/mad.c index ccf9caad..803e294b 100644 --- a/shared/comps/mad.c +++ b/shared/comps/mad.c @@ -1,4 +1,4 @@ -#include "comps/mad_comp.h" +#include "mad_comp.h" #include "hal.h" HAL_COMP(mad); diff --git a/shared/comps/move.c b/shared/comps/move.c index 0454d78c..1aea73c0 100644 --- a/shared/comps/move.c +++ b/shared/comps/move.c @@ -1,4 +1,4 @@ -#include "comps/move_comp.h" +#include "move_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/mpid.c b/shared/comps/mpid.c index 9a3cb756..435d5cd9 100644 --- a/shared/comps/mpid.c +++ b/shared/comps/mpid.c @@ -1,4 +1,4 @@ -#include "comps/mpid_comp.h" +#include "mpid_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/mux.c b/shared/comps/mux.c index ff3e0f46..68e2dfae 100644 --- a/shared/comps/mux.c +++ b/shared/comps/mux.c @@ -1,4 +1,4 @@ -#include "comps/mux_comp.h" +#include "mux_comp.h" #include "hal.h" #include "defines.h" diff --git a/shared/comps/not.c b/shared/comps/not.c index f863ac2a..e566eb93 100644 --- a/shared/comps/not.c +++ b/shared/comps/not.c @@ -1,4 +1,4 @@ -#include "comps/not_comp.h" +#include "not_comp.h" #include "hal.h" HAL_COMP(not); diff --git a/shared/comps/or.c b/shared/comps/or.c index 23230e07..e3a2a3d5 100644 --- a/shared/comps/or.c +++ b/shared/comps/or.c @@ -1,4 +1,4 @@ -#include "comps/or_comp.h" +#include "or_comp.h" #include "hal.h" HAL_COMP(or); diff --git a/shared/comps/pe.c b/shared/comps/pe.c index 52cd5fde..b90610c5 100644 --- a/shared/comps/pe.c +++ b/shared/comps/pe.c @@ -1,4 +1,4 @@ -#include "comps/pe_comp.h" +#include "pe_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/pid.c b/shared/comps/pid.c index e19c1551..ba9e53bc 100644 --- a/shared/comps/pid.c +++ b/shared/comps/pid.c @@ -1,4 +1,4 @@ -#include "comps/pid_comp.h" +#include "pid_comp.h" /* * This file is part of the stmbl project. * diff --git a/shared/comps/pmsm_limits.c b/shared/comps/pmsm_limits.c index 9b25da59..81c3191b 100644 --- a/shared/comps/pmsm_limits.c +++ b/shared/comps/pmsm_limits.c @@ -1,4 +1,4 @@ -#include "comps/pmsm_limits_comp.h" +#include "pmsm_limits_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/pmsm_ttc.c b/shared/comps/pmsm_ttc.c index 6ff7adb4..56765f53 100644 --- a/shared/comps/pmsm_ttc.c +++ b/shared/comps/pmsm_ttc.c @@ -1,4 +1,4 @@ -#include "comps/pmsm_ttc_comp.h" +#include "pmsm_ttc_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/pos_filter.c b/shared/comps/pos_filter.c index 2a7139a0..978a55d0 100644 --- a/shared/comps/pos_filter.c +++ b/shared/comps/pos_filter.c @@ -1,4 +1,4 @@ -#include "comps/pos_filter_comp.h" +#include "pos_filter_comp.h" #include "hal.h" #include "angle.h" #include "defines.h" diff --git a/shared/comps/psi.c b/shared/comps/psi.c index b4512052..af980da3 100644 --- a/shared/comps/psi.c +++ b/shared/comps/psi.c @@ -1,4 +1,4 @@ -#include "comps/psi_comp.h" +#include "psi_comp.h" #include "hal.h" #include "math.h" #include "defines.h" diff --git a/shared/comps/ramp.c b/shared/comps/ramp.c index dfe68698..57d4fcd1 100644 --- a/shared/comps/ramp.c +++ b/shared/comps/ramp.c @@ -1,4 +1,4 @@ -#include "comps/ramp_comp.h" +#include "ramp_comp.h" #include "commands.h" #include "hal.h" #include "defines.h" diff --git a/shared/comps/reslimit.c b/shared/comps/reslimit.c index 1b417c4c..750d1714 100644 --- a/shared/comps/reslimit.c +++ b/shared/comps/reslimit.c @@ -1,4 +1,4 @@ -#include "comps/reslimit_comp.h" +#include "reslimit_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/rev.c b/shared/comps/rev.c index 5e3c49bd..bec0ba62 100644 --- a/shared/comps/rev.c +++ b/shared/comps/rev.c @@ -1,4 +1,4 @@ -#include "comps/rev_comp.h" +#include "rev_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/rl.c b/shared/comps/rl.c index 20bc75ab..c9fbf958 100644 --- a/shared/comps/rl.c +++ b/shared/comps/rl.c @@ -1,4 +1,4 @@ -#include "comps/rl_comp.h" +#include "rl_comp.h" #include "hal.h" #include "angle.h" #include "defines.h" diff --git a/shared/comps/rlpsij.c b/shared/comps/rlpsij.c index eb1d92b1..8514f1d7 100644 --- a/shared/comps/rlpsij.c +++ b/shared/comps/rlpsij.c @@ -1,4 +1,4 @@ -#include "comps/rlpsij_comp.h" +#include "rlpsij_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/scale.c b/shared/comps/scale.c index 6d8becee..7894ef9a 100644 --- a/shared/comps/scale.c +++ b/shared/comps/scale.c @@ -1,4 +1,4 @@ -#include "comps/scale_comp.h" +#include "scale_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/sensorless.c b/shared/comps/sensorless.c index d2aa5ed4..e4596e34 100644 --- a/shared/comps/sensorless.c +++ b/shared/comps/sensorless.c @@ -1,4 +1,4 @@ -#include "comps/sensorless_comp.h" +#include "sensorless_comp.h" /* * This file is part of the stmbl project. * diff --git a/shared/comps/sim.c b/shared/comps/sim.c index 09f924ec..fb77ac46 100644 --- a/shared/comps/sim.c +++ b/shared/comps/sim.c @@ -1,4 +1,4 @@ -#include "comps/sim_comp.h" +#include "sim_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/spid.c b/shared/comps/spid.c index 7f00d069..b71d077e 100644 --- a/shared/comps/spid.c +++ b/shared/comps/spid.c @@ -1,4 +1,4 @@ -#include "comps/spid_comp.h" +#include "spid_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/stp.c b/shared/comps/stp.c index b2cd03b0..758f9b7c 100644 --- a/shared/comps/stp.c +++ b/shared/comps/stp.c @@ -1,4 +1,4 @@ -#include "comps/stp_comp.h" +#include "stp_comp.h" #include "hal.h" #include "math.h" #include "defines.h" diff --git a/shared/comps/svm.c b/shared/comps/svm.c index cfc4eea2..090a3730 100644 --- a/shared/comps/svm.c +++ b/shared/comps/svm.c @@ -1,4 +1,4 @@ -#include "comps/svm_comp.h" +#include "svm_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/term.c b/shared/comps/term.c index b2fd6c91..d8ed91aa 100644 --- a/shared/comps/term.c +++ b/shared/comps/term.c @@ -1,4 +1,4 @@ -#include "comps/term_comp.h" +#include "term_comp.h" #include "commands.h" #include "hal.h" #include "defines.h" diff --git a/shared/comps/th.c b/shared/comps/th.c index f0af5c8c..9e77fe5c 100644 --- a/shared/comps/th.c +++ b/shared/comps/th.c @@ -1,4 +1,4 @@ -#include "comps/th_comp.h" +#include "th_comp.h" #include "hal.h" HAL_COMP(th); diff --git a/shared/comps/uf2.c b/shared/comps/uf2.c index 22608c8e..d3a9e0b1 100644 --- a/shared/comps/uf2.c +++ b/shared/comps/uf2.c @@ -1,4 +1,4 @@ -#include "comps/uf2_comp.h" +#include "uf2_comp.h" #include "hal.h" #include "defines.h" #include "angle.h" diff --git a/shared/comps/uvw.c b/shared/comps/uvw.c index 85e57d90..194a827b 100644 --- a/shared/comps/uvw.c +++ b/shared/comps/uvw.c @@ -1,4 +1,4 @@ -#include "comps/uvw_comp.h" +#include "uvw_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/vel.c b/shared/comps/vel.c index 7684b02c..293ad7ff 100644 --- a/shared/comps/vel.c +++ b/shared/comps/vel.c @@ -1,4 +1,4 @@ -#include "comps/vel_comp.h" +#include "vel_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/vel_int.c b/shared/comps/vel_int.c index b9596069..6f9d995b 100644 --- a/shared/comps/vel_int.c +++ b/shared/comps/vel_int.c @@ -1,4 +1,4 @@ -#include "comps/vel_int_comp.h" +#include "vel_int_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/velbuf.c b/shared/comps/velbuf.c index 62b2a4f4..d0770797 100644 --- a/shared/comps/velbuf.c +++ b/shared/comps/velbuf.c @@ -1,4 +1,4 @@ -#include "comps/velbuf_comp.h" +#include "velbuf_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/veltime.c b/shared/comps/veltime.c index 12d1f0ad..45ad464f 100644 --- a/shared/comps/veltime.c +++ b/shared/comps/veltime.c @@ -1,4 +1,4 @@ -#include "comps/veltime_comp.h" +#include "veltime_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/veltopos.c b/shared/comps/veltopos.c index 87ce24e9..fc6acb6e 100644 --- a/shared/comps/veltopos.c +++ b/shared/comps/veltopos.c @@ -1,4 +1,4 @@ -#include "comps/veltopos_comp.h" +#include "veltopos_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/shared/comps/ypid.c b/shared/comps/ypid.c index d8cb4269..c4a1fc29 100644 --- a/shared/comps/ypid.c +++ b/shared/comps/ypid.c @@ -1,4 +1,4 @@ -#include "comps/ypid_comp.h" +#include "ypid_comp.h" /* * This file is part of the stmbl project. * diff --git a/src/comps/adc.c b/src/comps/adc.c index e4c29d06..9ea36c7a 100644 --- a/src/comps/adc.c +++ b/src/comps/adc.c @@ -1,4 +1,4 @@ -#include "comps/adc_comp.h" +#include "adc_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/conf.c b/src/comps/conf.c index 431fde7d..548258ca 100644 --- a/src/comps/conf.c +++ b/src/comps/conf.c @@ -1,4 +1,4 @@ -#include "comps/conf_comp.h" +#include "conf_comp.h" #include #include "main.h" // for Wait #include "commands.h" diff --git a/src/comps/enc_cmd.c b/src/comps/enc_cmd.c index a82ed204..97603357 100644 --- a/src/comps/enc_cmd.c +++ b/src/comps/enc_cmd.c @@ -1,4 +1,4 @@ -#include "comps/enc_cmd_comp.h" +#include "enc_cmd_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/enc_fb.c b/src/comps/enc_fb.c index 894b9bb3..305d0d89 100644 --- a/src/comps/enc_fb.c +++ b/src/comps/enc_fb.c @@ -1,4 +1,4 @@ -#include "comps/enc_fb_comp.h" +#include "enc_fb_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/encf.c b/src/comps/encf.c index 545dc529..e161dab1 100644 --- a/src/comps/encf.c +++ b/src/comps/encf.c @@ -1,4 +1,4 @@ -#include "comps/encf_comp.h" +#include "encf_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/encm.c b/src/comps/encm.c index c9ef1db9..b6abb3c9 100644 --- a/src/comps/encm.c +++ b/src/comps/encm.c @@ -1,4 +1,4 @@ -#include "comps/encm_comp.h" +#include "encm_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/encs.c b/src/comps/encs.c index 9645ce74..c610e752 100644 --- a/src/comps/encs.c +++ b/src/comps/encs.c @@ -1,4 +1,4 @@ -#include "comps/encs_comp.h" +#include "encs_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/endat.c b/src/comps/endat.c index 77dc8537..a7a0aa55 100644 --- a/src/comps/endat.c +++ b/src/comps/endat.c @@ -1,4 +1,4 @@ -#include "comps/endat_comp.h" +#include "endat_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/hv.c b/src/comps/hv.c index 1fd5a283..ef19150d 100644 --- a/src/comps/hv.c +++ b/src/comps/hv.c @@ -1,4 +1,4 @@ -#include "comps/hv_comp.h" +#include "hv_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/hw/io4.c b/src/comps/hw/io4.c index 44ff2971..5f12bd12 100644 --- a/src/comps/hw/io4.c +++ b/src/comps/hw/io4.c @@ -1,4 +1,4 @@ -#include "comps/io4_comp.h" +#include "io4_comp.h" #include "commands.h" #include "hal.h" #include "defines.h" diff --git a/src/comps/hx711.c b/src/comps/hx711.c index 1cd75cc0..10f53923 100644 --- a/src/comps/hx711.c +++ b/src/comps/hx711.c @@ -1,4 +1,4 @@ -#include "comps/hx711_comp.h" +#include "hx711_comp.h" /* * This file is part of the stmbl project. * diff --git a/src/comps/o_fb.c b/src/comps/o_fb.c index d7fffd19..f52e1a3a 100644 --- a/src/comps/o_fb.c +++ b/src/comps/o_fb.c @@ -1,4 +1,4 @@ -#include "comps/o_fb_comp.h" +#include "o_fb_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/res.c b/src/comps/res.c index 79ce3508..fc43f1a4 100644 --- a/src/comps/res.c +++ b/src/comps/res.c @@ -1,4 +1,4 @@ -#include "comps/res_comp.h" +#include "res_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/smartabs.c b/src/comps/smartabs.c index a44ba56e..7d263509 100644 --- a/src/comps/smartabs.c +++ b/src/comps/smartabs.c @@ -1,4 +1,4 @@ -#include "comps/smartabs_comp.h" +#include "smartabs_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/sserial.c b/src/comps/sserial.c index b7290e61..2135780b 100644 --- a/src/comps/sserial.c +++ b/src/comps/sserial.c @@ -1,4 +1,4 @@ -#include "comps/sserial_comp.h" +#include "sserial_comp.h" /* * This file is part of the stmbl project. * diff --git a/src/comps/usart.c b/src/comps/usart.c index 27315917..4915303b 100644 --- a/src/comps/usart.c +++ b/src/comps/usart.c @@ -1,4 +1,4 @@ -#include "comps/usart_comp.h" +#include "usart_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/src/comps/yaskawa.c b/src/comps/yaskawa.c index fcbb820d..fdd29dd0 100644 --- a/src/comps/yaskawa.c +++ b/src/comps/yaskawa.c @@ -1,4 +1,4 @@ -#include "comps/yaskawa_comp.h" +#include "yaskawa_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/stm32f303/Makefile b/stm32f303/Makefile index c682822f..6e0d0edf 100644 --- a/stm32f303/Makefile +++ b/stm32f303/Makefile @@ -15,6 +15,7 @@ TARGET = $(OBJDIR)/hvf3 # Define all C source files (dependencies are generated automatically) INCDIRS += stm32f303/inc INCDIRS += stm32f303/inc/comps +INCDIRS += stm32f303/inc/shared_comps SOURCES += stm32f303/src/main.c SOURCES += stm32f303/src/adc.c SOURCES += stm32f303/src/dac.c @@ -28,23 +29,24 @@ SOURCES += stm32f303/src/version.c SOURCES += stm32f303/src/hal_tbl.c CFLAGS += -DHAL_MAX_CTX=1024 -COMPS += stm32f303/src/comps/hv.c -COMPS += stm32f303/src/comps/io.c -COMPS += stm32f303/src/comps/ls.c -#COMPS += stm32f303/src/comps/enc.c +SRC_COMPS += stm32f303/src/comps/hv.c +SRC_COMPS += stm32f303/src/comps/io.c +SRC_COMPS += stm32f303/src/comps/ls.c +#SRC_COMPS += stm32f303/src/comps/enc.c -COMPS += shared/comps/sim.c -COMPS += shared/comps/term.c -COMPS += shared/comps/curpid.c -COMPS += shared/comps/svm.c -COMPS += shared/comps/dq.c -COMPS += shared/comps/idq.c -COMPS += shared/comps/sensorless.c -# COMPS += shared/comps/vel.c -# COMPS += shared/comps/hal_test.c -# COMPS += shared/comps/dc.c -# COMPS += shared/comps/ypid.c +SHARED_COMPS += shared/comps/sim.c +SHARED_COMPS += shared/comps/term.c +SHARED_COMPS += shared/comps/curpid.c +SHARED_COMPS += shared/comps/svm.c +SHARED_COMPS += shared/comps/dq.c +SHARED_COMPS += shared/comps/idq.c +SHARED_COMPS += shared/comps/sensorless.c +# SHARED_COMPS += shared/comps/vel.c +# SHARED_COMPS += shared/comps/hal_test.c +# SHARED_COMPS += shared/comps/dc.c +# SHARED_COMPS += shared/comps/ypid.c +COMPS = $(SRC_COMPS) $(SHARED_COMPS) SOURCES += $(COMPS) INCDIRS += shared @@ -86,6 +88,8 @@ SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_uart_ex.c LDSCRIPT = stm32f303/STM32F303CBTx_FLASH.ld #============================================================================ +SRC_COMP_OBJECTS = $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SRC_COMPS)))) +SHARED_COMP_OBJECTS = $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SHARED_COMPS)))) OBJECTS += $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SOURCES)))) CPPFLAGS += $(addprefix -I,$(INCDIRS)) @@ -197,18 +201,27 @@ sym: $(TARGET).sym # Display compiler version information # -$(OBJECTS): stm32f303/src/hal_tbl.c - $(OBJDIR)/shared/commands.o: stm32f303/inc/commandslist.h stm32f303/inc/commandslist.h: tools/create_cmd.py $(SOURCES) @echo Generating commands list @$(PYTHON) tools/create_cmd.py stm32f303/inc/commandslist.h $(SOURCES) -stm32f303/src/hal_tbl.c &: tools/create_hal_tbl.py $(COMPS) +stm32f303/src/hal_tbl.c: tools/create_hal_tbl.py $(COMPS) @echo Generating HAL table - @$(PYTHON) tools/create_hal_tbl.py stm32f303 $(COMPS) - @$(PYTHON) tools/inc_comps.py . $(COMPS) + @$(PYTHON) tools/create_hal_tbl.py stm32f303/src/hal_tbl.c $(COMPS) + +$(SRC_COMP_OBJECTS): $(OBJDIR)/stm32f303/src/comps/%.o: stm32f303/inc/comps/%_comp.h + +$(SHARED_COMP_OBJECTS): $(OBJDIR)/shared/comps/%.o: stm32f303/inc/shared_comps/%_comp.h + +stm32f303/inc/comps/%_comp.h: stm32f303/src/comps/%.c + @echo Generating H: $< + @$(PYTHON) tools/create_comp_h.py $@ $< + +stm32f303/inc/shared_comps/%_comp.h: shared/comps/%.c + @echo Generating H: $< + @$(PYTHON) tools/create_comp_h.py $@ $< tbl: stm32f303/src/hal_tbl.c stm32f303/inc/commandslist.h @@ -219,6 +232,7 @@ clean: rm -rf $(OBJDIR) rm -rf stm32f303/inc/commandslist.h rm -rf stm32f303/inc/comps/* + rm -rf stm32f303/inc/shared_comps/* rm -rf stm32f303/src/hal_tbl.c rm -rf hv_firmware.o diff --git a/stm32f303/src/comps/hv.c b/stm32f303/src/comps/hv.c index 5f7ccb20..b8780c04 100644 --- a/stm32f303/src/comps/hv.c +++ b/stm32f303/src/comps/hv.c @@ -1,4 +1,4 @@ -#include "comps/hv_comp.h" +#include "hv_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/stm32f303/src/comps/io.c b/stm32f303/src/comps/io.c index cad2dd50..3a18e4d7 100644 --- a/stm32f303/src/comps/io.c +++ b/stm32f303/src/comps/io.c @@ -1,4 +1,4 @@ -#include "comps/io_comp.h" +#include "io_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/stm32f303/src/comps/ls.c b/stm32f303/src/comps/ls.c index 62887aac..2720df46 100644 --- a/stm32f303/src/comps/ls.c +++ b/stm32f303/src/comps/ls.c @@ -1,4 +1,4 @@ -#include "comps/ls_comp.h" +#include "ls_comp.h" #include "commands.h" #include "hal.h" #include "math.h" diff --git a/tools/create_hal_tbl.py b/tools/create_hal_tbl.py index 1be98460..920ff2c0 100755 --- a/tools/create_hal_tbl.py +++ b/tools/create_hal_tbl.py @@ -5,7 +5,7 @@ import file_updater comps = [] -code = file_updater.FileUpdater(sys.argv[1] + '/src/hal_tbl.c') +code = file_updater.FileUpdater(sys.argv[1]) for infile in sys.argv[2:]: with open(infile) as f: @@ -24,51 +24,6 @@ for infile in sys.argv[2:]: pins.append((pin.groups()[0], int(pin.groups()[1]))) comps.append((compname, pins, infile, comp_file)) -# header.write("#pragma once\n") -# header.write("//generated by " + sys.argv[0] + " DO NOT EDIT\n\n") - -# header.write("struct pin_ctx_t{\n") -# header.write(" hal_pin_inst_t rt_prio;\n") -# header.write(" hal_pin_inst_t frt_prio;\n") -# header.write(" hal_pin_inst_t rt_calc_time;\n") -# header.write(" hal_pin_inst_t rt_start_time;\n") -# header.write(" hal_pin_inst_t frt_calc_time;\n") -# header.write(" hal_pin_inst_t frt_start_time;\n") -# header.write(" hal_pin_inst_t nrt_calc_time;\n") -# header.write(" hal_pin_inst_t nrt_start_time;\n") - -# header.write("};\n\n") - -for comp_name, pins, file_name, comp_file in comps: - header = file_updater.FileUpdater(sys.argv[1] + '/inc/comps/' + comp_file + '_comp.h') - header.write("#pragma once\n") - header.write("//generated by " + sys.argv[0] + " DO NOT EDIT\n\n") - header.write("#include \"hal.h\"\n") - header.write("struct " + comp_name + "_pin_ctx_t{ // found in " + file_name + "\n") - header.write(" hal_pin_inst_t rt_prio;\n") - header.write(" hal_pin_inst_t frt_prio;\n") - # header.write(" hal_pin_inst_t rt_calc_time;\n") - # header.write(" hal_pin_inst_t rt_start_time;\n") - # header.write(" hal_pin_inst_t frt_calc_time;\n") - # header.write(" hal_pin_inst_t frt_start_time;\n") - # header.write(" hal_pin_inst_t nrt_calc_time;\n") - # header.write(" hal_pin_inst_t nrt_start_time;\n") - - for (p, i) in pins: - if i > 1: - header.write(" hal_pin_inst_t " + p + "[" + str(i) + "]" + ";\n") - else: - header.write(" hal_pin_inst_t " + p + ";\n") - header.write("};\n") - header.close() - -# header.write("extern const hal_comp_t * comps[];\n") -# header.write("extern const pin_t pins[];\n") -# header.write("extern const uint32_t comp_count;\n") -# header.write("extern const uint32_t pin_count;\n\n") - - - code.write("#include \"hal.h\"\n\n") code.write("//generated by " + sys.argv[0] + " DO NOT EDIT\n\n") for comp_name, pins, file_name, comp_file in comps: diff --git a/tools/file_updater.py b/tools/file_updater.py index 0d22fcd9..c29e6540 100644 --- a/tools/file_updater.py +++ b/tools/file_updater.py @@ -2,6 +2,7 @@ import shutil import tempfile import filecmp +import os def copyIfDifferent(src, dst_path): dst = None @@ -20,6 +21,7 @@ def copyIfDifferent(src, dst_path): class FileUpdater: def __init__(self, path): + os.makedirs(os.path.dirname(path), exist_ok=True) self.filePath = path self.tempFile = tempfile.TemporaryFile(mode='r+')