Browse Source

Merge remote-tracking branch 'origin/YA'

Arnaud Vergnet 3 years ago
parent
commit
4ca6136473

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

@@ -345,7 +345,7 @@
345 345
         <SetRegEntry>
346 346
           <Number>0</Number>
347 347
           <Key>DLGDARM</Key>
348
-          <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=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,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=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=-1,-1,-1,-1,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)</Name>
348
+          <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=2156,213,2522,450,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=2124,217,2535,660,0)(122=-1,-1,-1,-1,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=-1,-1,-1,-1,0)(131=-1,-1,-1,-1,0)(132=2076,105,2660,897,0)(133=2592,151,3176,943,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)</Name>
349 349
         </SetRegEntry>
350 350
         <SetRegEntry>
351 351
           <Number>0</Number>
@@ -382,9 +382,25 @@
382 382
         <Bp>
383 383
           <Number>0</Number>
384 384
           <Type>0</Type>
385
-          <LineNumber>46</LineNumber>
385
+          <LineNumber>65</LineNumber>
386
+          <EnabledFlag>1</EnabledFlag>
387
+          <Address>134223216</Address>
388
+          <ByteObject>0</ByteObject>
389
+          <HtxType>0</HtxType>
390
+          <ManyObjects>0</ManyObjects>
391
+          <SizeOfObject>0</SizeOfObject>
392
+          <BreakByAccess>0</BreakByAccess>
393
+          <BreakIfRCount>1</BreakIfRCount>
394
+          <Filename>../Src/main.c</Filename>
395
+          <ExecCommand></ExecCommand>
396
+          <Expression>\\NUCLEO_F103RB\../Src/main.c\65</Expression>
397
+        </Bp>
398
+        <Bp>
399
+          <Number>1</Number>
400
+          <Type>0</Type>
401
+          <LineNumber>69</LineNumber>
386 402
           <EnabledFlag>1</EnabledFlag>
387
-          <Address>134219406</Address>
403
+          <Address>134223230</Address>
388 404
           <ByteObject>0</ByteObject>
389 405
           <HtxType>0</HtxType>
390 406
           <ManyObjects>0</ManyObjects>
@@ -393,9 +409,16 @@
393 409
           <BreakIfRCount>1</BreakIfRCount>
394 410
           <Filename>../Src/main.c</Filename>
395 411
           <ExecCommand></ExecCommand>
396
-          <Expression>\\NUCLEO_F103RB\../Src/main.c\46</Expression>
412
+          <Expression>\\NUCLEO_F103RB\../Src/main.c\69</Expression>
397 413
         </Bp>
398 414
       </Breakpoint>
415
+      <WatchWindow1>
416
+        <Ww>
417
+          <count>0</count>
418
+          <WinNumber>1</WinNumber>
419
+          <ItemText>counter,0x10</ItemText>
420
+        </Ww>
421
+      </WatchWindow1>
399 422
       <Tracepoint>
400 423
         <THDelay>0</THDelay>
401 424
       </Tracepoint>
@@ -416,7 +439,7 @@
416 439
         <AscS3>0</AscS3>
417 440
         <aSer3>0</aSer3>
418 441
         <eProf>0</eProf>
419
-        <aLa>0</aLa>
442
+        <aLa>1</aLa>
420 443
         <aPa1>0</aPa1>
421 444
         <AscS4>0</AscS4>
422 445
         <aSer4>0</aSer4>
@@ -438,6 +461,13 @@
438 461
       <pszMrulep></pszMrulep>
439 462
       <pSingCmdsp></pSingCmdsp>
440 463
       <pMultCmdsp></pMultCmdsp>
464
+      <LogicAnalyzers>
465
+        <Wi>
466
+          <IntNumber>0</IntNumber>
467
+          <FirstString>((PORTB &amp; 0x00000100) &gt;&gt; 8 &amp; 0x100) &gt;&gt; 8</FirstString>
468
+          <SecondString>FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028504F5254422026203078303030303031303029203E3E2038000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1400000000000000000000000000000000000000AE110008</SecondString>
469
+        </Wi>
470
+      </LogicAnalyzers>
441 471
       <DebugDescription>
442 472
         <Enable>1</Enable>
443 473
         <EnableFlashSeq>0</EnableFlashSeq>
@@ -618,6 +648,18 @@
618 648
       <RteFlg>0</RteFlg>
619 649
       <bShared>0</bShared>
620 650
     </File>
651
+    <File>
652
+      <GroupNumber>2</GroupNumber>
653
+      <FileNumber>14</FileNumber>
654
+      <FileType>1</FileType>
655
+      <tvExp>0</tvExp>
656
+      <tvExpOptDlg>0</tvExpOptDlg>
657
+      <bDave2>0</bDave2>
658
+      <PathWithFileName>..\Services\Scheduler.c</PathWithFileName>
659
+      <FilenameWithoutPath>Scheduler.c</FilenameWithoutPath>
660
+      <RteFlg>0</RteFlg>
661
+      <bShared>0</bShared>
662
+    </File>
621 663
   </Group>
622 664
 
623 665
   <Group>
@@ -628,7 +670,7 @@
628 670
     <RteFlg>0</RteFlg>
629 671
     <File>
630 672
       <GroupNumber>3</GroupNumber>
631
-      <FileNumber>14</FileNumber>
673
+      <FileNumber>15</FileNumber>
632 674
       <FileType>1</FileType>
633 675
       <tvExp>0</tvExp>
634 676
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -640,7 +682,7 @@
640 682
     </File>
641 683
     <File>
642 684
       <GroupNumber>3</GroupNumber>
643
-      <FileNumber>15</FileNumber>
685
+      <FileNumber>16</FileNumber>
644 686
       <FileType>1</FileType>
645 687
       <tvExp>0</tvExp>
646 688
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -652,7 +694,7 @@
652 694
     </File>
653 695
     <File>
654 696
       <GroupNumber>3</GroupNumber>
655
-      <FileNumber>16</FileNumber>
697
+      <FileNumber>17</FileNumber>
656 698
       <FileType>1</FileType>
657 699
       <tvExp>0</tvExp>
658 700
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -664,7 +706,7 @@
664 706
     </File>
665 707
     <File>
666 708
       <GroupNumber>3</GroupNumber>
667
-      <FileNumber>17</FileNumber>
709
+      <FileNumber>18</FileNumber>
668 710
       <FileType>1</FileType>
669 711
       <tvExp>0</tvExp>
670 712
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -684,7 +726,7 @@
684 726
     <RteFlg>0</RteFlg>
685 727
     <File>
686 728
       <GroupNumber>4</GroupNumber>
687
-      <FileNumber>18</FileNumber>
729
+      <FileNumber>19</FileNumber>
688 730
       <FileType>1</FileType>
689 731
       <tvExp>0</tvExp>
690 732
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -696,7 +738,7 @@
696 738
     </File>
697 739
     <File>
698 740
       <GroupNumber>4</GroupNumber>
699
-      <FileNumber>19</FileNumber>
741
+      <FileNumber>20</FileNumber>
700 742
       <FileType>1</FileType>
701 743
       <tvExp>0</tvExp>
702 744
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -708,7 +750,7 @@
708 750
     </File>
709 751
     <File>
710 752
       <GroupNumber>4</GroupNumber>
711
-      <FileNumber>20</FileNumber>
753
+      <FileNumber>21</FileNumber>
712 754
       <FileType>1</FileType>
713 755
       <tvExp>0</tvExp>
714 756
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -718,17 +760,29 @@
718 760
       <RteFlg>0</RteFlg>
719 761
       <bShared>0</bShared>
720 762
     </File>
763
+    <File>
764
+      <GroupNumber>4</GroupNumber>
765
+      <FileNumber>22</FileNumber>
766
+      <FileType>1</FileType>
767
+      <tvExp>0</tvExp>
768
+      <tvExpOptDlg>0</tvExpOptDlg>
769
+      <bDave2>0</bDave2>
770
+      <PathWithFileName>..\LLDrivers\src\stm32f1xx_ll_gpio.c</PathWithFileName>
771
+      <FilenameWithoutPath>stm32f1xx_ll_gpio.c</FilenameWithoutPath>
772
+      <RteFlg>0</RteFlg>
773
+      <bShared>0</bShared>
774
+    </File>
721 775
   </Group>
722 776
 
723 777
   <Group>
724 778
     <GroupName>Doc</GroupName>
725
-    <tvExp>1</tvExp>
779
+    <tvExp>0</tvExp>
726 780
     <tvExpOptDlg>0</tvExpOptDlg>
727 781
     <cbSel>0</cbSel>
728 782
     <RteFlg>0</RteFlg>
729 783
     <File>
730 784
       <GroupNumber>5</GroupNumber>
731
-      <FileNumber>21</FileNumber>
785
+      <FileNumber>23</FileNumber>
732 786
       <FileType>5</FileType>
733 787
       <tvExp>0</tvExp>
734 788
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -742,13 +796,13 @@
742 796
 
743 797
   <Group>
744 798
     <GroupName>Drivers/CMSIS</GroupName>
745
-    <tvExp>0</tvExp>
799
+    <tvExp>1</tvExp>
746 800
     <tvExpOptDlg>0</tvExpOptDlg>
747 801
     <cbSel>0</cbSel>
748 802
     <RteFlg>0</RteFlg>
749 803
     <File>
750 804
       <GroupNumber>6</GroupNumber>
751
-      <FileNumber>22</FileNumber>
805
+      <FileNumber>24</FileNumber>
752 806
       <FileType>1</FileType>
753 807
       <tvExp>0</tvExp>
754 808
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -768,7 +822,7 @@
768 822
     <RteFlg>0</RteFlg>
769 823
     <File>
770 824
       <GroupNumber>7</GroupNumber>
771
-      <FileNumber>23</FileNumber>
825
+      <FileNumber>25</FileNumber>
772 826
       <FileType>2</FileType>
773 827
       <tvExp>0</tvExp>
774 828
       <tvExpOptDlg>0</tvExpOptDlg>

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

@@ -453,6 +453,11 @@
453 453
               <FileType>1</FileType>
454 454
               <FilePath>..\Services\Voltage.c</FilePath>
455 455
             </File>
456
+            <File>
457
+              <FileName>Scheduler.c</FileName>
458
+              <FileType>1</FileType>
459
+              <FilePath>..\Services\Scheduler.c</FilePath>
460
+            </File>
456 461
           </Files>
457 462
         </Group>
458 463
         <Group>
@@ -498,6 +503,11 @@
498 503
               <FileType>1</FileType>
499 504
               <FilePath>..\LLDrivers\src\stm32f1xx_ll_tim.c</FilePath>
500 505
             </File>
506
+            <File>
507
+              <FileName>stm32f1xx_ll_gpio.c</FileName>
508
+              <FileType>1</FileType>
509
+              <FilePath>..\LLDrivers\src\stm32f1xx_ll_gpio.c</FilePath>
510
+            </File>
501 511
           </Files>
502 512
         </Group>
503 513
         <Group>
@@ -982,6 +992,11 @@
982 992
               <FileType>1</FileType>
983 993
               <FilePath>..\Services\Voltage.c</FilePath>
984 994
             </File>
995
+            <File>
996
+              <FileName>Scheduler.c</FileName>
997
+              <FileType>1</FileType>
998
+              <FilePath>..\Services\Scheduler.c</FilePath>
999
+            </File>
985 1000
           </Files>
986 1001
         </Group>
987 1002
         <Group>
@@ -1027,6 +1042,11 @@
1027 1042
               <FileType>1</FileType>
1028 1043
               <FilePath>..\LLDrivers\src\stm32f1xx_ll_tim.c</FilePath>
1029 1044
             </File>
1045
+            <File>
1046
+              <FileName>stm32f1xx_ll_gpio.c</FileName>
1047
+              <FileType>1</FileType>
1048
+              <FilePath>..\LLDrivers\src\stm32f1xx_ll_gpio.c</FilePath>
1049
+            </File>
1030 1050
           </Files>
1031 1051
         </Group>
1032 1052
         <Group>

+ 51
- 0
MyDrivers/ADC.c View File

@@ -1 +1,52 @@
1 1
 #include "ADC.h"
2
+#include "stm32f1xx_ll_bus.h" 	// Pour horloge
3
+
4
+void ADC_conf(ADC_TypeDef *adc, uint32_t voie) 
5
+{
6
+	if (adc == ADC1) {
7
+		LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
8
+	} else if (adc == ADC2) {
9
+		LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC2);
10
+	}
11
+	
12
+	// Division de la frequence
13
+	RCC->CFGR |= RCC_CFGR_ADCPRE_DIV6;
14
+	
15
+	// Fixe le nombre de conversion à 1
16
+	adc->SQR1&= ADC_SQR1_L; 
17
+	
18
+	// Indique la voie a convertir
19
+	adc->SQR3|= voie; 
20
+	
21
+	 // Calibration
22
+	adc->CR2 |= ADC_CR2_CAL_Msk;
23
+	while ((adc->CR2 & ADC_CR2_CAL_Msk));	
24
+}
25
+
26
+
27
+void ADC_start(ADC_TypeDef *adc)
28
+{
29
+	adc->CR2 |= ADC_CR2_ADON;
30
+}
31
+
32
+
33
+uint16_t ADC_readRaw(ADC_TypeDef *adc)
34
+{
35
+		// Lancement de la conversion
36
+	  adc->CR2 |= ADC_CR2_ADON; 
37
+    while(!(ADC1->SR & ADC_SR_EOC)) {}
38
+			
39
+    return ADC1->DR & ADC_DR_DATA_Msk;
40
+}
41
+
42
+
43
+double ADC_convertToVolt(uint16_t value)
44
+{
45
+	return ((double) value) / 4095.0 * 3.3;
46
+}
47
+
48
+
49
+double ADC_readVolt(ADC_TypeDef *adc)
50
+{
51
+	return ADC_convertToVolt(ADC_readRaw(adc));
52
+}

+ 11
- 0
MyDrivers/ADC.h View File

@@ -1,4 +1,15 @@
1 1
 #ifndef ADC_H
2 2
 #define ADC_H
3 3
 
4
+#include "stm32f1xx_ll_adc.h"
5
+
6
+void ADC_conf(ADC_TypeDef *adc, uint32_t voie);
7
+void ADC_start(ADC_TypeDef *adc);
8
+
9
+uint16_t ADC_readRaw(ADC_TypeDef *adc);
10
+double ADC_readVolt(ADC_TypeDef *adc);
11
+
12
+double ADC_convertToVolt(uint16_t value);
13
+
14
+
4 15
 #endif

+ 1
- 1
MyDrivers/Timer.c View File

@@ -173,7 +173,7 @@ void Timer_conf(TIM_TypeDef * timer, int arr, int psc)
173 173
 
174 174
 int getArrFromFreq(float freq)
175 175
 {
176
-	return (72000000 / freq) - 1;
176
+	return (72000 / freq) - 1;
177 177
 }
178 178
 
179 179
 void Timer_pwmo_conf(TIM_TypeDef * timer, int channel, float freq, float dutyCycle)

+ 57
- 0
MyDrivers/USART.c View File

@@ -1 +1,58 @@
1 1
 #include "USART.h" 
2
+#include "GPIO.h"
3
+#include "stm32f1xx_ll_bus.h" 	// Pour horloge
4
+
5
+
6
+void Usart_conf(USART_TypeDef *USARTx) {
7
+	int txPin;
8
+	GPIO_TypeDef *usartGpio;
9
+	
10
+	if (USARTx == USART1) {
11
+		LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
12
+		LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
13
+		txPin = LL_GPIO_PIN_9;
14
+		usartGpio = GPIOA;
15
+	} else if (USARTx == USART2) {
16
+		LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2);
17
+		LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
18
+		txPin = LL_GPIO_PIN_2;
19
+		usartGpio = GPIOA;
20
+	} else if (USARTx == USART3) {
21
+		LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART3);
22
+		LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
23
+		txPin = LL_GPIO_PIN_10;	
24
+		usartGpio = GPIOB;
25
+	}	
26
+	
27
+	LL_USART_InitTypeDef usartInit;
28
+	LL_USART_StructInit(&usartInit);
29
+	usartInit.DataWidth = LL_USART_DATAWIDTH_8B;
30
+	usartInit.BaudRate = 9600;
31
+	usartInit.TransferDirection = LL_USART_DIRECTION_TX_RX;
32
+	LL_USART_Init(USARTx, &usartInit);
33
+	
34
+	GPIO_conf(usartGpio, txPin, LL_GPIO_MODE_ALTERNATE, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_UP);
35
+}
36
+
37
+
38
+
39
+void Usart_enable(USART_TypeDef *USARTx) {
40
+		LL_USART_Enable(USARTx);
41
+}
42
+
43
+
44
+void sendChar(USART_TypeDef *USARTx, char c) {
45
+	LL_USART_TransmitData8(USARTx, c);
46
+	while (!LL_USART_IsActiveFlag_TXE(USARTx)) {}
47
+}
48
+
49
+
50
+void Usart_send(USART_TypeDef *USARTx, char *msg, int length) {
51
+	for (int i = 0; i < length; i++) {
52
+		sendChar(USARTx, msg[i]);
53
+	}
54
+}
55
+
56
+
57
+
58
+

+ 5
- 0
MyDrivers/USART.h View File

@@ -1,5 +1,10 @@
1 1
 #ifndef USART_H
2 2
 #define USART_H
3 3
 
4
+#include "stm32f1xx_ll_usart.h"
5
+
6
+void Usart_conf(USART_TypeDef *USARTx);
7
+void Usart_enable(USART_TypeDef *USARTx);
8
+void Usart_send(USART_TypeDef *USARTx, char *msg, int length);
4 9
 
5 10
 #endif

+ 3
- 2
Services/IncrementalEncoder.c View File

@@ -1,11 +1,12 @@
1 1
 #include "IncrementalEncoder.h"
2 2
 
3 3
 #include "Timer.h"
4
+#include "GPIO.h"
4 5
 
5
-void IncrementalEncoder_conf(TIM_TypeDef * timer)
6
+void IncrementalEncoder_conf(TIM_TypeDef * timer, GPIO_TypeDef * gpio, int pin)
6 7
 {
7 8
 	Timer_encoder_conf(timer);
8
-	// TODO GPIO config
9
+	GPIO_conf(gpio, pin, LL_GPIO_MODE_INPUT, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_UP);
9 10
 }
10 11
 
11 12
 void IncrementalEncoder_start(TIM_TypeDef * timer)

+ 1
- 1
Services/IncrementalEncoder.h View File

@@ -9,7 +9,7 @@
9 9
 	* @param  TIM_TypeDef Timer : indique le timer à utiliser : TIM1, TIM2, TIM3 ou TIM4
10 10
   * @retval None
11 11
   */
12
-void IncrementalEncoder_conf(TIM_TypeDef * timer);
12
+void IncrementalEncoder_conf(TIM_TypeDef * timer, GPIO_TypeDef * gpio, int pin);
13 13
 
14 14
 /**
15 15
 	* @brief  Démarre le codeur incrémental associé au timer donné

+ 23
- 0
Services/Scheduler.c View File

@@ -0,0 +1,23 @@
1
+#include "Scheduler.h"
2
+#include "Timer.h"
3
+#include "stm32f1xx_ll_utils.h"
4
+
5
+void (*it_callback_SysTick)(void); 
6
+
7
+void SysTick_Handler(void)
8
+{
9
+	(*it_callback_SysTick)();
10
+}	
11
+
12
+void Scheduler_conf(void (*it_callback) (void))
13
+{
14
+	it_callback_SysTick = it_callback;
15
+	SysTick->CTRL &= ~(SysTick_CTRL_CLKSOURCE_Msk);
16
+	SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
17
+	SysTick->LOAD = 9000;
18
+}
19
+
20
+void Scheduler_start(void)
21
+{
22
+	SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
23
+}

+ 22
- 0
Services/Scheduler.h View File

@@ -0,0 +1,22 @@
1
+#ifndef SCHEDULER_H
2
+#define SCHEDULER_H
3
+
4
+#include "stm32f103xb.h" 
5
+
6
+/**
7
+	* @brief  Configure l'horloge interne comme ordonanceur toutes les 1ms
8
+  * @note   
9
+	* @param  (void)* it_callback : Tache de fond à executer
10
+  * @retval None
11
+  */
12
+void Scheduler_conf(void (*it_callback) (void));
13
+
14
+/**
15
+	* @brief  Démarre ordonanceur
16
+  * @note   
17
+	* @param  None
18
+  * @retval None
19
+  */
20
+void Scheduler_start(void);
21
+
22
+#endif

+ 3
- 3
Services/ServoMotor.c View File

@@ -1,11 +1,11 @@
1 1
 #include "ServoMotor.h"
2
-#include "Timer.h"
3 2
 
4 3
 #define SERVO_MOTO_FREQ 50
5 4
 
6
-void ServoMotor_conf(TIM_TypeDef * timer, int channel)
5
+void ServoMotor_conf(TIM_TypeDef * timer, int channel, GPIO_TypeDef * gpio, int pin)
7 6
 {
8
-	Timer_pwmo_conf(timer, channel, SERVO_MOTO_FREQ, 0);
7
+	Timer_pwmo_conf(timer, channel, SERVO_MOTO_FREQ, 0.5);
8
+	GPIO_conf(gpio, pin, LL_GPIO_MODE_ALTERNATE, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_UP);
9 9
 }
10 10
 
11 11
 void ServoMotor_start(TIM_TypeDef * timer)

+ 5
- 1
Services/ServoMotor.h View File

@@ -2,15 +2,19 @@
2 2
 #define SERVO_MOTOR_H
3 3
 
4 4
 #include "stm32f103xb.h"
5
+#include "Timer.h"
6
+#include "GPIO.h"
5 7
 
6 8
 /**
7 9
 	* @brief  Configure le servo moteur associé au timer donné
8 10
   * @note   
9 11
 	* @param  TIM_TypeDef Timer : indique le timer à utiliser : TIM1, TIM2, TIM3 ou TIM4
10 12
 	*					int channel 			: Le channel utilisé par le servo moteur
13
+	*					GPIO_TypeDef gpio : Le GPIO à utiliser pour la sortie de la PWM
14
+	*					int pin     			: Le PIN associé au GPIO
11 15
   * @retval None
12 16
   */
13
-void ServoMotor_conf(TIM_TypeDef * timer, int channel);
17
+void ServoMotor_conf(TIM_TypeDef * timer, int channel, GPIO_TypeDef * gpio, int pin);
14 18
 
15 19
 /**
16 20
 	* @brief  Démarre les servo moteurs associés au timer donné

+ 34
- 0
Src/Sail.c View File

@@ -1 +1,35 @@
1 1
 #include "Sail.h"
2
+#include "ServoMotor.h"
3
+#include "IncrementalEncoder.h"
4
+
5
+TIM_TypeDef * MOTOR_TIMER = TIM4;
6
+const int MOTOR_CHANNEL = LL_TIM_CHANNEL_CH3;
7
+GPIO_TypeDef * MOTOR_GPIO = GPIOB;
8
+const int MOTOR_PIN = LL_GPIO_PIN_8;
9
+
10
+TIM_TypeDef * ENCODER_TIMER = TIM3;
11
+GPIO_TypeDef * ENCODER_GPIO = GPIOA;
12
+const int ENCODER_PIN = LL_GPIO_PIN_5;
13
+
14
+void Sail_conf()
15
+{
16
+	ServoMotor_conf(MOTOR_TIMER, MOTOR_CHANNEL, MOTOR_GPIO, MOTOR_PIN);
17
+	IncrementalEncoder_conf(ENCODER_TIMER, ENCODER_GPIO, ENCODER_PIN);
18
+}
19
+
20
+void Sail_background()
21
+{
22
+	
23
+}
24
+
25
+void Sail_reset()
26
+{
27
+	
28
+}
29
+
30
+
31
+void Sail_start()
32
+{
33
+	Timer_start(MOTOR_TIMER);
34
+	Timer_start(ENCODER_TIMER);
35
+}

+ 4
- 4
Src/Sail.h View File

@@ -7,7 +7,7 @@
7 7
 	* @param  None
8 8
   * @retval None
9 9
   */
10
-void Sail_conf();
10
+void Sail_conf(void);
11 11
 
12 12
 /**
13 13
 	* @brief  Execute la tache de fond des voiles en fonction des valeurs récupérées par les drivers
@@ -15,7 +15,7 @@ void Sail_conf();
15 15
 	* @param  None
16 16
   * @retval None
17 17
   */
18
-void Sail_background();
18
+void Sail_background(void);
19 19
 
20 20
 /**
21 21
 	* @brief  Mets la voile à 90 degres
@@ -23,7 +23,7 @@ void Sail_background();
23 23
 	* @param  None
24 24
   * @retval None
25 25
   */
26
-void Sail_reset();
26
+void Sail_reset(void);
27 27
 
28 28
 /**
29 29
 	* @brief  Réinitialise la voile à sa position initiale
@@ -31,6 +31,6 @@ void Sail_reset();
31 31
 	* @param  None
32 32
   * @retval None
33 33
   */
34
-void Sail_start();
34
+void Sail_start(void);
35 35
 
36 36
 #endif

+ 37
- 10
Src/main.c View File

@@ -20,20 +20,45 @@
20 20
 #include "stm32f1xx_ll_utils.h"   // utile dans la fonction SystemClock_Config
21 21
 #include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
22 22
 
23
-#include "Chrono.h"
23
+#include "Sail.h"
24
+#include "Scheduler.h"
25
+#include "ADC.h"
26
+#include "GPIO.h"
24 27
 
25 28
 void  SystemClock_Config(void);
26 29
 
27 30
 /* Private functions ---------------------------------------------------------*/
28 31
 
32
+int counter = 1;
33
+int adcRaw = 0;
34
+double adcVolt = 0.0;
35
+
36
+void backgroundTask()
37
+{
38
+	counter++;
39
+	Sail_background();
40
+	adcRaw = ADC_readRaw(ADC1);
41
+	adcVolt = ADC_convertToVolt(adcRaw);
42
+}
43
+
44
+
45
+void configurePeripherals()
46
+{
47
+	Sail_conf();
48
+	ADC_conf(ADC1, 12);
49
+}
50
+
51
+void startPeripherals()
52
+{
53
+	Sail_start();
54
+	ADC_start(ADC1);
55
+}
56
+
29 57
 /**
30 58
   * @brief  Main program
31 59
   * @param  None
32 60
   * @retval None
33 61
   */
34
-	
35
-Time * time;
36
-
37 62
 int main(void)
38 63
 {
39 64
   /* Configure the system clock to 72 MHz */
@@ -41,14 +66,16 @@ int main(void)
41 66
 
42 67
   /* Add your application code here */
43 68
   // Configuration chronomètre
44
-	Chrono_Conf(TIM3);
45
-	
69
+	// Chrono_Conf(TIM3);
46 70
 	// Lancement chronomètre
47
-	Chrono_Start(); 
71
+	// Chrono_Start(); 
72
+	// time = Chrono_Read();
73
+  configurePeripherals();
74
+	startPeripherals();
48 75
 	
49
-	time = Chrono_Read();
50
-  
51
-  /* Infinite loop */
76
+	Scheduler_conf(backgroundTask);
77
+	Scheduler_start();
78
+
52 79
   while (1)
53 80
   {
54 81
   }

Loading…
Cancel
Save