Skip to content

Commit 8102189

Browse files
committed
fix B-G431-ESC1 current sense driver
1 parent afa8e3d commit 8102189

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/current_sense/hardware_specific/stm32/b_g431/b_g431_mcu.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void* _configureADCLowSide(const void* driver_params, const int pinA,const int p
132132
Stm32CurrentSenseParams* params = new Stm32CurrentSenseParams {
133133
.pins = { pinA, pinB, pinC },
134134
.adc_voltage_conv = (_ADC_VOLTAGE) / (_ADC_RESOLUTION),
135-
.timer_handle = (HardwareTimer *)(HardwareTimer_Handle[get_timer_index(TIM1)]->__this)
135+
.timer_handle = ((STM32DriverParams*)driver_params)->timers_handle[0],
136136
};
137137

138138
return params;
@@ -153,21 +153,21 @@ void* _driverSyncLowSide(void* _driver_params, void* _cs_params){
153153
Stm32CurrentSenseParams* cs_params = (Stm32CurrentSenseParams*)_cs_params;
154154

155155
// stop all the timers for the driver
156-
_stopTimers(driver_params->timers, 6);
156+
stm32_pause(driver_params);
157157

158158
// if timer has repetition counter - it will downsample using it
159159
// and it does not need the software downsample
160-
if( IS_TIM_REPETITION_COUNTER_INSTANCE(cs_params->timer_handle->getHandle()->Instance) ){
160+
if( IS_TIM_REPETITION_COUNTER_INSTANCE(cs_params->timer_handle->Instance) ){
161161
// adjust the initial timer state such that the trigger for DMA transfer aligns with the pwm peaks instead of throughs.
162162
// only necessary for the timers that have repetition counters
163-
cs_params->timer_handle->getHandle()->Instance->CR1 |= TIM_CR1_DIR;
164-
cs_params->timer_handle->getHandle()->Instance->CNT = cs_params->timer_handle->getHandle()->Instance->ARR;
163+
cs_params->timer_handle->Instance->CR1 |= TIM_CR1_DIR;
164+
cs_params->timer_handle->Instance->CNT = cs_params->timer_handle->Instance->ARR;
165165
}
166166
// set the trigger output event
167-
LL_TIM_SetTriggerOutput(cs_params->timer_handle->getHandle()->Instance, LL_TIM_TRGO_UPDATE);
167+
LL_TIM_SetTriggerOutput(cs_params->timer_handle->Instance, LL_TIM_TRGO_UPDATE);
168168

169169
// restart all the timers of the driver
170-
_startTimers(driver_params->timers, 6);
170+
stm32_resume(driver_params);
171171

172172
// return the cs parameters
173173
// successfully initialized

0 commit comments

Comments
 (0)