added PWM_control

This commit is contained in:
2024-05-24 21:13:02 +03:00
parent 600d55f292
commit 7133516721
3 changed files with 66 additions and 2 deletions

13
Core/Inc/PWM_control.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef INC_PWM_CONTROL_H_
#define INC_PWM_CONTROL_H_
#include "stm32f3xx_hal.h"
#include "ADBMS_LL_Driver.h"
#include "main.h"
void PWM_control_init(TIM_HandleTypeDef powerground1, TIM_HandleTypeDef powerground2, TIM_HandleTypeDef battery_cooling);
void PWM_powerground_control(uint8_t percent);
void PWM_battery_cooling_control(uint8_t percent);
#endif /* INC_CHANNEL_CONTROL_H_ */

30
Core/Src/PWM_control.c Normal file
View File

@ -0,0 +1,30 @@
#include "PWM_control.h"
#include "stm32f3xx_hal_tim.h"
#include <stdint.h>
uint8_t powerground_status;
uint8_t battery_cooling_status;
TIM_HandleTypeDef powerground1, powerground2, battery_cooling;
void PWM_control_init(TIM_HandleTypeDef powerground1, TIM_HandleTypeDef powerground2, TIM_HandleTypeDef battery_cooling){
powerground_status = 0;
battery_cooling = 0;
HAL_TIM_PWM_Start(&powerground1, 1);
HAL_TIM_PWM_Start(&powerground2, 4);
HAL_TIM_PWM_Start(&battery_cooling, 3);
//__HAL_TIM_SET_COMPARE(&powerground1, 1, 0);
//__HAL_TIM_SET_COMPARE(&powerground2, 4, 0);
//__HAL_TIM_SET_COMPARE(&battery_cooling, 3, 0);
}
void PWM_powerground_control(uint8_t percent){
//uint8_t duty_cycle = (percent/100) * 65536;
//__HAL_TIM_SET_COMPARE(&powerground1, 1, 0);
}
void PWM_battery_cooling_control(uint8_t percent){
}