Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianmiriuta committed Jul 15, 2019
1 parent f66103a commit 5ccb154
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
26 changes: 13 additions & 13 deletions src/main/drivers/motor.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,31 +288,31 @@ void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp) {
}

void motorStartupTune() {
TIM1->CCR1 = 5;
TIM1->CCR2 = 5;
TIM1->CCR3 = 5;
motorPwmTimerHandle.Instance->CCR1 = 5;
motorPwmTimerHandle.Instance->CCR2 = 5;
motorPwmTimerHandle.Instance->CCR3 = 5;

motorCommutationStep(motorStep);
TIM1->PSC = 100;
motorPwmTimerHandle.Instance->PSC = 100;
HAL_Delay(100);
TIM1->PSC = 75;
motorPwmTimerHandle.Instance->PSC = 75;
HAL_Delay(100);
TIM1->PSC = 50;
motorPwmTimerHandle.Instance->PSC = 50;
HAL_Delay(100);

TIM1->PSC = 0;
motorPwmTimerHandle.Instance->PSC = 0;
}

void motorInputTune(uint8_t motorStepDebug) {
TIM1->CCR1 = 5;
TIM1->CCR2 = 5;
TIM1->CCR3 = 5;
motorPwmTimerHandle.Instance->CCR1 = 5;
motorPwmTimerHandle.Instance->CCR2 = 5;
motorPwmTimerHandle.Instance->CCR3 = 5;

motorCommutationStep(motorStepDebug);
TIM1->PSC = 75;
motorPwmTimerHandle.Instance->PSC = 75;
HAL_Delay(100);
TIM1->PSC = 50;
motorPwmTimerHandle.Instance->PSC = 50;
HAL_Delay(100);

TIM1->PSC = 0;
motorPwmTimerHandle.Instance->PSC = 0;
}
12 changes: 6 additions & 6 deletions src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ int main(void) {
break;
}

TIM1->CCR1 = motorDutyCycle;
TIM1->CCR2 = motorDutyCycle;
TIM1->CCR3 = motorDutyCycle;
motorPwmTimerHandle.Instance->CCR1 = motorDutyCycle;
motorPwmTimerHandle.Instance->CCR2 = motorDutyCycle;
motorPwmTimerHandle.Instance->CCR3 = motorDutyCycle;
}

if (inputProtocol == AUTODETECT) {
Expand Down Expand Up @@ -154,9 +154,9 @@ int main(void) {

// input
motorDutyCycle = constrain(outputPwm, OUTPUT_PWM_MIN, OUTPUT_PWM_MAX);
TIM1->CCR1 = motorDutyCycle;
TIM1->CCR2 = motorDutyCycle;
TIM1->CCR3 = motorDutyCycle;
motorPwmTimerHandle.Instance->CCR1 = motorDutyCycle;
motorPwmTimerHandle.Instance->CCR2 = motorDutyCycle;
motorPwmTimerHandle.Instance->CCR3 = motorDutyCycle;

// motor BEMF filter
if ((motorCommutationInterval < 200) && (motorDutyCycle > 500)) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/target/stm32f0xx_hal_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) {
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) {
GPIO_InitTypeDef GPIO_InitStruct;

if(htim_base->Instance == TIM1) {
if(htim_base->Instance == motorPwmTimerHandle.Instance) {
__HAL_RCC_TIM1_CLK_ENABLE();

//HAL_NVIC_SetPriority(TIM1_CC_IRQn, 0, 0);
Expand Down Expand Up @@ -115,7 +115,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) {
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) {
GPIO_InitTypeDef GPIO_InitStruct;

if(htim->Instance == TIM1) {
if(htim->Instance == motorPwmTimerHandle.Instance) {
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
Expand All @@ -138,7 +138,7 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) {

void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) {

if(htim_base->Instance == TIM1) {
if(htim_base->Instance == motorPwmTimerHandle.Instance) {
__HAL_RCC_TIM1_CLK_DISABLE();

HAL_NVIC_DisableIRQ(TIM1_CC_IRQn);
Expand Down

0 comments on commit 5ccb154

Please sign in to comment.