Browse Source

Zi projet iz finich

Neluji 3 years ago
parent
commit
b61941fe41

+ 110
- 17
MDK-ARM/Project.uvoptx View File

@@ -317,7 +317,7 @@
317 317
         <SetRegEntry>
318 318
           <Number>0</Number>
319 319
           <Key>DLGDARM</Key>
320
-          <Name>(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)</Name>
320
+          <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=458,245,834,481,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=205,153,626,580,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=537,17,1131,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)</Name>
321 321
         </SetRegEntry>
322 322
         <SetRegEntry>
323 323
           <Number>0</Number>
@@ -350,7 +350,40 @@
350 350
           <Name>-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)</Name>
351 351
         </SetRegEntry>
352 352
       </TargetDriverDllRegistry>
353
-      <Breakpoint/>
353
+      <Breakpoint>
354
+        <Bp>
355
+          <Number>0</Number>
356
+          <Type>0</Type>
357
+          <LineNumber>46</LineNumber>
358
+          <EnabledFlag>1</EnabledFlag>
359
+          <Address>134231148</Address>
360
+          <ByteObject>0</ByteObject>
361
+          <HtxType>0</HtxType>
362
+          <ManyObjects>0</ManyObjects>
363
+          <SizeOfObject>0</SizeOfObject>
364
+          <BreakByAccess>0</BreakByAccess>
365
+          <BreakIfRCount>1</BreakIfRCount>
366
+          <Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Src\main.c</Filename>
367
+          <ExecCommand></ExecCommand>
368
+          <Expression>\\NUCLEO_F103RB\../Src/main.c\46</Expression>
369
+        </Bp>
370
+        <Bp>
371
+          <Number>1</Number>
372
+          <Type>0</Type>
373
+          <LineNumber>58</LineNumber>
374
+          <EnabledFlag>1</EnabledFlag>
375
+          <Address>134231188</Address>
376
+          <ByteObject>0</ByteObject>
377
+          <HtxType>0</HtxType>
378
+          <ManyObjects>0</ManyObjects>
379
+          <SizeOfObject>0</SizeOfObject>
380
+          <BreakByAccess>0</BreakByAccess>
381
+          <BreakIfRCount>1</BreakIfRCount>
382
+          <Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Src\main.c</Filename>
383
+          <ExecCommand></ExecCommand>
384
+          <Expression>\\NUCLEO_F103RB\../Src/main.c\58</Expression>
385
+        </Bp>
386
+      </Breakpoint>
354 387
       <WatchWindow1>
355 388
         <Ww>
356 389
           <count>0</count>
@@ -412,7 +445,7 @@
412 445
         <Wi>
413 446
           <IntNumber>0</IntNumber>
414 447
           <FirstString>((porta &amp; 0x00000800) &gt;&gt; 11 &amp; 0x800) &gt;&gt; 11</FirstString>
415
-          <SecondString>00800000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274612026203078303030303038303029203E3E2031310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F170000000000000000000000000000000000000076150008</SecondString>
448
+          <SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303038303029203E3E2031310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F170000000000000000000000000000000000000076150008</SecondString>
416 449
         </Wi>
417 450
       </LogicAnalyzers>
418 451
       <DebugDescription>
@@ -487,6 +520,42 @@
487 520
       <RteFlg>0</RteFlg>
488 521
       <bShared>0</bShared>
489 522
     </File>
523
+    <File>
524
+      <GroupNumber>2</GroupNumber>
525
+      <FileNumber>5</FileNumber>
526
+      <FileType>1</FileType>
527
+      <tvExp>0</tvExp>
528
+      <tvExpOptDlg>0</tvExpOptDlg>
529
+      <bDave2>0</bDave2>
530
+      <PathWithFileName>..\MyDrivers\girouette.c</PathWithFileName>
531
+      <FilenameWithoutPath>girouette.c</FilenameWithoutPath>
532
+      <RteFlg>0</RteFlg>
533
+      <bShared>0</bShared>
534
+    </File>
535
+    <File>
536
+      <GroupNumber>2</GroupNumber>
537
+      <FileNumber>6</FileNumber>
538
+      <FileType>1</FileType>
539
+      <tvExp>0</tvExp>
540
+      <tvExpOptDlg>0</tvExpOptDlg>
541
+      <bDave2>0</bDave2>
542
+      <PathWithFileName>..\Services\antichavirement.c</PathWithFileName>
543
+      <FilenameWithoutPath>antichavirement.c</FilenameWithoutPath>
544
+      <RteFlg>0</RteFlg>
545
+      <bShared>0</bShared>
546
+    </File>
547
+    <File>
548
+      <GroupNumber>2</GroupNumber>
549
+      <FileNumber>7</FileNumber>
550
+      <FileType>1</FileType>
551
+      <tvExp>0</tvExp>
552
+      <tvExpOptDlg>0</tvExpOptDlg>
553
+      <bDave2>0</bDave2>
554
+      <PathWithFileName>..\Services\Chrono.c</PathWithFileName>
555
+      <FilenameWithoutPath>Chrono.c</FilenameWithoutPath>
556
+      <RteFlg>0</RteFlg>
557
+      <bShared>0</bShared>
558
+    </File>
490 559
   </Group>
491 560
 
492 561
   <Group>
@@ -497,7 +566,7 @@
497 566
     <RteFlg>0</RteFlg>
498 567
     <File>
499 568
       <GroupNumber>3</GroupNumber>
500
-      <FileNumber>5</FileNumber>
569
+      <FileNumber>8</FileNumber>
501 570
       <FileType>1</FileType>
502 571
       <tvExp>0</tvExp>
503 572
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -509,7 +578,7 @@
509 578
     </File>
510 579
     <File>
511 580
       <GroupNumber>3</GroupNumber>
512
-      <FileNumber>6</FileNumber>
581
+      <FileNumber>9</FileNumber>
513 582
       <FileType>1</FileType>
514 583
       <tvExp>0</tvExp>
515 584
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -521,9 +590,9 @@
521 590
     </File>
522 591
     <File>
523 592
       <GroupNumber>3</GroupNumber>
524
-      <FileNumber>7</FileNumber>
593
+      <FileNumber>10</FileNumber>
525 594
       <FileType>1</FileType>
526
-      <tvExp>1</tvExp>
595
+      <tvExp>0</tvExp>
527 596
       <tvExpOptDlg>0</tvExpOptDlg>
528 597
       <bDave2>0</bDave2>
529 598
       <PathWithFileName>..\MyDrivers\MyUSART.c</PathWithFileName>
@@ -533,7 +602,7 @@
533 602
     </File>
534 603
     <File>
535 604
       <GroupNumber>3</GroupNumber>
536
-      <FileNumber>8</FileNumber>
605
+      <FileNumber>11</FileNumber>
537 606
       <FileType>1</FileType>
538 607
       <tvExp>0</tvExp>
539 608
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -545,7 +614,7 @@
545 614
     </File>
546 615
     <File>
547 616
       <GroupNumber>3</GroupNumber>
548
-      <FileNumber>9</FileNumber>
617
+      <FileNumber>12</FileNumber>
549 618
       <FileType>1</FileType>
550 619
       <tvExp>0</tvExp>
551 620
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -555,6 +624,18 @@
555 624
       <RteFlg>0</RteFlg>
556 625
       <bShared>0</bShared>
557 626
     </File>
627
+    <File>
628
+      <GroupNumber>3</GroupNumber>
629
+      <FileNumber>13</FileNumber>
630
+      <FileType>1</FileType>
631
+      <tvExp>0</tvExp>
632
+      <tvExpOptDlg>0</tvExpOptDlg>
633
+      <bDave2>0</bDave2>
634
+      <PathWithFileName>..\MyDrivers\ADC.c</PathWithFileName>
635
+      <FilenameWithoutPath>ADC.c</FilenameWithoutPath>
636
+      <RteFlg>0</RteFlg>
637
+      <bShared>0</bShared>
638
+    </File>
558 639
   </Group>
559 640
 
560 641
   <Group>
@@ -565,7 +646,7 @@
565 646
     <RteFlg>0</RteFlg>
566 647
     <File>
567 648
       <GroupNumber>4</GroupNumber>
568
-      <FileNumber>10</FileNumber>
649
+      <FileNumber>14</FileNumber>
569 650
       <FileType>1</FileType>
570 651
       <tvExp>0</tvExp>
571 652
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -577,7 +658,7 @@
577 658
     </File>
578 659
     <File>
579 660
       <GroupNumber>4</GroupNumber>
580
-      <FileNumber>11</FileNumber>
661
+      <FileNumber>15</FileNumber>
581 662
       <FileType>1</FileType>
582 663
       <tvExp>0</tvExp>
583 664
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -589,7 +670,7 @@
589 670
     </File>
590 671
     <File>
591 672
       <GroupNumber>4</GroupNumber>
592
-      <FileNumber>12</FileNumber>
673
+      <FileNumber>16</FileNumber>
593 674
       <FileType>1</FileType>
594 675
       <tvExp>0</tvExp>
595 676
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -601,7 +682,7 @@
601 682
     </File>
602 683
     <File>
603 684
       <GroupNumber>4</GroupNumber>
604
-      <FileNumber>13</FileNumber>
685
+      <FileNumber>17</FileNumber>
605 686
       <FileType>1</FileType>
606 687
       <tvExp>0</tvExp>
607 688
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -613,7 +694,7 @@
613 694
     </File>
614 695
     <File>
615 696
       <GroupNumber>4</GroupNumber>
616
-      <FileNumber>14</FileNumber>
697
+      <FileNumber>18</FileNumber>
617 698
       <FileType>1</FileType>
618 699
       <tvExp>0</tvExp>
619 700
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -623,6 +704,18 @@
623 704
       <RteFlg>0</RteFlg>
624 705
       <bShared>0</bShared>
625 706
     </File>
707
+    <File>
708
+      <GroupNumber>4</GroupNumber>
709
+      <FileNumber>19</FileNumber>
710
+      <FileType>1</FileType>
711
+      <tvExp>0</tvExp>
712
+      <tvExpOptDlg>0</tvExpOptDlg>
713
+      <bDave2>0</bDave2>
714
+      <PathWithFileName>..\LLDrivers\src\stm32f1xx_ll_adc.c</PathWithFileName>
715
+      <FilenameWithoutPath>stm32f1xx_ll_adc.c</FilenameWithoutPath>
716
+      <RteFlg>0</RteFlg>
717
+      <bShared>0</bShared>
718
+    </File>
626 719
   </Group>
627 720
 
628 721
   <Group>
@@ -633,7 +726,7 @@
633 726
     <RteFlg>0</RteFlg>
634 727
     <File>
635 728
       <GroupNumber>5</GroupNumber>
636
-      <FileNumber>15</FileNumber>
729
+      <FileNumber>20</FileNumber>
637 730
       <FileType>5</FileType>
638 731
       <tvExp>0</tvExp>
639 732
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -653,7 +746,7 @@
653 746
     <RteFlg>0</RteFlg>
654 747
     <File>
655 748
       <GroupNumber>6</GroupNumber>
656
-      <FileNumber>16</FileNumber>
749
+      <FileNumber>21</FileNumber>
657 750
       <FileType>1</FileType>
658 751
       <tvExp>0</tvExp>
659 752
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -673,7 +766,7 @@
673 766
     <RteFlg>0</RteFlg>
674 767
     <File>
675 768
       <GroupNumber>7</GroupNumber>
676
-      <FileNumber>17</FileNumber>
769
+      <FileNumber>22</FileNumber>
677 770
       <FileType>2</FileType>
678 771
       <tvExp>0</tvExp>
679 772
       <tvExpOptDlg>0</tvExpOptDlg>

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

@@ -407,6 +407,21 @@
407 407
               <FileType>1</FileType>
408 408
               <FilePath>..\Services\MySequencer.c</FilePath>
409 409
             </File>
410
+            <File>
411
+              <FileName>girouette.c</FileName>
412
+              <FileType>1</FileType>
413
+              <FilePath>..\MyDrivers\girouette.c</FilePath>
414
+            </File>
415
+            <File>
416
+              <FileName>antichavirement.c</FileName>
417
+              <FileType>1</FileType>
418
+              <FilePath>..\Services\antichavirement.c</FilePath>
419
+            </File>
420
+            <File>
421
+              <FileName>Chrono.c</FileName>
422
+              <FileType>1</FileType>
423
+              <FilePath>..\Services\Chrono.c</FilePath>
424
+            </File>
410 425
           </Files>
411 426
         </Group>
412 427
         <Group>
@@ -437,6 +452,11 @@
437 452
               <FileType>1</FileType>
438 453
               <FilePath>..\MyDrivers\GPIO.c</FilePath>
439 454
             </File>
455
+            <File>
456
+              <FileName>ADC.c</FileName>
457
+              <FileType>1</FileType>
458
+              <FilePath>..\MyDrivers\ADC.c</FilePath>
459
+            </File>
440 460
           </Files>
441 461
         </Group>
442 462
         <Group>
@@ -467,6 +487,11 @@
467 487
               <FileType>1</FileType>
468 488
               <FilePath>..\LLDrivers\src\stm32f1xx_ll_usart.c</FilePath>
469 489
             </File>
490
+            <File>
491
+              <FileName>stm32f1xx_ll_adc.c</FileName>
492
+              <FileType>1</FileType>
493
+              <FilePath>..\LLDrivers\src\stm32f1xx_ll_adc.c</FilePath>
494
+            </File>
470 495
           </Files>
471 496
         </Group>
472 497
         <Group>
@@ -905,6 +930,21 @@
905 930
               <FileType>1</FileType>
906 931
               <FilePath>..\Services\MySequencer.c</FilePath>
907 932
             </File>
933
+            <File>
934
+              <FileName>girouette.c</FileName>
935
+              <FileType>1</FileType>
936
+              <FilePath>..\MyDrivers\girouette.c</FilePath>
937
+            </File>
938
+            <File>
939
+              <FileName>antichavirement.c</FileName>
940
+              <FileType>1</FileType>
941
+              <FilePath>..\Services\antichavirement.c</FilePath>
942
+            </File>
943
+            <File>
944
+              <FileName>Chrono.c</FileName>
945
+              <FileType>1</FileType>
946
+              <FilePath>..\Services\Chrono.c</FilePath>
947
+            </File>
908 948
           </Files>
909 949
         </Group>
910 950
         <Group>
@@ -935,6 +975,11 @@
935 975
               <FileType>1</FileType>
936 976
               <FilePath>..\MyDrivers\GPIO.c</FilePath>
937 977
             </File>
978
+            <File>
979
+              <FileName>ADC.c</FileName>
980
+              <FileType>1</FileType>
981
+              <FilePath>..\MyDrivers\ADC.c</FilePath>
982
+            </File>
938 983
           </Files>
939 984
         </Group>
940 985
         <Group>
@@ -965,6 +1010,11 @@
965 1010
               <FileType>1</FileType>
966 1011
               <FilePath>..\LLDrivers\src\stm32f1xx_ll_usart.c</FilePath>
967 1012
             </File>
1013
+            <File>
1014
+              <FileName>stm32f1xx_ll_adc.c</FileName>
1015
+              <FileType>1</FileType>
1016
+              <FilePath>..\LLDrivers\src\stm32f1xx_ll_adc.c</FilePath>
1017
+            </File>
968 1018
           </Files>
969 1019
         </Group>
970 1020
         <Group>

Services/ADC_antichavirement.c → MyDrivers/ADC.c View File

@@ -1,17 +1,17 @@
1
-#include "ADC_antichavirement.h"
2
-#include "Chrono.h"
3
-#include "MyTimer.h"
1
+#include "ADC.h"
4 2
 #include "stm32f1xx_ll_bus.h"
5
-#include "stm32f1xx_ll_tim.h"
6 3
 #include "stm32f1xx_ll_adc.h"
7 4
 #include "stm32f1xx_ll_rcc.h"
8 5
 
9
-#define seuil_g_pos 1.0
10
-#define seuil_g_neg -1.0
11
-
6
+/**
7
+	* @brief  Configure l'ADC pour les différents channels
8
+  * @note   
9
+	* @param  None
10
+  * @retval None
11
+  */
12 12
 void conf_ADC (void) {
13 13
 	
14
-		//ADC_REG
14
+		//Activation de la clock de l'ADC
15 15
 	
16 16
 		LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
17 17
 	
@@ -19,7 +19,7 @@ void conf_ADC (void) {
19 19
 	
20 20
 		LL_RCC_SetADCClockSource(LL_RCC_ADC_CLKSRC_PCLK2_DIV_6);
21 21
 	
22
-		//Bit ADON à 1
22
+		//Bit ADON à 1 pour lancer la conversion
23 23
 	
24 24
 		LL_ADC_Enable(ADC1);
25 25
 		
@@ -39,14 +39,18 @@ void conf_ADC (void) {
39 39
    
40 40
 		LL_ADC_REG_Init(ADC1,&My_LL_ADC_REG_Init_Struct);
41 41
 		
42
-		
43
-		//ADC Sampling Time
42
+		//Configuration du Sampling Time
44 43
 
45 44
 		LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_10, LL_ADC_SAMPLINGTIME_239CYCLES_5);
46 45
 		LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_11, LL_ADC_SAMPLINGTIME_239CYCLES_5);		
47 46
 }
48 47
 
49
-
48
+/**
49
+	* @brief  Règle les différentes entrées et sortie nécessaire à la girouette
50
+  * @note   
51
+	* @param  None
52
+  * @retval valeur du rapport "X/Y" [0 infini]
53
+  */
50 54
 uint32_t X;
51 55
 uint32_t Y;
52 56
 float rapport;
@@ -86,16 +90,3 @@ float start_ADC (void) {
86 90
 	return rapport;
87 91
 	
88 92
 }
89
-
90
-
91
-void antichavirement (float rapport) {
92
-	
93
-	if (rapport >= seuil_g_pos || rapport <= seuil_g_neg){
94
-		
95
-	//Voiles à 90°
96
-	MyPWM_Set_Impulse_Duration(TIM1,10000*10/100,LL_TIM_CHANNEL_CH1);
97
-		
98
-	}
99
-	
100
-	
101
-}

+ 4
- 0
MyDrivers/ADC.h View File

@@ -0,0 +1,4 @@
1
+#include "stm32f103xb.h" 
2
+
3
+void conf_ADC (void);
4
+float start_ADC (void);

+ 0
- 1
MyDrivers/GPIO.h View File

@@ -8,7 +8,6 @@ Configuration de toutes les broches utilis
8 8
 - Accéléromètre : PC.0 et PC.1
9 9
 - Servo : PA.8
10 10
 - Girouette : PA.5, PA.6 et PA.7
11
-Manque PC.2 = adc batterie
12 11
 */
13 12
 
14 13
 #include "stm32f103xb.h"

+ 41
- 0
MyDrivers/MyPWM.c View File

@@ -18,6 +18,32 @@ void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel)
18 18
 }
19 19
 
20 20
 
21
+/**
22
+	* @brief  Configuration du timer en mode PWM
23
+  * @note   
24
+	* @param  TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
25
+  * @retval None
26
+  */
27
+void MyPWM_girouette_Conf_Output(TIM_TypeDef *TIMx, uint32_t Channel)
28
+{
29
+	
30
+		//Définition
31
+    LL_TIM_OC_InitTypeDef My_LL_Tim_OC_Init_Struct;
32
+
33
+    //Configuration du output channel en PWM
34
+    LL_TIM_OC_StructInit(&My_LL_Tim_OC_Init_Struct);
35
+    My_LL_Tim_OC_Init_Struct.OCMode = LL_TIM_OCMODE_PWM1;
36
+    LL_TIM_OC_Init(TIMx,Channel,&My_LL_Tim_OC_Init_Struct);
37
+
38
+		// Réglage du ARR et du PSC du Timer en PWM pour une période de 20ms
39
+		LL_TIM_SetAutoReload(TIMx,0x707F);
40
+		LL_TIM_SetPrescaler(TIMx,0x31);
41
+	
42
+		//Activation du channel (CH3) pour le timer considéré
43
+    LL_TIM_CC_EnableChannel(TIMx, Channel);
44
+}
45
+
46
+
21 47
 //Configurer obligatoirement les channels 1 et 2 sur IC1 et IC2 ou IC3 et IC4
22 48
 void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2)
23 49
 {	
@@ -56,6 +82,21 @@ void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int
56 82
 }
57 83
 
58 84
 
85
+void MyPWM_girouette_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage, int channel)
86
+{
87
+	static uint32_t Val_ARR;
88
+	static uint32_t CompareValue;
89
+	
90
+	Val_ARR = LL_TIM_GetAutoReload(Timer);
91
+	CompareValue = (Val_ARR * Percentage)/10000;
92
+	
93
+	if (channel==LL_TIM_CHANNEL_CH1) LL_TIM_OC_SetCompareCH1(Timer, CompareValue);
94
+	else if (channel==LL_TIM_CHANNEL_CH2) LL_TIM_OC_SetCompareCH2(Timer, CompareValue);
95
+	else if (channel==LL_TIM_CHANNEL_CH3) LL_TIM_OC_SetCompareCH3(Timer, CompareValue);
96
+	else  LL_TIM_OC_SetCompareCH4(Timer, CompareValue);
97
+}
98
+
99
+
59 100
 int MyPWM_Duty_Cycle_Permilles(TIM_TypeDef * Timer, int channel1, int channel2) {
60 101
 	if(channel1 == LL_TIM_CHANNEL_CH1 && channel2 == LL_TIM_CHANNEL_CH2) {
61 102
 		return LL_TIM_IC_GetCaptureCH2(Timer) / LL_TIM_IC_GetCaptureCH1(Timer) * 1000;

+ 10
- 0
MyDrivers/MyPWM.h View File

@@ -16,6 +16,14 @@ Driver pour la gestion de la PWM de Timers 1 
16 16
 void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel);
17 17
 
18 18
 /**
19
+	* @brief  Configuration du timer en mode PWM
20
+  * @note   
21
+	* @param  TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
22
+  * @retval None
23
+  */
24
+void MyPWM_girouette_Conf_Output(TIM_TypeDef *TIMx, uint32_t Channel);
25
+
26
+/**
19 27
 	* @brief  Configure un timer en mode PWM Input
20 28
 	* @note   Penser à appeler Timer_Conf() de Timer.h avant !
21 29
 	* @param  1 timer, 2 channels associés (1&2 ou 3&4)
@@ -31,6 +39,8 @@ void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2);
31 39
 	*/
32 40
 void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int channel);
33 41
 
42
+void MyPWM_girouette_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage, int channel);
43
+
34 44
 /**
35 45
 	* @brief  Renvoie le duty cycle de la PWM en entrée
36 46
 	* @note   Fct utilisée en réception

+ 27
- 1
MyDrivers/MyTimer.c View File

@@ -143,7 +143,33 @@ void MyTimer_IT_Enable(TIM_TypeDef * Timer)
143 143
 void MyTimer_IT_Disable(TIM_TypeDef * Timer)
144 144
 {
145 145
 			LL_TIM_DisableIT_UPDATE(Timer); 
146
-}	
146
+}
147
+
148
+
149
+/**
150
+	* @brief  Configuration du timer en mode encodeur
151
+  * @note   
152
+	* @param  None
153
+  * @retval None
154
+  */
155
+void MyTimer_girouette_Conf(void)
156
+{
157
+	
158
+	//Définition
159
+	LL_TIM_ENCODER_InitTypeDef My_LL_Tim_Init_Struct;
160
+	
161
+	// Validation horloge locale
162
+  LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
163
+
164
+	//Initilisation de la structure au Timer 3
165
+	LL_TIM_ENCODER_StructInit(&My_LL_Tim_Init_Struct);
166
+	LL_TIM_ENCODER_Init(TIM3, &My_LL_Tim_Init_Struct);
167
+	
168
+	// Réglage Timer 3
169
+	LL_TIM_SetAutoReload(TIM3,719);
170
+	LL_TIM_SetPrescaler(TIM3,0);
171
+		
172
+}
147 173
 
148 174
 
149 175
 /*

+ 8
- 0
MyDrivers/MyTimer.h View File

@@ -67,4 +67,12 @@ void MyTimer_IT_Enable(TIM_TypeDef * Timer);
67 67
   */
68 68
 void MyTimer_IT_Disable(TIM_TypeDef * Timer);
69 69
 
70
+/**
71
+	* @brief  Configuration du timer en mode encodeur
72
+  * @note   
73
+	* @param  None
74
+  * @retval None
75
+  */
76
+void MyTimer_girouette_Conf(void);
77
+
70 78
 #endif

Services/girouette.c → MyDrivers/girouette.c View File

@@ -1,12 +1,15 @@
1 1
 #include "stm32f1xx_ll_gpio.h"
2 2
 #include "girouette.h"
3 3
 #include "MyTimer.h"
4
-#include "stm32f1xx_ll_bus.h"
4
+#include "MyPWM.h"
5 5
 #include "stm32f1xx_ll_tim.h"
6
-#include "stm32f1xx_ll_adc.h"
7
-#include "stm32f1xx_ll_rcc.h"
8 6
 
9
-//Configuration de l'interruption exterieure
7
+/**
8
+	* @brief  Configuration de l'interruption exterieure
9
+  * @note   
10
+	* @param  None
11
+  * @retval None
12
+  */
10 13
 void exti_ref(void){
11 14
 
12 15
     LL_GPIO_AF_SetEXTISource(LL_GPIO_AF_EXTI_PORTA, LL_GPIO_AF_EXTI_LINE5);
@@ -17,13 +20,23 @@ void exti_ref(void){
17 20
     EXTI->RTSR |= EXTI_RTSR_TR5_Msk;
18 21
 }
19 22
 
20
-//Configuration de l'interruption du NVIC
23
+/**
24
+	* @brief  Configuration de l'interruption du NVIC
25
+  * @note   
26
+	* @param  None
27
+  * @retval None
28
+  */
21 29
 void nvic_exti_conf(void){
22 30
     NVIC->IP[23]=2<<4;
23 31
     NVIC->ISER[0]=1<<23;
24 32
 }
25 33
 
26
-//redirection de l'interruption
34
+/**
35
+	* @brief  redirection de l'interruption
36
+  * @note   
37
+	* @param  None
38
+  * @retval None
39
+  */
27 40
 void EXTI9_5_IRQHandler(void){
28 41
     //CNT A ZERO
29 42
     LL_TIM_SetCounter(TIM3, 0);
@@ -32,31 +45,38 @@ void EXTI9_5_IRQHandler(void){
32 45
 }
33 46
 
34 47
 
35
-
36
-//configuration interruption + timer 3 en mode encodeur et 4 en mode PWM
48
+/**
49
+	* @brief  Configuration des interruptions et des timers
50
+  * @note   
51
+	* @param  None
52
+  * @retval None
53
+  */
37 54
 void conf_girouette(void){
38 55
 	
39
-		//interruption
56
+		//Configuration des interruptions
40 57
 		exti_ref();
41 58
 		nvic_exti_conf();
42
-
43
-		
44
-		//Timer en mode encodeur
59
+	
60
+		//Configuration timer en mode encodeur
45 61
     MyTimer_girouette_Conf();
46 62
 		
47
-		//Timer en mode PWM
48
-		MyPWM_Conf_Output(TIM1,LL_TIM_CHANNEL_CH1);
63
+		//Configuration timer en mode PWM
64
+		MyPWM_girouette_Conf_Output(TIM1,LL_TIM_CHANNEL_CH1);
49 65
 		
50 66
 		//Activation Timer 1
51 67
 		LL_TIM_EnableAllOutputs(TIM1);
52
-
53 68
 }
54 69
 
70
+/**
71
+	* @brief  Calcul position-angle à partir de l'encodeur
72
+  * @note   
73
+	* @param  None
74
+  * @retval Pourcentage "Temps haut/Période" de la PWM [5 10]% (180 valeurs)
75
+  */
55 76
 
56
-//Calcul position-angle
57
-
58
-float pos_Min=0;
59
-float pos_Max=135;
77
+//Initialisation des variables
78
+float pos_Min=90;
79
+float pos_Max=270;
60 80
 float pos_actuelle;
61 81
 
62 82
 float duree_Min=1;
@@ -71,16 +91,16 @@ float Pourcentage_calc;
71 91
 
72 92
 float Calcul_pourcentage_duree (void){
73 93
 	
74
-	pos_actuelle=LL_TIM_GetCounter(TIM3);
94
+	pos_actuelle=LL_TIM_GetCounter(TIM3);//Récupération de la valeur du compteur
75 95
 	
76 96
 	//Calcul pourcentage min et max
77 97
 	Pourcentage_Min=duree_Min/Periode;
78 98
 	Pourcentage_Max=duree_Max/Periode;
79 99
 	
80
-	//Calcul fctn affine
100
+	//Calcul fonction affine "durée Temps haut" en fonction de la valeur du compteur
81 101
 	if (pos_actuelle <= 360){
82
-		if (pos_actuelle > 90 && pos_actuelle < 270) {
83
-			duree_calc=((duree_Max-duree_Min)/(pos_Max-pos_Min))*pos_actuelle+duree_Min;
102
+		if (pos_actuelle > 90 && pos_actuelle <= 270) {
103
+			duree_calc=((duree_Max-duree_Min)/(pos_Max-pos_Min))*pos_actuelle+duree_Min/duree_Max;
84 104
 		}
85 105
 		else if (pos_actuelle > 270){
86 106
 			duree_calc=duree_Max;
@@ -89,10 +109,11 @@ float Calcul_pourcentage_duree (void){
89 109
 			duree_calc=duree_Min;
90 110
 		}
91 111
 	}
92
-	
93
-	/*if (pos_actuelle > 360 && pos_actuelle < 720){
112
+	//Calcul fonction affine "durée Temps haut" en fonction de la valeur du compteur
113
+	//Si la girouette dépasse 180° ?
114
+	if (pos_actuelle > 360 && pos_actuelle < 720){
94 115
 		if (pos_actuelle > 450 && pos_actuelle < 630) {
95
-			duree_calc=((duree_Max-duree_Min)/(pos_Max-pos_Min))*(720-pos_actuelle)+duree_Min;
116
+			duree_calc=((duree_Max-duree_Min)/(pos_Max-pos_Min))*(720-pos_actuelle)+duree_Min/duree_Max;
96 117
 		}
97 118
 		else if (pos_actuelle < 450){
98 119
 			duree_calc=duree_Max;
@@ -100,9 +121,9 @@ float Calcul_pourcentage_duree (void){
100 121
 		else {
101 122
 			duree_calc=duree_Min;
102 123
 		}
103
-	}*/
124
+	}
104 125
 	
105
-	//Calcul pourcentage
126
+	//Calcul du pourcentage en fonction de la "durée Temps haut"
106 127
 	Pourcentage_calc=((Pourcentage_Max-Pourcentage_Min)/(duree_Max-duree_Min))*duree_calc;
107 128
 	
108 129
  return Pourcentage_calc;

+ 7
- 0
MyDrivers/girouette.h View File

@@ -0,0 +1,7 @@
1
+#include "stm32f103xb.h" 
2
+
3
+void conf_girouette(void);
4
+
5
+float Calcul_pourcentage_duree (void);
6
+
7
+float Angle_Vent(void);

+ 235
- 0
Services/Chrono.c View File

@@ -0,0 +1,235 @@
1
+// A COMPLETER
2
+
3
+/*
4
+Service permettant de chornométrer jusqu'à 59mn 59s 99 1/100
5
+Utilise un timer au choix (TIMER1 à TIMER4).
6
+Utilise la lib MyTimers.h /.c
7
+*/
8
+
9
+
10
+
11
+#include "Chrono.h"
12
+#include "MyTimer.h"
13
+#include "stm32f1xx_ll_gpio.h"
14
+#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
15
+
16
+// variable privée de type Time qui mémorise la durée mesurée
17
+static Time Chrono_Time; // rem : static rend la visibilité de la variable Chrono_Time limitée à ce fichier 
18
+
19
+// variable privée qui mémorise pour le module le timer utilisé par le module
20
+static TIM_TypeDef * Chrono_Timer=TIM1; // init par défaut au cas où l'utilisateur ne lance pas Chrono_Conf avant toute autre fct.
21
+
22
+//mémorise l'état précédent du bouton Start/Stop
23
+static int Prev_Start_Stop_BP_Status=0;
24
+
25
+//mémorise l'état du chrono (lancé ou pas)
26
+static int Started=1;
27
+
28
+// déclaration callback appelé toute les 10ms
29
+void Chrono_Task_10ms(void);
30
+
31
+//Configuration des I/O
32
+void Chrono_Conf_io(void);
33
+
34
+/**
35
+	* @brief  Configure le chronomètre. 
36
+  * @note   A lancer avant toute autre fonction.
37
+	* @param  Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
38
+  * @retval None
39
+  */
40
+void Chrono_Conf(TIM_TypeDef * Timer)
41
+{
42
+    // Reset Time
43
+    Chrono_Time.Hund=0;
44
+    Chrono_Time.Sec=0;
45
+    Chrono_Time.Min=0;
46
+
47
+    // Fixation du Timer
48
+    Chrono_Timer=Timer;
49
+
50
+    // Réglage Timer par défaut
51
+    MyTimer_Conf(Chrono_Timer,0xFFFF,0);
52
+
53
+    // Réglage interruption du Timer avec callback : Chrono_Task_10ms()
54
+    MyTimer_IT_Conf(Chrono_Timer, Chrono_Task_10ms,3);
55
+
56
+    // Validation IT
57
+    MyTimer_IT_Enable(Chrono_Timer);
58
+	
59
+}
60
+
61
+
62
+/**
63
+	* @brief  Démarre le chronomètre. 
64
+  * @note   si la durée dépasse 59mn 59sec 99 Hund, elle est remise à zéro et repart
65
+	* @param  Aucun
66
+  * @retval Aucun
67
+  */
68
+void Chrono_Start(void)
69
+{
70
+	Chrono_Timer=TIM3;
71
+    MyTimer_Start(Chrono_Timer); //Start Timer 3
72
+
73
+    Chrono_Timer=TIM1;
74
+    MyTimer_Start(Chrono_Timer); //Start Timer 1
75
+}
76
+
77
+
78
+/**
79
+	* @brief  Arrête le chronomètre. 
80
+  * @note   
81
+	* @param  Aucun
82
+  * @retval Aucun
83
+  */
84
+void Chrono_Stop(void)
85
+{
86
+	MyTimer_Stop(Chrono_Timer);
87
+}
88
+
89
+
90
+/**
91
+	* @brief  Remet le chronomètre à 0 
92
+  * @note   
93
+	* @param  Aucun
94
+  * @retval Aucun
95
+  */
96
+void Chrono_Reset(void)
97
+{
98
+  // Arrêt Chrono
99
+	MyTimer_Stop(Chrono_Timer);
100
+
101
+	// Reset Time
102
+	Chrono_Time.Hund=0;
103
+	Chrono_Time.Sec=0;
104
+	Chrono_Time.Min=0;
105
+}
106
+
107
+
108
+/**
109
+	* @brief  Renvoie l'adresse de la variable Time privée gérée dans le module Chrono.c
110
+  * @note   
111
+	* @param  Aucun
112
+  * @retval adresse de la variable Time
113
+  */
114
+Time * Chrono_Read(void)
115
+{
116
+	return &Chrono_Time;
117
+}
118
+
119
+
120
+
121
+
122
+/**
123
+	* @brief  incrémente la variable privée Chron_Time modulo 60mn 
124
+  * @note   
125
+	* @param  Aucun
126
+  * @retval Aucun
127
+  */
128
+void Chrono_Task_10ms(void)
129
+{ 
130
+	Chrono_Time.Hund++;
131
+	if (Chrono_Time.Hund==100)
132
+	{
133
+		Chrono_Time.Sec++;
134
+		Chrono_Time.Hund=0;
135
+		LL_GPIO_TogglePin(GPIOA,LL_GPIO_PIN_5);
136
+	}
137
+	if (Chrono_Time.Sec==60)
138
+	{
139
+		Chrono_Time.Min++;
140
+		Chrono_Time.Sec=0;
141
+	}
142
+	if (Chrono_Time.Min==60)
143
+	{
144
+		Chrono_Time.Hund=0;
145
+	}
146
+	
147
+}
148
+
149
+
150
+/**
151
+	* @brief  polle les 3 entrées et gènère les actions à faire
152
+  * @note   Fct à lancer en tâche de fond (non bloquante)
153
+	* @param  None 
154
+  * @retval None
155
+  */
156
+		
157
+void Chrono_Background(void) {
158
+	
159
+	//Lecture PC8 bouton Start/Stop
160
+	int Start_Stop_BP_Status = LL_GPIO_IsInputPinSet(GPIOC, LL_GPIO_PIN_8);
161
+	
162
+	//Changement de l'état du chrono sur front montant du BP
163
+	if(Start_Stop_BP_Status && (Start_Stop_BP_Status != Prev_Start_Stop_BP_Status)) {
164
+		if(!Started){
165
+			Chrono_Start();
166
+			Started = 1;
167
+		}
168
+		else {
169
+			Chrono_Stop();
170
+			Started = 0;
171
+		}
172
+	}
173
+	
174
+	//Actualisation mémoire BP
175
+	Prev_Start_Stop_BP_Status = Start_Stop_BP_Status;
176
+	
177
+	//Reset sur PC13 high
178
+	if(!LL_GPIO_IsInputPinSet(GPIOC, LL_GPIO_PIN_13)) {
179
+		Chrono_Time.Hund=0;
180
+		Chrono_Time.Sec=0;
181
+		Chrono_Time.Min=0;
182
+	}
183
+	
184
+}
185
+
186
+/**
187
+	* @brief  configure les 3 pins d'I/O
188
+  * @note   
189
+	* @param  None 
190
+  * @retval None
191
+  */
192
+		
193
+void Chrono_Conf_io(void) {
194
+	
195
+	//Validation horloge locale
196
+	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
197
+	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
198
+	
199
+	GPIO_TypeDef * GPIO;
200
+	LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
201
+	
202
+	//PA5 (LED de la carte) en output push-pull
203
+	
204
+	GPIO = GPIOA;
205
+	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_5;
206
+	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
207
+	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
208
+	My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_10MHz;
209
+	My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
210
+	
211
+	LL_GPIO_Init(GPIO, &My_GPIO_Init_Struct);
212
+	
213
+	//PC8 en floating input
214
+	
215
+	GPIO = GPIOC;
216
+	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_8;
217
+	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_FLOATING;
218
+	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
219
+	My_GPIO_Init_Struct.Speed = LL_GPIO_SPEED_FREQ_LOW;
220
+	My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
221
+	
222
+	LL_GPIO_Init(GPIO, &My_GPIO_Init_Struct);
223
+	
224
+	//PC13 (USER Button bleu carte) en floating input
225
+	
226
+	GPIO = GPIOC;
227
+	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_13;
228
+	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_FLOATING;
229
+	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
230
+	My_GPIO_Init_Struct.Speed = LL_GPIO_SPEED_FREQ_LOW;
231
+	My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
232
+	
233
+	LL_GPIO_Init(GPIO, &My_GPIO_Init_Struct);
234
+	
235
+}

+ 107
- 0
Services/Chrono.h View File

@@ -0,0 +1,107 @@
1
+// RIEN A MODIFIER //
2
+
3
+#ifndef CHRONO_H
4
+#define CHRONO_H
5
+
6
+/*
7
+Service permettant de chornométrer jusqu'à 59mn 59s 99 1/100
8
+Utilise un timer au choix (TIMER1 à TIMER4).
9
+Utilise la lib MyTimers.h /.c
10
+*/
11
+
12
+#include "stm32f103xb.h" 
13
+
14
+/* =====================================================================================
15
+Les fonctions qui gèrent les IO (ajout par rapport à l'activité 1)
16
+=======================================================================================*/
17
+
18
+
19
+#define PinStart LL_GPIO_PIN_8
20
+#define PinStop LL_GPIO_PIN_6
21
+// à compléter pour la pin reset du chronometre
22
+#define PinLED LL_GPIO_PIN_10
23
+#define GPIO_Pin GPIOC
24
+#define GPIO_LED GPIOC
25
+
26
+
27
+
28
+
29
+
30
+
31
+/**
32
+	* @brief  polle les 3 entrées et gènère les actions à faire
33
+  * @note   Fct à lancer en tâche de fond (non bloquante)
34
+	* @param  None 
35
+  * @retval None
36
+  */
37
+		
38
+void Chrono_Background(void);
39
+
40
+//=======================================================================================//
41
+
42
+
43
+
44
+
45
+// Type de donnée utilisé dans le module
46
+
47
+typedef struct {
48
+	char Hund;
49
+	char Sec;
50
+	char Min;
51
+} Time;
52
+
53
+
54
+
55
+
56
+/**
57
+	* @brief  Configure le chronomètre. 
58
+  * @note   A lancer avant toute autre fonction.
59
+	* @param  TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
60
+  * @retval None
61
+  */
62
+void Chrono_Conf(TIM_TypeDef * Timer);
63
+
64
+
65
+
66
+
67
+
68
+
69
+/**
70
+	* @brief  Démarre le chronomètre. 
71
+  * @note   si la durée dépasse 59mn 59sec 99 cent, elle est remise à zéro et repart
72
+	* @param  Aucun
73
+  * @retval Aucun
74
+  */
75
+void Chrono_Start(void);
76
+
77
+
78
+/**
79
+	* @brief  Arrête le chronomètre. 
80
+  * @note   
81
+	* @param  Aucun
82
+  * @retval Aucun
83
+  */
84
+void Chrono_Stop(void);
85
+
86
+
87
+/**
88
+	* @brief  Remet le chronomètre à 0 
89
+  * @note   
90
+	* @param  Aucun
91
+  * @retval Aucun
92
+  */
93
+void Chrono_Reset(void);
94
+
95
+
96
+/**
97
+	* @brief  Renvoie l'adresse de la variable Time privée gérée dans le module Chrono.c
98
+  * @note   
99
+	* @param  Aucun
100
+  * @retval adresse de la variable Time
101
+  */
102
+Time * Chrono_Read(void);
103
+
104
+
105
+
106
+
107
+#endif

+ 2
- 16
Services/MyRF.c View File

@@ -71,12 +71,8 @@ void MyRF_Transmit_3s(int bordage_pc, int angle_vent) {
71 71
 		"au grand largue.",
72 72
 		"au vent arrière."
73 73
 	};
74
-		
75
-	char heure[2] = "xx";
76
-	char min[2] = "xx";
77
-	char sec[2] = "xx";
78 74
 	
79
-	char data1[14] = "\" - Bordage : ";
75
+	char data1[10] = "Bordage : ";
80 76
 	char data2[24] = " === Le voilier navigue ";
81 77
 	
82 78
 	int i;
@@ -84,17 +80,7 @@ void MyRF_Transmit_3s(int bordage_pc, int angle_vent) {
84 80
 	//Activation de l'émetteur RF
85 81
 	LL_GPIO_SetOutputPin(GPIOOut ,PinTXEn);
86 82
 	
87
-	//Heure
88
-	MyUSART_Transmit_Data_8b(USARTOut, heure[0]);
89
-	MyUSART_Transmit_Data_8b(USARTOut, heure[1]);
90
-	MyUSART_Transmit_Data_8b(USARTOut, 'h');
91
-	//Minutes
92
-	MyUSART_Transmit_Data_8b(USARTOut, min[0]);
93
-	MyUSART_Transmit_Data_8b(USARTOut, min[1]);
94
-	MyUSART_Transmit_Data_8b(USARTOut, '\'');
95
-	//Secondes
96
-	MyUSART_Transmit_Data_8b(USARTOut, sec[0]);
97
-	MyUSART_Transmit_Data_8b(USARTOut, sec[1]);
83
+	
98 84
 	//Texte 1 (bordage)
99 85
 	for(i=0; i<14; i++) {
100 86
 		MyUSART_Transmit_Data_8b(USARTOut, data1[i]);

+ 1
- 1
Services/MyRF.h View File

@@ -38,7 +38,7 @@ void MyRF_Conf(void);
38 38
 	* @param  None 
39 39
   * @retval int : [-100; 100] pour correspondre à la plage du moteur
40 40
   */
41
-int MyRF_Duty_Cycle_Moteur(void);
41
+int MyRF_Input_Duty_Cycle(void);
42 42
 
43 43
 /**
44 44
 	* @brief  Transmet un message via l'USART vers l'émetteur RF

+ 15
- 2
Services/MySequencer.c View File

@@ -3,8 +3,15 @@
3 3
 #include "Moteur.h"
4 4
 #include "MyRF.h"
5 5
 #include "girouette.h"
6
+#include "antichavirement.h"
7
+#include "ADC.h"
8
+#include "MyPWM.h"
9
+#include "stm32f1xx_ll_tim.h"
6 10
 
7 11
 int cnt_3sec = 0;
12
+float pourcentage = 0.0;
13
+
14
+void MySequencer_Task_10ms (void);
8 15
 
9 16
 void MySequencer_Conf(void) {
10 17
 	
@@ -28,12 +35,12 @@ void MySequencer_Task_10ms (void) {
28 35
 	
29 36
 	//Transmission données toutes les 3 secondes
30 37
 	if(cnt_3sec == 300) {
31
-		MyRF_Transmit_3s((int)((Calcul_pourcentage_duree()-5.0)*20.0), (int)(Angle_Vent()));
38
+		MyRF_Transmit_3s((int)((Calcul_pourcentage_duree()-0.05)*2000.0), (int)(Angle_Vent()));
32 39
 		cnt_3sec = 0;
33 40
 	}
34 41
 	
35 42
 	//Réglage sens et vitesse moteur
36
-	int Duty_Cycle = MyRF_Duty_Cycle_Moteur();
43
+	int Duty_Cycle = MyRF_Input_Duty_Cycle();
37 44
 	if (Duty_Cycle >= 0) {
38 45
 		Moteur_Speed(Duty_Cycle);
39 46
 		Moteur_Sens(1);
@@ -43,6 +50,12 @@ void MySequencer_Task_10ms (void) {
43 50
 		Moteur_Sens(0);
44 51
 	}
45 52
 	
53
+	//Gestion de l'antichavirement
54
+	antichavirement(start_ADC());
46 55
 	
56
+	//Gestion du bordage
57
+	pourcentage = Calcul_pourcentage_duree();
58
+	pourcentage *= 1000;
59
+	MyPWM_girouette_Set_Impulse_Duration(TIM1,pourcentage,LL_TIM_CHANNEL_CH1);
47 60
 	
48 61
 }

+ 28
- 0
Services/antichavirement.c View File

@@ -0,0 +1,28 @@
1
+#include "antichavirement.h"
2
+#include "MyPWM.h"
3
+#include "stm32f1xx_ll_tim.h"
4
+#include "stm32f1xx_ll_adc.h"
5
+#include "MyRF.h"
6
+
7
+#define seuil_g_pos 1.0
8
+#define seuil_g_neg -1.0
9
+
10
+/**
11
+	* @brief  Configure l'antichavirement pour des valeurs seuils 
12
+  * @note   
13
+	* @param  Rapport "X/Y" [0 infini] (Si Rapport dépasse les valeurs seuils alors on déclenche les voiles)
14
+  * @retval None
15
+  */
16
+void antichavirement (float rapport) {
17
+	
18
+	if (rapport >= seuil_g_pos || rapport <= seuil_g_neg){
19
+		
20
+		//Application des voiles à 90°
21
+		MyPWM_girouette_Set_Impulse_Duration(TIM1,10000*10/100,LL_TIM_CHANNEL_CH1);
22
+		
23
+		MyRF_Transmit_Limite_Roulis();
24
+		
25
+	}
26
+	
27
+	
28
+}

+ 3
- 0
Services/antichavirement.h View File

@@ -0,0 +1,3 @@
1
+#include "stm32f103xb.h" 
2
+
3
+void antichavirement (float rapport);

+ 11
- 0
Src/main.c View File

@@ -24,6 +24,9 @@
24 24
 #include "Moteur.h"
25 25
 #include "MySequencer.h"
26 26
 #include "girouette.h"
27
+#include "GPIO.h"
28
+#include "ADC.h"
29
+#include "Chrono.h"
27 30
 
28 31
 
29 32
 void  SystemClock_Config(void);
@@ -42,9 +45,17 @@ int main(void)
42 45
   /* Configure the system clock to 72 MHz */
43 46
   SystemClock_Config();
44 47
 	
48
+	Chrono_Conf(TIM3);
49
+	Chrono_Conf(TIM1);
50
+	
51
+	Chrono_Start();
52
+	
45 53
 	MyRF_Conf();
46 54
 	Moteur_Conf();
47 55
 	MySequencer_Conf();
56
+	conf_girouette();
57
+	conf_GPIO();
58
+	conf_ADC();
48 59
   
49 60
   /* Infinite loop */
50 61
   while (1)

Loading…
Cancel
Save