diff --git a/.travis.yml b/.travis.yml index 531bce18..2fdc962e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,17 @@ # adapted from https://github.com/andysworkshop/stm32plus/blob/master/.travis.yml +branches: + only: + - master + - devel + language: c sudo: false -addons: - apt: - packages: - libc6-i386 +addons: + apt: + packages: + libc6-i386 cache: directories: diff --git a/Firmware/Board/v3.3/Inc/main.h b/Firmware/Board/v3.3/Inc/main.h index c6276ad8..9bdea772 100644 --- a/Firmware/Board/v3.3/Inc/main.h +++ b/Firmware/Board/v3.3/Inc/main.h @@ -65,6 +65,8 @@ #define TIM_APB1_CLOCK_HZ 84000000 #define TIM_APB1_PERIOD_CLOCKS 4096 #define TIM_APB1_DEADTIME_CLOCKS 40 +#define TIM_TIME_BASE TIM14 + #define M0_nCS_Pin GPIO_PIN_13 #define M0_nCS_GPIO_Port GPIOC diff --git a/Firmware/CHANGELOG.md b/Firmware/CHANGELOG.md index 9d3e620e..304a193b 100644 --- a/Firmware/CHANGELOG.md +++ b/Firmware/CHANGELOG.md @@ -1,17 +1,22 @@ -## UNRELEASED -Please add a note of your changes below this heading if you make a PR +# Unreleased Features +Please add a note of your changes below this heading if you make a Pull Request. + +* **Storing of configuration parameters to Non Volatile Memory** + +# Releases + +## [0.3.5] - 2018-03-04 ### Added -* **Storing of configuration parameters to Non Volatile Memory** * Reporting error if your encoder CPR is incorrect +* Ability to start anticogging calibration over USB protocol * Reporting of DRV status/control registers and fault codes * DRV status read script * Microsecond delay function -* Ability to start anticogging calibration over USB protocol * Travis-CI ### Changed -* Build system is now tup instead of make +* Build system is now tup instead of make. Please check the [Readme](README.md#installing-prerequisites) for installation instructions. ## [0.3.4] - 2018-02-13 diff --git a/Firmware/MotorControl/commands.cpp b/Firmware/MotorControl/commands.cpp index 7ef7e995..b70d977b 100644 --- a/Firmware/MotorControl/commands.cpp +++ b/Firmware/MotorControl/commands.cpp @@ -305,6 +305,19 @@ const Endpoint endpoints[] = { Endpoint::make_function("set_current_setpoint", &motors_1_set_current_setpoint_func), Endpoint::make_property("current_setpoint", &motors[1].set_current_setpoint_args.current_setpoint), Endpoint::close_tree(), + Endpoint::make_object("timing_log"), + Endpoint::make_property("TIMING_LOG_GENERAL", &motors[1].timing_log[TIMING_LOG_GENERAL]), + Endpoint::make_property("TIMING_LOG_ADC_CB_M0_I", &motors[1].timing_log[TIMING_LOG_ADC_CB_M0_I]), + Endpoint::make_property("TIMING_LOG_ADC_CB_M0_DC", &motors[1].timing_log[TIMING_LOG_ADC_CB_M0_DC]), + Endpoint::make_property("TIMING_LOG_ADC_CB_M1_I", &motors[1].timing_log[TIMING_LOG_ADC_CB_M1_I]), + Endpoint::make_property("TIMING_LOG_ADC_CB_M1_DC", &motors[1].timing_log[TIMING_LOG_ADC_CB_M1_DC]), + Endpoint::make_property("TIMING_LOG_MEAS_R", &motors[1].timing_log[TIMING_LOG_MEAS_R]), + Endpoint::make_property("TIMING_LOG_MEAS_L", &motors[1].timing_log[TIMING_LOG_MEAS_L]), + Endpoint::make_property("TIMING_LOG_ENC_CALIB", &motors[1].timing_log[TIMING_LOG_ENC_CALIB]), + Endpoint::make_property("TIMING_LOG_IDX_SEARCH", &motors[1].timing_log[TIMING_LOG_IDX_SEARCH]), + Endpoint::make_property("TIMING_LOG_FOC_VOLTAGE", &motors[1].timing_log[TIMING_LOG_FOC_VOLTAGE]), + Endpoint::make_property("TIMING_LOG_FOC_CURRENT", &motors[1].timing_log[TIMING_LOG_FOC_CURRENT]), + Endpoint::close_tree(), Endpoint::close_tree(), // motor1 Endpoint::make_function("save_configuration", &save_configuration), // no arguments @@ -315,19 +328,6 @@ const Endpoint endpoints[] = { Endpoint::make_function("reboot", &NVIC_SystemReset), // no arguments Endpoint::close_tree(), - Endpoint::make_object("timing_log"), - Endpoint::make_property("TIMING_LOG_GENERAL", &motors[1].timing_log[TIMING_LOG_GENERAL]), - Endpoint::make_property("TIMING_LOG_ADC_CB_M0_I", &motors[1].timing_log[TIMING_LOG_ADC_CB_M0_I]), - Endpoint::make_property("TIMING_LOG_ADC_CB_M0_DC", &motors[1].timing_log[TIMING_LOG_ADC_CB_M0_DC]), - Endpoint::make_property("TIMING_LOG_ADC_CB_M1_I", &motors[1].timing_log[TIMING_LOG_ADC_CB_M1_I]), - Endpoint::make_property("TIMING_LOG_ADC_CB_M1_DC", &motors[1].timing_log[TIMING_LOG_ADC_CB_M1_DC]), - Endpoint::make_property("TIMING_LOG_MEAS_R", &motors[1].timing_log[TIMING_LOG_MEAS_R]), - Endpoint::make_property("TIMING_LOG_MEAS_L", &motors[1].timing_log[TIMING_LOG_MEAS_L]), - Endpoint::make_property("TIMING_LOG_ENC_CALIB", &motors[1].timing_log[TIMING_LOG_ENC_CALIB]), - Endpoint::make_property("TIMING_LOG_IDX_SEARCH", &motors[1].timing_log[TIMING_LOG_IDX_SEARCH]), - Endpoint::make_property("TIMING_LOG_FOC_VOLTAGE", &motors[1].timing_log[TIMING_LOG_FOC_VOLTAGE]), - Endpoint::make_property("TIMING_LOG_FOC_CURRENT", &motors[1].timing_log[TIMING_LOG_FOC_CURRENT]), - Endpoint::close_tree(), }; // clang-format on diff --git a/Firmware/MotorControl/utils.c b/Firmware/MotorControl/utils.c index 032a996a..a6a02a5a 100644 --- a/Firmware/MotorControl/utils.c +++ b/Firmware/MotorControl/utils.c @@ -187,13 +187,13 @@ uint32_t timeout_to_deadline(uint32_t timeout_ms) { // @brief: Returns number of microseconds since system startup uint32_t micros(void) { - uint32_t usTicks = HAL_RCC_GetSysClockFreq() / 1000000; register uint32_t ms, cycle_cnt; do { ms = HAL_GetTick(); - cycle_cnt = SysTick->VAL; - } while (ms != HAL_GetTick()); - return (ms * 1000) + (usTicks * 1000 - cycle_cnt) / usTicks; + cycle_cnt = TIM_TIME_BASE->CNT; + } while (ms != HAL_GetTick()); + + return (ms * 1000) + cycle_cnt; } // @brief: Busy wait delay for given amount of microseconds (us) @@ -203,4 +203,4 @@ void delay_us(uint32_t us) while (micros() - start < (uint32_t) us) { __ASM("nop"); } -} \ No newline at end of file +}