2 Commits

Author SHA1 Message Date
cd69f0b894 Merge pull request #21 from bobbycar-graz/wno-volatile
Ignore -Wvolatile warnings from STM32 HAL
2023-04-14 16:58:08 +02:00
323db30bc1 Ignore -Wvolatile warnings from STM32 HAL 2023-04-13 04:18:49 +02:00
2 changed files with 8 additions and 12 deletions

View File

@ -11,7 +11,7 @@ SET(CMAKE_SYSTEM_NAME Generic)
set(COMMON_FLAGS "-mcpu=cortex-m3 -mthumb -Wall -fdata-sections -ffunction-sections")
set(CMAKE_ASM_FLAGS "${COMMON_FLAGS} -x assembler-with-cpp")
set(CMAKE_C_FLAGS "${COMMON_FLAGS}")
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS}")
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -Wno-volatile")
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)

View File

@ -530,11 +530,7 @@ void updateMotors()
OverrunFlag = true;
constexpr int32_t pwm_res = 64000000 / 2 / PWM_FREQ; // = 2000
constexpr int32_t foc_pwm_margin = 100; /* This margin allows to always have a window in the PWM signal for proper Phase currents measurement */
using bobbycar::protocol::ControlType;
const int32_t pwm_margin_l = (left.rtP.z_ctrlTypSel == uint8_t(ControlType::FieldOrientedControl)) ? foc_pwm_margin : 0;
const int32_t pwm_margin_r = (right.rtP.z_ctrlTypSel == uint8_t(ControlType::FieldOrientedControl)) ? foc_pwm_margin : 0;
constexpr int32_t pwm_margin = 100; /* This margin allows to always have a window in the PWM signal for proper Phase currents measurement */
/* Make sure to stop BOTH motors in case of an error */
@ -579,9 +575,9 @@ void updateMotors()
int wl = left.rtY.DC_phaC;
/* Apply commands */
LEFT_TIM->LEFT_TIM_U = (uint16_t)std::clamp(ul + pwm_res / 2, pwm_margin_l, pwm_res-pwm_margin_l);
LEFT_TIM->LEFT_TIM_V = (uint16_t)std::clamp(vl + pwm_res / 2, pwm_margin_l, pwm_res-pwm_margin_l);
LEFT_TIM->LEFT_TIM_W = (uint16_t)std::clamp(wl + pwm_res / 2, pwm_margin_l, pwm_res-pwm_margin_l);
LEFT_TIM->LEFT_TIM_U = (uint16_t)std::clamp(ul + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
LEFT_TIM->LEFT_TIM_V = (uint16_t)std::clamp(vl + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
LEFT_TIM->LEFT_TIM_W = (uint16_t)std::clamp(wl + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
// =================================================================
@ -616,9 +612,9 @@ void updateMotors()
int wr = right.rtY.DC_phaC;
/* Apply commands */
RIGHT_TIM->RIGHT_TIM_U = (uint16_t)std::clamp(ur + pwm_res / 2, pwm_margin_r, pwm_res-pwm_margin_r);
RIGHT_TIM->RIGHT_TIM_V = (uint16_t)std::clamp(vr + pwm_res / 2, pwm_margin_r, pwm_res-pwm_margin_r);
RIGHT_TIM->RIGHT_TIM_W = (uint16_t)std::clamp(wr + pwm_res / 2, pwm_margin_r, pwm_res-pwm_margin_r);
RIGHT_TIM->RIGHT_TIM_U = (uint16_t)std::clamp(ur + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
RIGHT_TIM->RIGHT_TIM_V = (uint16_t)std::clamp(vr + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
RIGHT_TIM->RIGHT_TIM_W = (uint16_t)std::clamp(wr + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
// =================================================================
/* Indicate task complete */