43 lines
1.1 KiB
C
43 lines
1.1 KiB
C
#include "MyPWM.h"
|
|
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
|
|
#include "stm32f1xx_ll_tim.h"
|
|
|
|
//Seul le channel CH1 des timers sera utilisé
|
|
int channel = LL_TIM_CHANNEL_CH1;
|
|
|
|
void MyPWM_Conf_Output(TIM_TypeDef * Timer)
|
|
{
|
|
//Activation du channel (CH1) pour le timer considéré
|
|
LL_TIM_CC_EnableChannel(Timer, channel);
|
|
|
|
LL_TIM_OC_InitTypeDef My_LL_Tim_OC_Init_Struct;
|
|
|
|
//Configuration du output channel en PWM
|
|
LL_TIM_OC_StructInit(&My_LL_Tim_OC_Init_Struct);
|
|
My_LL_Tim_OC_Init_Struct.OCMode = LL_TIM_OCMODE_PWM1;
|
|
|
|
LL_TIM_OC_Init(Timer,channel,&My_LL_Tim_OC_Init_Struct);
|
|
}
|
|
|
|
|
|
|
|
void MyPWM_Conf_Input(TIM_TypeDef * Timer)
|
|
{
|
|
//Activation du channel (CH1) pour le timer considéré
|
|
LL_TIM_CC_EnableChannel(Timer, channel);
|
|
|
|
LL_TIM_IC_InitTypeDef My_LL_Tim_IC_Init_Struct;
|
|
|
|
LL_TIM_IC_StructInit(&My_LL_Tim_IC_Init_Struct);
|
|
//Compléter ici?!...
|
|
|
|
LL_TIM_IC_Init(Timer,channel,&My_LL_Tim_IC_Init_Struct);
|
|
}
|
|
|
|
|
|
void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage)
|
|
{
|
|
uint32_t CompareValue = 0xFFFF * Percentage/100;
|
|
LL_TIM_OC_SetCompareCH1(Timer, CompareValue);
|
|
}
|
|
|