diff --git a/MDK-ARM/Project.uvoptx b/MDK-ARM/Project.uvoptx index aa749d9..481799b 100644 --- a/MDK-ARM/Project.uvoptx +++ b/MDK-ARM/Project.uvoptx @@ -305,7 +305,7 @@ - + ..\..\inifiles\Simu_Pulse.ini @@ -317,7 +317,7 @@ 0 DLGDARM - (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=504,37,1150,710,0)(110=60,88,280,548,0)(111=752,104,972,564,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=864,64,1285,491,0)(121=892,96,1313,523,0)(122=674,103,1095,530,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=709,11,1303,762,0)(131=736,17,1330,768,0)(132=599,17,1193,768,0)(133=295,17,889,768,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=504,37,1150,710,0)(110=60,88,280,548,0)(111=752,104,972,564,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=874,38,1295,465,0)(121=892,96,1313,523,0)(122=674,103,1095,530,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=517,8,1111,759,0)(131=150,13,744,764,0)(132=599,17,1193,768,0)(133=-1,-1,-1,-1,0)(160=674,53,1122,467,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) 0 @@ -350,24 +350,7 @@ -U-O142 -O2254 -S0 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) - - - 0 - 0 - 25 - 1 -
134219120
- 0 - 0 - 0 - 0 - 0 - 1 - F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Services\Moteur.c - - \\NUCLEO_F103RB\../Services/Moteur.c\25 -
-
+ 0 @@ -379,7 +362,7 @@ 1 0 - My_GPIO_Init_Struct + 0x08001778 0 @@ -391,7 +374,7 @@ 1 1 0 - 0 + 1 0 0 1 @@ -428,13 +411,8 @@ 0 - ((porta & 0x00000002) >> 1 & 0x2) >> 1 - 00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F0B00000000000000000000000000000000000000320F0008 - - - 1 - ((porta & 0x00000004) >> 2 & 0x4) >> 2 - 00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303429203E3E2032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F0B00000000000000000000000000000000000000320F0008 + ((porta & 0x00000800) >> 11 & 0x800) >> 11 + 00800000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274612026203078303030303038303029203E3E2031310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F170000000000000000000000000000000000000076150008 @@ -480,8 +458,8 @@ 0 0 0 - ..\Services\Moteur.c - Moteur.c + ..\Services\MyRF.c + MyRF.c 0 0 @@ -517,6 +495,18 @@ 0 0 + + 3 + 5 + 1 + 0 + 0 + 0 + ..\MyDrivers\MyUSART.c + MyUSART.c + 0 + 0 + @@ -527,7 +517,7 @@ 0 4 - 5 + 6 1 0 0 @@ -539,7 +529,7 @@ 4 - 6 + 7 1 0 0 @@ -551,7 +541,7 @@ 4 - 7 + 8 1 0 0 @@ -563,7 +553,7 @@ 4 - 8 + 9 1 0 0 @@ -575,7 +565,7 @@ 4 - 9 + 10 1 0 0 @@ -595,7 +585,7 @@ 0 5 - 10 + 11 5 0 0 @@ -615,7 +605,7 @@ 0 6 - 11 + 12 1 0 0 @@ -635,7 +625,7 @@ 0 7 - 12 + 13 2 0 0 diff --git a/MDK-ARM/Project.uvprojx b/MDK-ARM/Project.uvprojx index 59049c2..ba1fe3c 100644 --- a/MDK-ARM/Project.uvprojx +++ b/MDK-ARM/Project.uvprojx @@ -393,9 +393,9 @@ User Services - Moteur.c + MyRF.c 1 - ..\Services\Moteur.c + ..\Services\MyRF.c @@ -412,6 +412,11 @@ 1 ..\MyDrivers\MyPWM.c + + MyUSART.c + 1 + ..\MyDrivers\MyUSART.c + @@ -866,9 +871,9 @@ User Services - Moteur.c + MyRF.c 1 - ..\Services\Moteur.c + ..\Services\MyRF.c @@ -885,6 +890,11 @@ 1 ..\MyDrivers\MyPWM.c + + MyUSART.c + 1 + ..\MyDrivers\MyUSART.c + diff --git a/MyDrivers/MyPWM.c b/MyDrivers/MyPWM.c index a59d46a..1cffb8f 100644 --- a/MyDrivers/MyPWM.c +++ b/MyDrivers/MyPWM.c @@ -55,6 +55,7 @@ void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int else LL_TIM_OC_SetCompareCH4(Timer, CompareValue); } + int MyPWM_Duty_Cycle_Permilles(TIM_TypeDef * Timer, int channel1, int channel2) { if(channel1 == LL_TIM_CHANNEL_CH1 && channel2 == LL_TIM_CHANNEL_CH2) { return LL_TIM_IC_GetCaptureCH2(Timer) / LL_TIM_IC_GetCaptureCH1(Timer) * 1000; diff --git a/MyDrivers/MyPWM.h b/MyDrivers/MyPWM.h index 1905014..1cb3719 100644 --- a/MyDrivers/MyPWM.h +++ b/MyDrivers/MyPWM.h @@ -1,5 +1,5 @@ -#ifndef PWM_H -#define PWM_H +#ifndef MYPWM_H +#define MYPWM_H #include "stm32f103xb.h" diff --git a/Services/MyRF.c b/Services/MyRF.c new file mode 100644 index 0000000..c65cbaf --- /dev/null +++ b/Services/MyRF.c @@ -0,0 +1,158 @@ +#include "MyRF.h" +#include "MyTimer.h" +#include "MyPWM.h" +#include "MyUSART.h" + +#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges +#include "stm32f1xx_ll_tim.h" +#include "stm32f1xx_ll_gpio.h" +#include "stm32f1xx_ll_usart.h" + + +void MyRF_Conf(void) { + + //RX + //Activation horloge 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(GPIOIn, &My_GPIO_Init_Struct); + + //PB.7 en floating input + My_GPIO_Init_Struct.Pin = PinCH2; + LL_GPIO_Init(GPIOIn, &My_GPIO_Init_Struct); + + + //Configuration et lancment du Timer PWM Input + MyTimer_Conf(TimerCC,0xFFAD,0x15); + MyPWM_Conf_Input(TimerCC, channelCC1, channelCC2); + MyTimer_Start(TimerCC); + + //TX + //Activation horloge du GPIO + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA); + + LL_GPIO_StructInit(&My_GPIO_Init_Struct); + + //PA.9 en alternate output pp + My_GPIO_Init_Struct.Pin = PinOut; + My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE; + My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + LL_GPIO_Init(GPIOOut, &My_GPIO_Init_Struct); + + //PA.11 en output pp + My_GPIO_Init_Struct.Pin = PinTXEn; + My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT; + My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + LL_GPIO_Init(GPIOOut, &My_GPIO_Init_Struct); + + //Configuration de l'USART + MyUSART_Conf(USARTOut, TransferDirTX); + +} + +int MyRF_Input_Duty_Cycle(void) { + int duty_cycle_RC = MyPWM_Duty_Cycle_Permilles(TimerCC, channelCC1, channelCC2); + if (74PB PIN - Moteur_Conf(); + for(int i=0; i<0xCFFF; i++) { + } - Moteur_Speed(30); - Moteur_Sens(0); + MyRF_Transmit_3s(); /* Infinite loop */ - for (int i =0; i<0xFFFF; i++) + while (1) { } - - Moteur_Speed(60); - Moteur_Sens(1); - - while (1) - { - } }