start of pwm input
This commit is contained in:
parent
1da66cc347
commit
9a60eb93c5
3 changed files with 70 additions and 6 deletions
63
keil_project/Services/RFInput.c
Normal file
63
keil_project/Services/RFInput.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
#include "RFInput.h"
|
||||
#include "stm32f1xx_ll_gpio.h"
|
||||
#include "stm32f1xx_ll_bus.h"
|
||||
#include "stm32f1xx_ll_tim.h"
|
||||
|
||||
|
||||
// timer 4 channel 1 for pb6 channel 2 for pb7
|
||||
|
||||
void RF_INPUT_Init(void)
|
||||
{
|
||||
// GPIO setup
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
|
||||
LL_GPIO_InitTypeDef pb6_init_conf, pb7_init_conf;
|
||||
|
||||
pb6_init_conf.Mode = LL_GPIO_MODE_FLOATING;
|
||||
pb6_init_conf.Pin = LL_GPIO_PIN_6;
|
||||
pb6_init_conf.Pull = LL_GPIO_PULL_DOWN;
|
||||
LL_GPIO_Init(GPIOB, &pb6_init_conf);
|
||||
|
||||
pb7_init_conf.Mode = LL_GPIO_MODE_FLOATING;
|
||||
pb7_init_conf.Pin = LL_GPIO_PIN_7;
|
||||
pb7_init_conf.Pull = LL_GPIO_PULL_DOWN;
|
||||
LL_GPIO_Init(GPIOB, &pb7_init_conf);
|
||||
|
||||
// timer setup
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM4);
|
||||
LL_TIM_InitTypeDef tim4_init_struct;
|
||||
|
||||
tim4_init_struct.Autoreload= 1000; // ??
|
||||
tim4_init_struct.Prescaler=71;
|
||||
tim4_init_struct.ClockDivision=LL_TIM_CLOCKDIVISION_DIV1;
|
||||
tim4_init_struct.CounterMode=LL_TIM_COUNTERMODE_UP;
|
||||
tim4_init_struct.RepetitionCounter=0;
|
||||
|
||||
LL_TIM_Init(TIM4, &tim4_init_struct);
|
||||
|
||||
/*LL_TIM_IC_InitTypeDef tim4_ic_conf;
|
||||
tim4_ic_conf.ICPolarity= LL_TIM_IC_POLARITY_RISING;
|
||||
tim4_ic_conf.ICActiveInput = LL_TIM_ACTIVEINPUT_TRC;
|
||||
tim4_ic_conf.ICFilter = LL_TIM_IC_FILTER_FDIV1;
|
||||
tim4_ic_conf.ICPrescaler = LL_TIM_ICPSC_DIV1;
|
||||
|
||||
LL_TIM_IC_Init(TIM4, LL_TIM_CHANNEL_CH1, &tim4_ic_conf);
|
||||
*/
|
||||
LL_TIM_IC_InitTypeDef tim4_ic_conf_2;
|
||||
tim4_ic_conf_2.ICPolarity= LL_TIM_IC_POLARITY_RISING;
|
||||
tim4_ic_conf_2.ICActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
|
||||
tim4_ic_conf_2.ICFilter = LL_TIM_IC_FILTER_FDIV1;
|
||||
tim4_ic_conf_2.ICPrescaler = LL_TIM_ICPSC_DIV1;
|
||||
|
||||
LL_TIM_IC_Init(TIM4, LL_TIM_CHANNEL_CH1, &tim4_ic_conf_2);
|
||||
|
||||
}
|
||||
|
||||
int RF_INPUT_GetValue1(void)
|
||||
{
|
||||
return LL_TIM_ReadReg(TIM4, CCR1);
|
||||
}
|
||||
|
||||
int RF_INPUT_GetValue2(void)
|
||||
{
|
||||
return LL_TIM_ReadReg(TIM4, CCR2);
|
||||
}
|
5
keil_project/Services/RFInput.h
Normal file
5
keil_project/Services/RFInput.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
void RF_INPUT_Init(void);
|
||||
|
||||
int RF_INPUT_GetValue1(void);
|
||||
int RF_INPUT_GetValue2(void);
|
|
@ -21,6 +21,7 @@
|
|||
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
|
||||
|
||||
#include "Chrono.h"
|
||||
#include "RFInput.h"
|
||||
|
||||
void SystemClock_Config(void);
|
||||
|
||||
|
@ -50,17 +51,12 @@ int main(void)
|
|||
|
||||
/* Add your application code here */
|
||||
// Configuration chronomètre
|
||||
Chrono_Conf(TIM3);
|
||||
|
||||
// Lancement chronomètre
|
||||
Chrono_Start();
|
||||
|
||||
RF_INPUT_Init();
|
||||
|
||||
|
||||
/* Infinite loop */
|
||||
while (1)
|
||||
{
|
||||
Chrono_Background();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue