Browse Source

Transmission : conf et foncts

Neluji 3 years ago
parent
commit
27c8c1a005
5 changed files with 147 additions and 20 deletions
  1. 23
    11
      MDK-ARM/Project.uvoptx
  2. 10
    0
      MDK-ARM/Project.uvprojx
  3. 2
    2
      MyDrivers/MyPWM.h
  4. 99
    6
      Services/MyRF.c
  5. 13
    1
      Services/MyRF.h

+ 23
- 11
MDK-ARM/Project.uvoptx View File

@@ -460,7 +460,7 @@
460 460
       <GroupNumber>2</GroupNumber>
461 461
       <FileNumber>2</FileNumber>
462 462
       <FileType>1</FileType>
463
-      <tvExp>1</tvExp>
463
+      <tvExp>0</tvExp>
464 464
       <tvExpOptDlg>0</tvExpOptDlg>
465 465
       <bDave2>0</bDave2>
466 466
       <PathWithFileName>..\Services\MyRF.c</PathWithFileName>
@@ -480,7 +480,7 @@
480 480
       <GroupNumber>3</GroupNumber>
481 481
       <FileNumber>3</FileNumber>
482 482
       <FileType>1</FileType>
483
-      <tvExp>1</tvExp>
483
+      <tvExp>0</tvExp>
484 484
       <tvExpOptDlg>0</tvExpOptDlg>
485 485
       <bDave2>0</bDave2>
486 486
       <PathWithFileName>..\MyDrivers\MyTimer.c</PathWithFileName>
@@ -492,7 +492,7 @@
492 492
       <GroupNumber>3</GroupNumber>
493 493
       <FileNumber>4</FileNumber>
494 494
       <FileType>1</FileType>
495
-      <tvExp>1</tvExp>
495
+      <tvExp>0</tvExp>
496 496
       <tvExpOptDlg>0</tvExpOptDlg>
497 497
       <bDave2>0</bDave2>
498 498
       <PathWithFileName>..\MyDrivers\MyPWM.c</PathWithFileName>
@@ -500,6 +500,18 @@
500 500
       <RteFlg>0</RteFlg>
501 501
       <bShared>0</bShared>
502 502
     </File>
503
+    <File>
504
+      <GroupNumber>3</GroupNumber>
505
+      <FileNumber>5</FileNumber>
506
+      <FileType>1</FileType>
507
+      <tvExp>0</tvExp>
508
+      <tvExpOptDlg>0</tvExpOptDlg>
509
+      <bDave2>0</bDave2>
510
+      <PathWithFileName>..\MyDrivers\MyUSART.c</PathWithFileName>
511
+      <FilenameWithoutPath>MyUSART.c</FilenameWithoutPath>
512
+      <RteFlg>0</RteFlg>
513
+      <bShared>0</bShared>
514
+    </File>
503 515
   </Group>
504 516
 
505 517
   <Group>
@@ -510,7 +522,7 @@
510 522
     <RteFlg>0</RteFlg>
511 523
     <File>
512 524
       <GroupNumber>4</GroupNumber>
513
-      <FileNumber>5</FileNumber>
525
+      <FileNumber>6</FileNumber>
514 526
       <FileType>1</FileType>
515 527
       <tvExp>0</tvExp>
516 528
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -522,7 +534,7 @@
522 534
     </File>
523 535
     <File>
524 536
       <GroupNumber>4</GroupNumber>
525
-      <FileNumber>6</FileNumber>
537
+      <FileNumber>7</FileNumber>
526 538
       <FileType>1</FileType>
527 539
       <tvExp>0</tvExp>
528 540
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -534,7 +546,7 @@
534 546
     </File>
535 547
     <File>
536 548
       <GroupNumber>4</GroupNumber>
537
-      <FileNumber>7</FileNumber>
549
+      <FileNumber>8</FileNumber>
538 550
       <FileType>1</FileType>
539 551
       <tvExp>0</tvExp>
540 552
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -546,7 +558,7 @@
546 558
     </File>
547 559
     <File>
548 560
       <GroupNumber>4</GroupNumber>
549
-      <FileNumber>8</FileNumber>
561
+      <FileNumber>9</FileNumber>
550 562
       <FileType>1</FileType>
551 563
       <tvExp>0</tvExp>
552 564
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -558,7 +570,7 @@
558 570
     </File>
559 571
     <File>
560 572
       <GroupNumber>4</GroupNumber>
561
-      <FileNumber>9</FileNumber>
573
+      <FileNumber>10</FileNumber>
562 574
       <FileType>1</FileType>
563 575
       <tvExp>0</tvExp>
564 576
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -578,7 +590,7 @@
578 590
     <RteFlg>0</RteFlg>
579 591
     <File>
580 592
       <GroupNumber>5</GroupNumber>
581
-      <FileNumber>10</FileNumber>
593
+      <FileNumber>11</FileNumber>
582 594
       <FileType>5</FileType>
583 595
       <tvExp>0</tvExp>
584 596
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -598,7 +610,7 @@
598 610
     <RteFlg>0</RteFlg>
599 611
     <File>
600 612
       <GroupNumber>6</GroupNumber>
601
-      <FileNumber>11</FileNumber>
613
+      <FileNumber>12</FileNumber>
602 614
       <FileType>1</FileType>
603 615
       <tvExp>0</tvExp>
604 616
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -618,7 +630,7 @@
618 630
     <RteFlg>0</RteFlg>
619 631
     <File>
620 632
       <GroupNumber>7</GroupNumber>
621
-      <FileNumber>12</FileNumber>
633
+      <FileNumber>13</FileNumber>
622 634
       <FileType>2</FileType>
623 635
       <tvExp>0</tvExp>
624 636
       <tvExpOptDlg>0</tvExpOptDlg>

+ 10
- 0
MDK-ARM/Project.uvprojx View File

@@ -412,6 +412,11 @@
412 412
               <FileType>1</FileType>
413 413
               <FilePath>..\MyDrivers\MyPWM.c</FilePath>
414 414
             </File>
415
+            <File>
416
+              <FileName>MyUSART.c</FileName>
417
+              <FileType>1</FileType>
418
+              <FilePath>..\MyDrivers\MyUSART.c</FilePath>
419
+            </File>
415 420
           </Files>
416 421
         </Group>
417 422
         <Group>
@@ -885,6 +890,11 @@
885 890
               <FileType>1</FileType>
886 891
               <FilePath>..\MyDrivers\MyPWM.c</FilePath>
887 892
             </File>
893
+            <File>
894
+              <FileName>MyUSART.c</FileName>
895
+              <FileType>1</FileType>
896
+              <FilePath>..\MyDrivers\MyUSART.c</FilePath>
897
+            </File>
888 898
           </Files>
889 899
         </Group>
890 900
         <Group>

+ 2
- 2
MyDrivers/MyPWM.h View File

@@ -1,5 +1,5 @@
1
-#ifndef PWM_H
2
-#define PWM_H
1
+#ifndef MYPWM_H
2
+#define MYPWM_H
3 3
 
4 4
 #include "stm32f103xb.h"
5 5
 

+ 99
- 6
Services/MyRF.c View File

@@ -1,34 +1,58 @@
1 1
 #include "MyRF.h"
2 2
 #include "MyTimer.h"
3 3
 #include "MyPWM.h"
4
+#include "MyUSART.h"
4 5
 
5 6
 #include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
6 7
 #include "stm32f1xx_ll_tim.h"
7 8
 #include "stm32f1xx_ll_gpio.h"
9
+#include "stm32f1xx_ll_usart.h"
8 10
 
9 11
 
10 12
 void MyRF_Conf(void) {
11 13
 	
12
-	//Initialisation du GPIO
14
+	//RX
15
+	//Activation horloge du GPIO
13 16
 	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
14 17
 	
15 18
 	LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
16
-	
17 19
 	LL_GPIO_StructInit(&My_GPIO_Init_Struct);
18 20
 	
19 21
 	//PB.6 en floating input
20 22
 	My_GPIO_Init_Struct.Pin = PinCH1;
21
-	LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
23
+	LL_GPIO_Init(GPIOIn, &My_GPIO_Init_Struct);
22 24
 	
23 25
 	//PB.7 en floating input
24 26
 	My_GPIO_Init_Struct.Pin = PinCH2;
25
-	LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
27
+	LL_GPIO_Init(GPIOIn, &My_GPIO_Init_Struct);
26 28
 	
27
-	MyTimer_Conf(TimerCC,0xFFAD,0x15);
28 29
 	
30
+	//Configuration et lancment du Timer PWM Input
31
+	MyTimer_Conf(TimerCC,0xFFAD,0x15);
29 32
 	MyPWM_Conf_Input(TimerCC, channelCC1, channelCC2);
30
-	
31 33
 	MyTimer_Start(TimerCC);
34
+	
35
+	//TX
36
+	//Activation horloge du GPIO
37
+	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
38
+	
39
+	LL_GPIO_StructInit(&My_GPIO_Init_Struct);
40
+	
41
+	//PA.9 en alternate output pp
42
+	My_GPIO_Init_Struct.Pin = PinOut;
43
+	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
44
+	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
45
+	LL_GPIO_Init(GPIOOut, &My_GPIO_Init_Struct);
46
+
47
+	//Configuration de l'USART
48
+	MyUSART_Conf(USARTOut, TransferDirTX);
49
+	
50
+	//Configuration Timer (interruption à 3s, callback MyRF_Transmit_3s) et lancement
51
+	MyTimer_Conf(TimerRF,65633,3290);
52
+	MyTimer_IT_Conf(TimerRF,MyRF_Transmit_3s,3);
53
+	MyTimer_IT_Enable(TimerRF);
54
+	MyTimer_Start(TimerRF);
55
+	
32 56
 }
33 57
 
34 58
 int MyRF_Input_Duty_Cycle(void) {
@@ -36,3 +60,72 @@ int MyRF_Input_Duty_Cycle(void) {
36 60
 	return (MyPWM_Duty_Cycle_Permilles(TimerCC, channelCC1, channelCC2) - 75) * 4;
37 61
 	
38 62
 }
63
+
64
+void MyRF_Transmit_3s(void) {
65
+	
66
+	//Récupérer :
67
+	char bordage[3];
68
+	char heure[2];
69
+	char min[2];
70
+	char sec[2];
71
+	int allure_ref = 0;
72
+	
73
+	char allure[7][30] = {"pas (ou vent debout).",
74
+		"au plus près.",
75
+		"au près.",
76
+		"au bon plein.",
77
+		"au travers.",
78
+		"au grand largue.",
79
+		"au vent arrière."
80
+	};
81
+	char data1[23] = "\" : le voilier navigue ";
82
+	char data2[15] = " === Bordage : ";
83
+	
84
+	int i;
85
+	
86
+	//Heure
87
+	MyUSART_Transmit_Data_8b(USARTOut, heure[0]);
88
+	MyUSART_Transmit_Data_8b(USARTOut, heure[1]);
89
+	MyUSART_Transmit_Data_8b(USARTOut, 'h');
90
+	//Minutes
91
+	MyUSART_Transmit_Data_8b(USARTOut, min[0]);
92
+	MyUSART_Transmit_Data_8b(USARTOut, min[1]);
93
+	MyUSART_Transmit_Data_8b(USARTOut, '\'');
94
+	//Secondes
95
+	MyUSART_Transmit_Data_8b(USARTOut, sec[0]);
96
+	MyUSART_Transmit_Data_8b(USARTOut, sec[1]);
97
+	//Texte 1 (allures)
98
+	for(i=0; i<23; i++) {
99
+		MyUSART_Transmit_Data_8b(USARTOut, data1[i]);
100
+	}
101
+	//Allure
102
+	for(i=0; i<30; i++) {
103
+		MyUSART_Transmit_Data_8b(USARTOut, allure[allure_ref][i]);
104
+	}
105
+	//Texte 2 (bordage)
106
+	for(i=0; i<15; i++) {
107
+		MyUSART_Transmit_Data_8b(USARTOut, data2[i]);
108
+	}
109
+	//Bordage
110
+	for(i=0; i<3; i++) {
111
+		MyUSART_Transmit_Data_8b(USARTOut, bordage[i]);
112
+	}
113
+	MyUSART_Transmit_Data_8b(USARTOut, '%');
114
+	//Newline (fin)
115
+	MyUSART_Transmit_Data_8b(USARTOut, '\n');
116
+	
117
+}
118
+
119
+void MyRF_Transmit_Batterie_Faible(void) {
120
+	char data[24] = "/!\\ BATTERIE FAIBLE /!\\\n";
121
+	for(int i = 0; i<24; i++) {
122
+		MyUSART_Transmit_Data_8b(USARTOut, data[i]);
123
+	}
124
+}
125
+
126
+void MyRF_Transmit_Limite_Roulis(void) {
127
+	char data[30] = "/!\\ RISQUE DE CHAVIREMENT /!\\\n";
128
+	for(int i = 0; i<30; i++) {
129
+		MyUSART_Transmit_Data_8b(USARTOut, data[i]);
130
+	}
131
+}

+ 13
- 1
Services/MyRF.h View File

@@ -5,14 +5,26 @@
5 5
 
6 6
 #define PinCH1 LL_GPIO_PIN_6
7 7
 #define PinCH2 LL_GPIO_PIN_7
8
-#define GPIOPins GPIOB
8
+#define PinOut LL_GPIO_PIN_9
9
+#define PinTXEn LL_GPIO_PIN_11
10
+#define GPIOIn GPIOB
11
+#define GPIOOut GPIOA
9 12
 #define TimerCC TIM4
10 13
 #define channelCC1 LL_TIM_CHANNEL_CH1
11 14
 #define channelCC2 LL_TIM_CHANNEL_CH2
15
+#define USARTOut USART1
16
+#define TransferDirTX LL_USART_DIRECTION_TX
17
+#define TimerRF TIM1
12 18
 
13 19
 
14 20
 void MyRF_Conf(void);
15 21
 
16 22
 int MyRF_Duty_Cycle_Moteur(void);
17 23
 
24
+void MyRF_Transmit_3s(void);
25
+
26
+void MyRF_Transmit_Batterie_Faible(void);
27
+
28
+void MyRF_Transmit_Limite_Roulis(void);
29
+
18 30
 #endif

Loading…
Cancel
Save