From efcee578464f6ff167b41ed09cdaed617aadbca3 Mon Sep 17 00:00:00 2001
From: Neluji <38362829+Neluji@users.noreply.github.com>
Date: Sun, 22 Nov 2020 18:14:16 +0100
Subject: [PATCH 1/4] =?UTF-8?q?R=C3=A9cepteur=20RF=20OK?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MDK-ARM/Project.uvoptx | 32 +++++++++++++++-------
MDK-ARM/Project.uvprojx | 14 ++++++++++
Services/MyRF.c | 38 ++++++++++++++++++++++++++
Services/MyRF.h | 18 +++++++++++++
Services/services.txt | 1 -
Src/main.c | 59 -----------------------------------------
6 files changed, 92 insertions(+), 70 deletions(-)
create mode 100644 Services/MyRF.c
create mode 100644 Services/MyRF.h
delete mode 100644 Services/services.txt
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);
}
}
From 27c8c1a005a1431f45ef8f5aa72abe5cea6cc6b1 Mon Sep 17 00:00:00 2001
From: Neluji <38362829+Neluji@users.noreply.github.com>
Date: Mon, 23 Nov 2020 22:12:28 +0100
Subject: [PATCH 2/4] Transmission : conf et foncts
---
MDK-ARM/Project.uvoptx | 34 ++++++++-----
MDK-ARM/Project.uvprojx | 10 ++++
MyDrivers/MyPWM.h | 4 +-
Services/MyRF.c | 105 +++++++++++++++++++++++++++++++++++++---
Services/MyRF.h | 14 +++++-
5 files changed, 147 insertions(+), 20 deletions(-)
diff --git a/MDK-ARM/Project.uvoptx b/MDK-ARM/Project.uvoptx
index 7329a62..1aede9a 100644
--- a/MDK-ARM/Project.uvoptx
+++ b/MDK-ARM/Project.uvoptx
@@ -460,7 +460,7 @@
2
2
1
- 1
+ 0
0
0
..\Services\MyRF.c
@@ -480,7 +480,7 @@
3
3
1
- 1
+ 0
0
0
..\MyDrivers\MyTimer.c
@@ -492,7 +492,7 @@
3
4
1
- 1
+ 0
0
0
..\MyDrivers\MyPWM.c
@@ -500,6 +500,18 @@
0
0
+
+ 3
+ 5
+ 1
+ 0
+ 0
+ 0
+ ..\MyDrivers\MyUSART.c
+ MyUSART.c
+ 0
+ 0
+
@@ -510,7 +522,7 @@
0
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
@@ -558,7 +570,7 @@
4
- 9
+ 10
1
0
0
@@ -578,7 +590,7 @@
0
5
- 10
+ 11
5
0
0
@@ -598,7 +610,7 @@
0
6
- 11
+ 12
1
0
0
@@ -618,7 +630,7 @@
0
7
- 12
+ 13
2
0
0
diff --git a/MDK-ARM/Project.uvprojx b/MDK-ARM/Project.uvprojx
index 0d68036..ba1fe3c 100644
--- a/MDK-ARM/Project.uvprojx
+++ b/MDK-ARM/Project.uvprojx
@@ -412,6 +412,11 @@
1
..\MyDrivers\MyPWM.c
+
+ MyUSART.c
+ 1
+ ..\MyDrivers\MyUSART.c
+
@@ -885,6 +890,11 @@
1
..\MyDrivers\MyPWM.c
+
+ MyUSART.c
+ 1
+ ..\MyDrivers\MyUSART.c
+
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
index 4e40930..92c474d 100644
--- a/Services/MyRF.c
+++ b/Services/MyRF.c
@@ -1,34 +1,58 @@
#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) {
- //Initialisation du GPIO
+ //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(GPIOB, &My_GPIO_Init_Struct);
+ LL_GPIO_Init(GPIOIn, &My_GPIO_Init_Struct);
//PB.7 en floating input
My_GPIO_Init_Struct.Pin = PinCH2;
- LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
+ 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);
+
+ //Configuration de l'USART
+ MyUSART_Conf(USARTOut, TransferDirTX);
+
+ //Configuration Timer (interruption à 3s, callback MyRF_Transmit_3s) et lancement
+ MyTimer_Conf(TimerRF,65633,3290);
+ MyTimer_IT_Conf(TimerRF,MyRF_Transmit_3s,3);
+ MyTimer_IT_Enable(TimerRF);
+ MyTimer_Start(TimerRF);
+
}
int MyRF_Input_Duty_Cycle(void) {
@@ -36,3 +60,72 @@ int MyRF_Input_Duty_Cycle(void) {
return (MyPWM_Duty_Cycle_Permilles(TimerCC, channelCC1, channelCC2) - 75) * 4;
}
+
+void MyRF_Transmit_3s(void) {
+
+ //Récupérer :
+ char bordage[3];
+ char heure[2];
+ char min[2];
+ char sec[2];
+ int allure_ref = 0;
+
+ char allure[7][30] = {"pas (ou vent debout).",
+ "au plus près.",
+ "au près.",
+ "au bon plein.",
+ "au travers.",
+ "au grand largue.",
+ "au vent arrière."
+ };
+ char data1[23] = "\" : le voilier navigue ";
+ char data2[15] = " === Bordage : ";
+
+ int i;
+
+ //Heure
+ MyUSART_Transmit_Data_8b(USARTOut, heure[0]);
+ MyUSART_Transmit_Data_8b(USARTOut, heure[1]);
+ MyUSART_Transmit_Data_8b(USARTOut, 'h');
+ //Minutes
+ MyUSART_Transmit_Data_8b(USARTOut, min[0]);
+ MyUSART_Transmit_Data_8b(USARTOut, min[1]);
+ MyUSART_Transmit_Data_8b(USARTOut, '\'');
+ //Secondes
+ MyUSART_Transmit_Data_8b(USARTOut, sec[0]);
+ MyUSART_Transmit_Data_8b(USARTOut, sec[1]);
+ //Texte 1 (allures)
+ for(i=0; i<23; i++) {
+ MyUSART_Transmit_Data_8b(USARTOut, data1[i]);
+ }
+ //Allure
+ for(i=0; i<30; i++) {
+ MyUSART_Transmit_Data_8b(USARTOut, allure[allure_ref][i]);
+ }
+ //Texte 2 (bordage)
+ for(i=0; i<15; i++) {
+ MyUSART_Transmit_Data_8b(USARTOut, data2[i]);
+ }
+ //Bordage
+ for(i=0; i<3; i++) {
+ MyUSART_Transmit_Data_8b(USARTOut, bordage[i]);
+ }
+ MyUSART_Transmit_Data_8b(USARTOut, '%');
+ //Newline (fin)
+ MyUSART_Transmit_Data_8b(USARTOut, '\n');
+
+}
+
+void MyRF_Transmit_Batterie_Faible(void) {
+ char data[24] = "/!\\ BATTERIE FAIBLE /!\\\n";
+ for(int i = 0; i<24; i++) {
+ MyUSART_Transmit_Data_8b(USARTOut, data[i]);
+ }
+}
+
+void MyRF_Transmit_Limite_Roulis(void) {
+ char data[30] = "/!\\ RISQUE DE CHAVIREMENT /!\\\n";
+ for(int i = 0; i<30; i++) {
+ MyUSART_Transmit_Data_8b(USARTOut, data[i]);
+ }
+}
diff --git a/Services/MyRF.h b/Services/MyRF.h
index 4670582..98b5cef 100644
--- a/Services/MyRF.h
+++ b/Services/MyRF.h
@@ -5,14 +5,26 @@
#define PinCH1 LL_GPIO_PIN_6
#define PinCH2 LL_GPIO_PIN_7
-#define GPIOPins GPIOB
+#define PinOut LL_GPIO_PIN_9
+#define PinTXEn LL_GPIO_PIN_11
+#define GPIOIn GPIOB
+#define GPIOOut GPIOA
#define TimerCC TIM4
#define channelCC1 LL_TIM_CHANNEL_CH1
#define channelCC2 LL_TIM_CHANNEL_CH2
+#define USARTOut USART1
+#define TransferDirTX LL_USART_DIRECTION_TX
+#define TimerRF TIM1
void MyRF_Conf(void);
int MyRF_Duty_Cycle_Moteur(void);
+void MyRF_Transmit_3s(void);
+
+void MyRF_Transmit_Batterie_Faible(void);
+
+void MyRF_Transmit_Limite_Roulis(void);
+
#endif
From 5723b954059d3dfa138844484a4bcba096bae38f Mon Sep 17 00:00:00 2001
From: Neluji <38362829+Neluji@users.noreply.github.com>
Date: Tue, 24 Nov 2020 08:15:55 +0100
Subject: [PATCH 3/4] ajout de seuils sur Duty_Cycle
---
MDK-ARM/Project.uvoptx | 15 +++++--------
Services/MyRF.c | 48 +++++++++++++++++++++++-------------------
Src/main.c | 3 +++
3 files changed, 34 insertions(+), 32 deletions(-)
diff --git a/MDK-ARM/Project.uvoptx b/MDK-ARM/Project.uvoptx
index 1aede9a..da146e5 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=533,85,954,512,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=150,13,744,764,0)(132=599,17,1193,768,0)(133=-1,-1,-1,-1,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=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)
0
@@ -362,7 +362,7 @@
1
0
- porta
+ 0x08001778
0
@@ -374,7 +374,7 @@
1
1
0
- 0
+ 1
0
0
1
@@ -411,13 +411,8 @@
0
- ((portb & 0x00000040) >> 6 & 0x40) >> 6
- 00008000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274622026203078303030303030343029203E3E2036000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F0D00000000000000000000000000000000000000440E0008
-
-
- 1
- ((portb & 0x00000080) >> 7 & 0x80) >> 7
- 00000000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274622026203078303030303030383029203E3E2037000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F0D00000000000000000000000000000000000000040E0008
+ ((porta & 0x00000200) >> 9 & 0x200) >> 9
+ 00008000000000000000000000000000E0FFEF400200000000000000000000000000000028706F7274612026203078303030303032303029203E3E2039000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000001000000000000000000F03F17000000000000000000000000000000000000003E160008
diff --git a/Services/MyRF.c b/Services/MyRF.c
index 92c474d..d037b74 100644
--- a/Services/MyRF.c
+++ b/Services/MyRF.c
@@ -48,7 +48,7 @@ void MyRF_Conf(void) {
MyUSART_Conf(USARTOut, TransferDirTX);
//Configuration Timer (interruption à 3s, callback MyRF_Transmit_3s) et lancement
- MyTimer_Conf(TimerRF,65633,3290);
+ MyTimer_Conf(TimerRF,65533,3295);
MyTimer_IT_Conf(TimerRF,MyRF_Transmit_3s,3);
MyTimer_IT_Enable(TimerRF);
MyTimer_Start(TimerRF);
@@ -56,21 +56,25 @@ void MyRF_Conf(void) {
}
int MyRF_Input_Duty_Cycle(void) {
-
- return (MyPWM_Duty_Cycle_Permilles(TimerCC, channelCC1, channelCC2) - 75) * 4;
-
+ int duty_cycle_RC = MyPWM_Duty_Cycle_Permilles(TimerCC, channelCC1, channelCC2);
+ if (74
Date: Tue, 24 Nov 2020 08:59:25 +0100
Subject: [PATCH 4/4] 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)