diff --git a/Core/Inc/PWM_control.h b/Core/Inc/PWM_control.h new file mode 100644 index 0000000..590b0ef --- /dev/null +++ b/Core/Inc/PWM_control.h @@ -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_ */ diff --git a/Core/Src/PWM_control.c b/Core/Src/PWM_control.c new file mode 100644 index 0000000..74c8bc3 --- /dev/null +++ b/Core/Src/PWM_control.c @@ -0,0 +1,30 @@ +#include "PWM_control.h" +#include "stm32f3xx_hal_tim.h" +#include + +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){ + +} \ No newline at end of file diff --git a/Makefile b/Makefile index a020bde..4f8b9c9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ ########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [4.3.0-B58] date: [Fri May 24 17:06:04 GMT 2024] +# File automatically-generated by tool: [projectgenerator] version: [4.3.0-B58] date: [Fri May 24 17:29:49 GMT 2024] ########################################################################################################################## # ------------------------------------------------ @@ -40,7 +40,28 @@ Core/Src/main.c \ Core/Src/stm32f3xx_it.c \ Core/Src/stm32f3xx_hal_msp.c \ Core/Src/sysmem.c \ -Core/Src/syscalls.c +Core/Src/syscalls.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_can.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_rcc.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_rcc_ex.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_gpio.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_dma.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_cortex.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_pwr.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_pwr_ex.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_flash.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_flash_ex.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_i2c.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_i2c_ex.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_exti.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_spi.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_spi_ex.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_tim.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_tim_ex.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart.c \ +Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart_ex.c \ +Core/Src/system_stm32f3xx.c # ASM sources ASM_SOURCES = \