Skip to content

Commit

Permalink
Merge pull request #1247 from bitcraze/krichardsson/refactoring
Browse files Browse the repository at this point in the history
Krichardsson/refactoring
  • Loading branch information
krichardsson authored Mar 16, 2023
2 parents ea3490b + 9cac44c commit 9371e5f
Show file tree
Hide file tree
Showing 41 changed files with 68 additions and 63 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ INCLUDES += -I$(srctree)/src/deck/interface -I$(srctree)/src/deck/drivers/interf
INCLUDES += -I$(srctree)/src/drivers/interface -I$(srctree)/src/drivers/bosch/interface
INCLUDES += -I$(srctree)/src/drivers/esp32/interface
INCLUDES += -I$(srctree)/src/hal/interface
INCLUDES += -I$(srctree)/src/modules/interface -I$(srctree)/src/modules/interface/kalman_core -I$(srctree)/src/modules/interface/lighthouse -I$(srctree)/src/modules/interface/cpx -I$(srctree)/src/modules/interface/p2pDTR
INCLUDES += -I$(srctree)/src/modules/interface -I$(srctree)/src/modules/interface/kalman_core -I$(srctree)/src/modules/interface/lighthouse
INCLUDES += -I$(srctree)/src/modules/interface/cpx -I$(srctree)/src/modules/interface/p2pDTR -I$(srctree)/src/modules/interface/controller -I$(srctree)/src/modules/interface/estimator
INCLUDES += -I$(srctree)/src/utils/interface -I$(srctree)/src/utils/interface/kve -I$(srctree)/src/utils/interface/lighthouse -I$(srctree)/src/utils/interface/tdoa
INCLUDES += -I$(LIB)/FatFS
INCLUDES += -I$(LIB)/CMSIS/STM32F4xx/Include
Expand Down Expand Up @@ -169,12 +170,12 @@ flash_verify:
#sends a usb message to the CF to place it in DFU mode, then updates firmware over usb
flash_dfu:
$(PYTHON) $(srctree)/tools/make/usb-bootloader.py
$(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000:leave -D $(PROG).bin
$(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000:leave -D $(PROG).bin

#uses the dfu utility to flash the firmware at 0x08004000, just after the bootloader
#call this target directly if CF cannont be flashed automatically through flash_dfu
flash_dfu_manual:
$(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000:leave -D $(PROG).bin
$(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000:leave -D $(PROG).bin

#STM utility targets
halt:
Expand Down Expand Up @@ -216,7 +217,7 @@ MOD_INC = src/modules/interface
MOD_SRC = src/modules/src

bindings_python build/cffirmware.py: bindings/setup.py $(MOD_SRC)/*.c
swig -python -I$(MOD_INC) -Isrc/hal/interface -Isrc/utils/interface -o build/cffirmware_wrap.c bindings/cffirmware.i
swig -python -I$(MOD_INC) -Isrc/hal/interface -Isrc/utils/interface -Isrc/modules/interface/controller -o build/cffirmware_wrap.c bindings/cffirmware.i
$(PYTHON) bindings/setup.py build_ext --inplace

test_python: build/cffirmware.py
Expand All @@ -227,4 +228,3 @@ python_wheel: build/cffirmware.py
endif

.PHONY: all clean build compile unit prep erase flash check_submodules trace openocd gdb halt reset flash_dfu flash_dfu_manual flash_verify cload size print_version clean_version bindings_python test_python python_wheel

13 changes: 7 additions & 6 deletions bindings/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

include = [
"src/modules/interface",
"src/modules/interface/controller",
"src/hal/interface",
"src/utils/interface/lighthouse",
"src/utils/interface",
Expand Down Expand Up @@ -33,14 +34,14 @@
"src/modules/src/pptraj_compressed.c",
"src/modules/src/planner.c",
"src/modules/src/collision_avoidance.c",
"src/modules/src/controller_pid.c",
"src/modules/src/position_controller_pid.c",
"src/modules/src/attitude_pid_controller.c",
"src/modules/src/pid.c",
"src/modules/src/controller/controller_pid.c",
"src/modules/src/controller/position_controller_pid.c",
"src/modules/src/controller/attitude_pid_controller.c",
"src/modules/src/controller/controller_mellinger.c",
"src/modules/src/controller/controller_brescianini.c",
"src/utils/src/pid.c",
"src/utils/src/filter.c",
"src/utils/src/num.c",
"src/modules/src/controller_mellinger.c",
"src/modules/src/controller_brescianini.c",
"src/modules/src/power_distribution_quadrotor.c",
# "src/modules/src/power_distribution_flapper.c",
]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 5 additions & 26 deletions src/modules/src/Kbuild
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
obj-y += app_channel.o
obj-$(CONFIG_APP_ENABLE) += app_handler.o
obj-y += bootloader.o
obj-y += attitude_pid_controller.o
obj-y += collision_avoidance.o
obj-y += collision_avoidance.o
obj-y += commander.o
obj-y += comm.o
obj-y += console.o
obj-y += controller_indi.o
obj-y += controller_mellinger.o
obj-y += controller.o
obj-y += controller_pid.o
obj-y += controller_brescianini.o
obj-y += crtp_commander_generic.o
obj-y += crtp_commander_high_level.o
obj-y += crtp_commander.o
Expand All @@ -20,10 +14,6 @@ obj-y += crtp_localization_service.o
obj-y += crtp.o
obj-y += crtpservice.o
obj-y += esp_deck_flasher.o
obj-y += estimator_complementary.o
obj-$(CONFIG_ESTIMATOR_KALMAN_ENABLE) += estimator_kalman.o
obj-$(CONFIG_ESTIMATOR_UKF_ENABLE) += estimator_ukf.o
obj-y += estimator.o
obj-y += eventtrigger.o
obj-y += extrx.o
obj-y += health.o
Expand All @@ -36,12 +26,8 @@ obj-y += msp.o
obj-y += param_logic.o
obj-y += param_task.o
obj-y += peer_localization.o
obj-y += pid.o
obj-y += planner.o
obj-y += platformservice.o
obj-y += position_controller_indi.o
obj-y += position_controller_pid.o
obj-y += position_estimator_altitude.o
obj-$(CONFIG_POWER_DISTRIBUTION_QUADROTOR) += power_distribution_quadrotor.o
obj-$(CONFIG_POWER_DISTRIBUTION_FLAPPER) += power_distribution_flapper.o
obj-y += pptraj_compressed.o
Expand All @@ -60,18 +46,11 @@ obj-y += system.o
obj-$(CONFIG_DECK_LOCO) += tdoaEngineInstance.o
obj-y += vcp_esc_passthrough.o
obj-y += worker.o
obj-$(CONFIG_ENABLE_CPX) += cpx/cpx_external_router.o
obj-$(CONFIG_ENABLE_CPX) += cpx/cpx_internal_router.o
obj-$(CONFIG_ENABLE_CPX_ON_UART2) += cpx/cpx_uart_transport.o
obj-$(CONFIG_ENABLE_CPX) += cpx/cpxlink.o
obj-$(CONFIG_ENABLE_CPX) += cpx/cpx.o

obj-y += p2pDTR/DTR_handlers.o
obj-y += p2pDTR/DTR_p2p_interface.o
obj-y += p2pDTR/queueing.o
obj-y += p2pDTR/token_ring.o
# Kalman core
# Sub folders
obj-$(CONFIG_ESTIMATOR_KALMAN_ENABLE) += kalman_core/

# Lighthouse
obj-y += lighthouse/
obj-y += controller/
obj-y += estimator/
obj-y += cpx/
obj-y += p2pDTR/
8 changes: 8 additions & 0 deletions src/modules/src/controller/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
obj-y += attitude_pid_controller.o
obj-y += controller_indi.o
obj-y += controller_mellinger.o
obj-y += controller.o
obj-y += controller_pid.o
obj-y += controller_brescianini.o
obj-y += position_controller_indi.o
obj-y += position_controller_pid.o
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/modules/src/cpx/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
obj-$(CONFIG_ENABLE_CPX) += cpx_external_router.o
obj-$(CONFIG_ENABLE_CPX) += cpx_internal_router.o
obj-$(CONFIG_ENABLE_CPX_ON_UART2) += cpx_uart_transport.o
obj-$(CONFIG_ENABLE_CPX) += cpxlink.o
obj-$(CONFIG_ENABLE_CPX) += cpx.o
5 changes: 5 additions & 0 deletions src/modules/src/estimator/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
obj-y += estimator_complementary.o
obj-$(CONFIG_ESTIMATOR_KALMAN_ENABLE) += estimator_kalman.o
obj-$(CONFIG_ESTIMATOR_UKF_ENABLE) += estimator_ukf.o
obj-y += estimator.o
obj-y += position_estimator_altitude.o
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/modules/src/p2pDTR/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
obj-y += DTR_handlers.o
obj-y += DTR_p2p_interface.o
obj-y += queueing.o
obj-y += token_ring.o
File renamed without changes.
42 changes: 16 additions & 26 deletions src/utils/src/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,28 @@ obj-y += crc32.o
obj-y += debug.o
obj-y += eprintf.o
obj-y += buf2buf.o
### Implementations for abort(), malloc() and free(), needed to interact with apps written in C++
obj-y += abort.o
obj-y += malloc.o

### Add rules for handling generated version.c

obj-y += version.o
version-objs := version_gen.o

src/utils/src/version_gen.c: src/utils/src/version.vtpl FORCE
$(PYTHON) $(srctree)/tools/make/versionTemplate.py --crazyflie-base $(srctree) $< $@

###

obj-y += filter.o
obj-y += FreeRTOS-openocd.o
obj-y += kve/kve.o
obj-y += kve/kve_storage.o

# Lighthouse
obj-$(CONFIG_DECK_LIGHTHOUSE) += lighthouse/lighthouse_calibration.o
obj-$(CONFIG_DECK_LIGHTHOUSE) += lighthouse/lighthouse_geometry.o
obj-$(CONFIG_DECK_LIGHTHOUSE) += lighthouse/ootx_decoder.o
obj-$(CONFIG_DECK_LIGHTHOUSE) += lighthouse/pulse_processor.o
obj-$(CONFIG_DECK_LIGHTHOUSE) += lighthouse/pulse_processor_v1.o
obj-$(CONFIG_DECK_LIGHTHOUSE) += lighthouse/pulse_processor_v2.o
obj-y += num.o
obj-y += rateSupervisor.o
obj-y += sleepus.o
obj-y += statsCnt.o

# TDoA
obj-$(CONFIG_DECK_LOCO) += tdoa/tdoaEngine.o
obj-$(CONFIG_DECK_LOCO) += tdoa/tdoaStats.o
obj-$(CONFIG_DECK_LOCO) += tdoa/tdoaStorage.o
### Sub directories
obj-y += kve/
obj-y += lighthouse/
obj-y += tdoa/


### Implementations for abort(), malloc() and free(), needed to interact with apps written in C++
obj-y += abort.o
obj-y += malloc.o
obj-y += pid.o

### Rules for handling generated version.c
obj-y += version.o
version-objs := version_gen.o
src/utils/src/version_gen.c: src/utils/src/version.vtpl FORCE
$(PYTHON) $(srctree)/tools/make/versionTemplate.py --crazyflie-base $(srctree) $< $@
2 changes: 2 additions & 0 deletions src/utils/src/kve/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obj-y += kve.o
obj-y += kve_storage.o
6 changes: 6 additions & 0 deletions src/utils/src/lighthouse/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
obj-$(CONFIG_DECK_LIGHTHOUSE) += lighthouse_calibration.o
obj-$(CONFIG_DECK_LIGHTHOUSE) += lighthouse_geometry.o
obj-$(CONFIG_DECK_LIGHTHOUSE) += ootx_decoder.o
obj-$(CONFIG_DECK_LIGHTHOUSE) += pulse_processor.o
obj-$(CONFIG_DECK_LIGHTHOUSE) += pulse_processor_v1.o
obj-$(CONFIG_DECK_LIGHTHOUSE) += pulse_processor_v2.o
File renamed without changes.
3 changes: 3 additions & 0 deletions src/utils/src/tdoa/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
obj-$(CONFIG_DECK_LOCO) += tdoaEngine.o
obj-$(CONFIG_DECK_LOCO) += tdoaStats.o
obj-$(CONFIG_DECK_LOCO) += tdoaStorage.o
2 changes: 2 additions & 0 deletions tools/test/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ compiler:
- 'src/modules/interface/'
- 'src/modules/interface/kalman_core/'
- 'src/modules/interface/lighthouse/'
- 'src/modules/interface/estimator/'
- 'src/modules/interface/controller/'
- 'src/modules/src/'
- 'src/modules/src/kalman_core/'
- 'src/modules/src/lighthouse/'
Expand Down

0 comments on commit 9371e5f

Please sign in to comment.