diff --git a/MDK-ARM/Project.uvoptx b/MDK-ARM/Project.uvoptx index f817973..7329a62 100644 --- a/MDK-ARM/Project.uvoptx +++ b/MDK-ARM/Project.uvoptx @@ -456,6 +456,18 @@ 0 0 0 + + 2 + 2 + 1 + 1 + 0 + 0 + ..\Services\MyRF.c + MyRF.c + 0 + 0 + @@ -466,7 +478,7 @@ 0 3 - 2 + 3 1 1 0 @@ -478,7 +490,7 @@ 3 - 3 + 4 1 1 0 @@ -498,7 +510,7 @@ 0 4 - 4 + 5 1 0 0 @@ -510,7 +522,7 @@ 4 - 5 + 6 1 0 0 @@ -522,7 +534,7 @@ 4 - 6 + 7 1 0 0 @@ -534,7 +546,7 @@ 4 - 7 + 8 1 0 0 @@ -546,7 +558,7 @@ 4 - 8 + 9 1 0 0 @@ -566,7 +578,7 @@ 0 5 - 9 + 10 5 0 0 @@ -586,7 +598,7 @@ 0 6 - 10 + 11 1 0 0 @@ -606,7 +618,7 @@ 0 7 - 11 + 12 2 0 0 diff --git a/MDK-ARM/Project.uvprojx b/MDK-ARM/Project.uvprojx index 8a6b949..0d68036 100644 --- a/MDK-ARM/Project.uvprojx +++ b/MDK-ARM/Project.uvprojx @@ -391,6 +391,13 @@ User Services + + + MyRF.c + 1 + ..\Services\MyRF.c + + MyDrivers @@ -857,6 +864,13 @@ User Services + + + MyRF.c + 1 + ..\Services\MyRF.c + + MyDrivers diff --git a/Services/MyRF.c b/Services/MyRF.c new file mode 100644 index 0000000..4e40930 --- /dev/null +++ b/Services/MyRF.c @@ -0,0 +1,38 @@ +#include "MyRF.h" +#include "MyTimer.h" +#include "MyPWM.h" + +#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges +#include "stm32f1xx_ll_tim.h" +#include "stm32f1xx_ll_gpio.h" + + +void MyRF_Conf(void) { + + //Initialisation du GPIO + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB); + + LL_GPIO_InitTypeDef My_GPIO_Init_Struct; + + LL_GPIO_StructInit(&My_GPIO_Init_Struct); + + //PB.6 en floating input + My_GPIO_Init_Struct.Pin = PinCH1; + LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct); + + //PB.7 en floating input + My_GPIO_Init_Struct.Pin = PinCH2; + LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct); + + MyTimer_Conf(TimerCC,0xFFAD,0x15); + + MyPWM_Conf_Input(TimerCC, channelCC1, channelCC2); + + MyTimer_Start(TimerCC); +} + +int MyRF_Input_Duty_Cycle(void) { + + return (MyPWM_Duty_Cycle_Permilles(TimerCC, channelCC1, channelCC2) - 75) * 4; + +} diff --git a/Services/MyRF.h b/Services/MyRF.h new file mode 100644 index 0000000..4670582 --- /dev/null +++ b/Services/MyRF.h @@ -0,0 +1,18 @@ +#ifndef MYRF_H +#define MYRF_H + +#include "stm32f103xb.h" + +#define PinCH1 LL_GPIO_PIN_6 +#define PinCH2 LL_GPIO_PIN_7 +#define GPIOPins GPIOB +#define TimerCC TIM4 +#define channelCC1 LL_TIM_CHANNEL_CH1 +#define channelCC2 LL_TIM_CHANNEL_CH2 + + +void MyRF_Conf(void); + +int MyRF_Duty_Cycle_Moteur(void); + +#endif diff --git a/Services/services.txt b/Services/services.txt deleted file mode 100644 index 1698ef7..0000000 --- a/Services/services.txt +++ /dev/null @@ -1 +0,0 @@ -Mettre les services ici \ No newline at end of file diff --git a/Src/main.c b/Src/main.c index 16ce13c..c295b38 100644 --- a/Src/main.c +++ b/Src/main.c @@ -38,69 +38,10 @@ int main(void) { /* Configure the system clock to 72 MHz */ SystemClock_Config(); - - - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB); - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA); - LL_GPIO_InitTypeDef My_GPIO_Init_Struct; - - /*===Test Output===*/ - -// TIM_TypeDef *Timer1 = TIM3; -// int Channel1 = LL_TIM_CHANNEL_CH2; -// TIM_TypeDef *Timer2 = TIM4; -// int Channel2 = LL_TIM_CHANNEL_CH4; -// -// MyTimer_Conf(Timer1,0xFFFE, 0x72); -// MyTimer_Conf(Timer2,0xFFFE, 0x72); -// -// MyPWM_Conf_Output(Timer1, Channel1); -// MyPWM_Conf_Output(Timer2, Channel2); -// -// MyPWM_Set_Impulse_Duration(Timer1, 25, Channel1); -// MyPWM_Set_Impulse_Duration(Timer2, 75, Channel2); -// -// My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_7; -// My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE; -// My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; -// My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_2MHz; -// My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN; -// LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct); -// -// My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_9; -// My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE; -// My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; -// My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_2MHz; -// My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN; -// LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct); -// -// MyTimer_Start(Timer1); -// MyTimer_Start(Timer2); - - /*===Test Input===*/ - - TIM_TypeDef *Timer = TIM4; - int channel1 = LL_TIM_CHANNEL_CH1; - int channel2 = LL_TIM_CHANNEL_CH2; - - My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_6; - My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_FLOATING; - My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN; - LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct); - - My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_7; - LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct); - - MyTimer_Conf(Timer,0xFFAD,0x15); - - MyPWM_Conf_Input(Timer, channel1, channel2); - - int duty_cycle = 0; /* Infinite loop */ while (1) { - duty_cycle = MyPWM_Duty_Cycle_Permilles(Timer, channel1, channel2); } }