36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <stdint.h>
|
|
|
|
#include "motor_controller.h"
|
|
|
|
void BLDC_Init(Cont_Mot_Interface_TypeDef Interface) {
|
|
HAL_TIM_PWM_Start(Interface.Driver_PWM_TIM, Interface.U_Phase_TIM_Channel);
|
|
HAL_TIMEx_PWMN_Start(Interface.Driver_PWM_TIM, Interface.U_Phase_TIM_Channel);
|
|
HAL_TIM_PWM_Start(Interface.Driver_PWM_TIM, Interface.V_Phase_TIM_Channel);
|
|
HAL_TIMEx_PWMN_Start(Interface.Driver_PWM_TIM, Interface.V_Phase_TIM_Channel);
|
|
HAL_TIM_PWM_Start(Interface.Driver_PWM_TIM, Interface.W_Phase_TIM_Channel);
|
|
HAL_TIMEx_PWMN_Start(Interface.Driver_PWM_TIM, Interface.W_Phase_TIM_Channel);
|
|
}
|
|
|
|
void BLDC_Loop() {
|
|
static uint32_t int_count;
|
|
|
|
int_count++;
|
|
static uint32_t seconds;
|
|
|
|
if (int_count/1000u > seconds) {
|
|
seconds = int_count/1000u;
|
|
|
|
uint8_t txMsg1[20] = "";
|
|
snprintf(txMsg1, sizeof(txMsg1), "IRQ: %8lu\n\0", int_count);
|
|
//HAL_UART_Transmit(&huart1, txMsg1, strlen(txMsg1), 100);
|
|
//HAL_UART_Transmit_DMA(&huart1, txMsg1, strlen(txMsg1));
|
|
|
|
uint8_t txMsg2[20] = "";
|
|
//snprintf(txMsg2, sizeof(txMsg2), "CNT: %8lu\n\0", htim->Instance->CNT);
|
|
//HAL_UART_Transmit(&huart1, txMsg2, strlen(txMsg2), 100);
|
|
//HAL_UART_Transmit_DMA(&huart1, txMsg2, strlen(txMsg2));
|
|
|
|
}
|
|
|
|
} |