From d91e0bc8edf9fd81f905626aeb941cf0475764c7 Mon Sep 17 00:00:00 2001 From: Neluji <38362829+Neluji@users.noreply.github.com> Date: Tue, 24 Nov 2020 08:59:25 +0100 Subject: [PATCH] Ajout activation/desact. module RF (PA.11) --- MDK-ARM/Project.uvoptx | 6 +++--- MyDrivers/MyPWM.c | 1 + Services/MyRF.c | 35 +++++++++++++++++++++++++++++------ Services/MyRF.h | 1 - Src/main.c | 5 +++++ 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/MDK-ARM/Project.uvoptx b/MDK-ARM/Project.uvoptx index da146e5..481799b 100644 --- a/MDK-ARM/Project.uvoptx +++ b/MDK-ARM/Project.uvoptx @@ -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=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=521,17,1115,768,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) + (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 @@ -411,8 +411,8 @@ 0 - ((porta & 0x00000200) >> 9 & 0x200) >> 9 - 00008000000000000000000000000000E0FFEF400200000000000000000000000000000028706F7274612026203078303030303032303029203E3E2039000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000001000000000000000000F03F17000000000000000000000000000000000000003E160008 + ((porta & 0x00000800) >> 11 & 0x800) >> 11 + 00800000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274612026203078303030303038303029203E3E2031310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F170000000000000000000000000000000000000076150008 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/Services/MyRF.c b/Services/MyRF.c index d037b74..c65cbaf 100644 --- a/Services/MyRF.c +++ b/Services/MyRF.c @@ -43,16 +43,16 @@ void MyRF_Conf(void) { 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); - //Configuration Timer (interruption à 3s, callback MyRF_Transmit_3s) et lancement - MyTimer_Conf(TimerRF,65533,3295); - MyTimer_IT_Conf(TimerRF,MyRF_Transmit_3s,3); - MyTimer_IT_Enable(TimerRF); - MyTimer_Start(TimerRF); - } int MyRF_Input_Duty_Cycle(void) { @@ -87,6 +87,10 @@ void MyRF_Transmit_3s(void) { int i; + + //Activation de l'émetteur RF + LL_GPIO_SetOutputPin(GPIOOut ,PinTXEn); + //Heure MyUSART_Transmit_Data_8b(USARTOut, heure[0]); MyUSART_Transmit_Data_8b(USARTOut, heure[1]); @@ -118,18 +122,37 @@ void MyRF_Transmit_3s(void) { //Newline (fin) MyUSART_Transmit_Data_8b(USARTOut, '\n'); + //Désactivation de l'émetteur RF + LL_GPIO_ResetOutputPin(GPIOOut ,PinTXEn); + } void MyRF_Transmit_Batterie_Faible(void) { + + //Activation de l'émetteur RF + LL_GPIO_SetOutputPin(GPIOOut ,PinTXEn); + char data[24] = "/!\\ BATTERIE FAIBLE /!\\\n"; for(int i = 0; i<24; i++) { MyUSART_Transmit_Data_8b(USARTOut, data[i]); } + + //Désactivation de l'émetteur RF + LL_GPIO_ResetOutputPin(GPIOOut ,PinTXEn); + } void MyRF_Transmit_Limite_Roulis(void) { + + //Activation de l'émetteur RF + LL_GPIO_SetOutputPin(GPIOOut ,PinTXEn); + char data[30] = "/!\\ RISQUE DE CHAVIREMENT /!\\\n"; for(int i = 0; i<30; i++) { MyUSART_Transmit_Data_8b(USARTOut, data[i]); } + + //Désactivation de l'émetteur RF + LL_GPIO_ResetOutputPin(GPIOOut ,PinTXEn); + } diff --git a/Services/MyRF.h b/Services/MyRF.h index 98b5cef..e427a70 100644 --- a/Services/MyRF.h +++ b/Services/MyRF.h @@ -14,7 +14,6 @@ #define channelCC2 LL_TIM_CHANNEL_CH2 #define USARTOut USART1 #define TransferDirTX LL_USART_DIRECTION_TX -#define TimerRF TIM1 void MyRF_Conf(void); diff --git a/Src/main.c b/Src/main.c index 7e7006f..6861ae4 100644 --- a/Src/main.c +++ b/Src/main.c @@ -41,6 +41,11 @@ int main(void) SystemClock_Config(); MyRF_Conf(); + + for(int i=0; i<0xCFFF; i++) { + } + + MyRF_Transmit_3s(); /* Infinite loop */ while (1)