diff --git a/Makefile b/Makefile index 8954a9a3..ef7d621d 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,7 @@ TARGET = ODriveFirmware # debug build? DEBUG = 1 # optimization -# OPT = -O3 -ffast-math -flto -# OPT = -O3 -ffast-math -OPT = -O0 -ffast-math -u _printf_float -u _scanf_float +OPT = -Og -ffast-math ####################################### # pathes @@ -117,9 +115,9 @@ C_INCLUDES += -IDrivers/CMSIS/Include C_INCLUDES += -IInc C_INCLUDES += -IMotorControl # compile gcc flags -ASFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -CFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -CXXFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections +ASFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -u _printf_float -u _scanf_float +CFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -u _printf_float -u _scanf_float +CXXFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -u _printf_float -u _scanf_float ifeq ($(DEBUG), 1) CFLAGS += -g -gdwarf-2 CXXFLAGS += -g -gdwarf-2 diff --git a/MotorControl/axis.cpp b/MotorControl/axis.cpp index cda35325..27711567 100644 --- a/MotorControl/axis.cpp +++ b/MotorControl/axis.cpp @@ -17,13 +17,17 @@ void axis_thread_entry(void const* temp_motor_ptr) { while(&motors[ax_number] != motor) ++ax_number; - Axis axis(ax_number, motor); + static const AxisConfig default_config; + + Axis axis(default_config, ax_number, motor); axis.StateMachineLoop(); } } // extern "C" -Axis::Axis(uint8_t axis_number, Motor_t* legacy_motor_ref) +Axis::Axis(const AxisConfig& config, uint8_t axis_number, Motor_t* legacy_motor_ref) : axis_number_(axis_number), + enable_control_(config.enable_control_at_start), + do_calibration_(config.do_calibration_at_start), legacy_motor_ref_(legacy_motor_ref) {} void Axis::StateMachineLoop() { @@ -32,5 +36,9 @@ void Axis::StateMachineLoop() { exposed_bools[4*axis_number_ + 1] = &enable_control_; exposed_bools[4*axis_number_ + 2] = &do_calibration_; + // for (;;) { + + // } + motor_thread(legacy_motor_ref_); } \ No newline at end of file diff --git a/MotorControl/axis.hpp b/MotorControl/axis.hpp index 2431d383..5929acf8 100644 --- a/MotorControl/axis.hpp +++ b/MotorControl/axis.hpp @@ -10,6 +10,11 @@ extern "C" { //command handler //callback dispatch +// TODO: decide if we want to consolidate all default configs in one file for ease of use? +struct AxisConfig { + bool enable_control_at_start = true; + bool do_calibration_at_start = true; +}; class Axis { public: @@ -35,7 +40,7 @@ public: //step/dir handler // Object operation requires ptr to legacy object for now, TODO: get rid of this dep - Axis(uint8_t axis_number, Motor_t* legacy_motor_ref); + Axis(const AxisConfig& config, uint8_t axis_number, Motor_t* legacy_motor_ref); // Infinite loop that does calibration and enters main control loop as appropriate void StateMachineLoop();