This commit is contained in:
2024-07-02 23:01:26 +03:00
parent 9e80b90fd4
commit dae660d8f2
20 changed files with 591 additions and 11288 deletions

View File

@ -1,18 +1,16 @@
#include "PWM_control.h"
uint8_t battery_cooling_status;
//uint32_t powerground1_CCR, powerground2_CCR, battery_cooling_CCR;
TIM_HandleTypeDef* powerground, *battery_cooling;
TIM_HandleTypeDef *powerground, *battery_cooling, *esc_cooling;
/*
Pulse width modulation mode allows for generating a signal with a frequency determined by
the value of the TIMx_ARR register and a duty cycle determined by the value of the TIMx_CCRx register.
*/
void PWM_control_init(TIM_HandleTypeDef* pg, TIM_HandleTypeDef* bat_cool){
void PWM_control_init(TIM_HandleTypeDef* pg, TIM_HandleTypeDef* bat_cool, TIM_HandleTypeDef* esc_cool){
powerground_status = 0;
battery_cooling_status = 0;
HAL_TIM_PWM_Start(pg, TIM_CHANNEL_1); //TIM15CH1
HAL_TIM_PWM_Start(pg, TIM_CHANNEL_2); //TIM15CH2
@ -20,6 +18,8 @@ void PWM_control_init(TIM_HandleTypeDef* pg, TIM_HandleTypeDef* bat_cool){
powerground = pg;
battery_cooling = bat_cool;
esc_cooling = esc_cool;
__HAL_TIM_SET_COMPARE(powerground, TIM_CHANNEL_1, 2000);
__HAL_TIM_SET_COMPARE(powerground, TIM_CHANNEL_2, 2000);
//__HAL_TIM_SET_COMPARE(battery_cooling, TIM_CHANNEL_3, 2000);
@ -38,4 +38,5 @@ void PWM_powerground_control(uint8_t percent){
//TIM15->CCR1 = (TIM15->ARR*POWERGROUND_MAX_DUTY_CYCLE-TIM15->ARR*POWERGROUND_MIN_DUTY_CYCLE) * (percent/100.0) + TIM15->ARR*POWERGROUND_MIN_DUTY_CYCLE;
}
void PWM_battery_cooling_control(uint8_t percent){}
void PWM_battery_cooling_control(uint8_t percent){}
void PWM_esc_cooling(uint8_t percent){}