Browse Source

Merge branch 'Moteur' into develop

Neluji 3 years ago
parent
commit
7c30feb7fa
7 changed files with 178 additions and 82 deletions
  1. 49
    20
      MDK-ARM/Project.uvoptx
  2. 14
    0
      MDK-ARM/Project.uvprojx
  3. 3
    4
      MyDrivers/MyPWM.h
  4. 80
    0
      Services/Moteur.c
  5. 18
    0
      Services/Moteur.h
  6. 0
    1
      Services/services.txt
  7. 14
    57
      Src/main.c

+ 49
- 20
MDK-ARM/Project.uvoptx View File

@@ -305,7 +305,7 @@
305 305
         <sDllPa></sDllPa>
306 306
         <sDlgDll></sDlgDll>
307 307
         <sDlgPa></sDlgPa>
308
-        <sIfile>..\..\inifiles\Simu_Pulse.ini</sIfile>
308
+        <sIfile></sIfile>
309 309
         <tDll></tDll>
310 310
         <tDllPa></tDllPa>
311 311
         <tDlgDll></tDlgDll>
@@ -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=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)</Name>
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=864,64,1285,491,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=736,17,1330,768,0)(132=599,17,1193,768,0)(133=295,17,889,768,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>
321 321
         </SetRegEntry>
322 322
         <SetRegEntry>
323 323
           <Number>0</Number>
@@ -350,7 +350,24 @@
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>25</LineNumber>
358
+          <EnabledFlag>1</EnabledFlag>
359
+          <Address>134219120</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\Services\Moteur.c</Filename>
367
+          <ExecCommand></ExecCommand>
368
+          <Expression>\\NUCLEO_F103RB\../Services/Moteur.c\25</Expression>
369
+        </Bp>
370
+      </Breakpoint>
354 371
       <WatchWindow1>
355 372
         <Ww>
356 373
           <count>0</count>
@@ -362,7 +379,7 @@
362 379
         <Mm>
363 380
           <WinNumber>1</WinNumber>
364 381
           <SubType>0</SubType>
365
-          <ItemText>porta</ItemText>
382
+          <ItemText>My_GPIO_Init_Struct</ItemText>
366 383
           <AccSizeX>0</AccSizeX>
367 384
         </Mm>
368 385
       </MemoryWindow1>
@@ -411,13 +428,13 @@
411 428
       <LogicAnalyzers>
412 429
         <Wi>
413 430
           <IntNumber>0</IntNumber>
414
-          <FirstString>((portb &amp; 0x00000040) &gt;&gt; 6 &amp; 0x40) &gt;&gt; 6</FirstString>
415
-          <SecondString>00008000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274622026203078303030303030343029203E3E2036000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F0D00000000000000000000000000000000000000440E0008</SecondString>
431
+          <FirstString>((porta &amp; 0x00000002) &gt;&gt; 1 &amp; 0x2) &gt;&gt; 1</FirstString>
432
+          <SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F0B00000000000000000000000000000000000000320F0008</SecondString>
416 433
         </Wi>
417 434
         <Wi>
418 435
           <IntNumber>1</IntNumber>
419
-          <FirstString>((portb &amp; 0x00000080) &gt;&gt; 7 &amp; 0x80) &gt;&gt; 7</FirstString>
420
-          <SecondString>00000000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274622026203078303030303030383029203E3E2037000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F0D00000000000000000000000000000000000000040E0008</SecondString>
436
+          <FirstString>((porta &amp; 0x00000004) &gt;&gt; 2 &amp; 0x4) &gt;&gt; 2</FirstString>
437
+          <SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303429203E3E2032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F0B00000000000000000000000000000000000000320F0008</SecondString>
421 438
         </Wi>
422 439
       </LogicAnalyzers>
423 440
       <DebugDescription>
@@ -456,6 +473,18 @@
456 473
     <tvExpOptDlg>0</tvExpOptDlg>
457 474
     <cbSel>0</cbSel>
458 475
     <RteFlg>0</RteFlg>
476
+    <File>
477
+      <GroupNumber>2</GroupNumber>
478
+      <FileNumber>2</FileNumber>
479
+      <FileType>1</FileType>
480
+      <tvExp>0</tvExp>
481
+      <tvExpOptDlg>0</tvExpOptDlg>
482
+      <bDave2>0</bDave2>
483
+      <PathWithFileName>..\Services\Moteur.c</PathWithFileName>
484
+      <FilenameWithoutPath>Moteur.c</FilenameWithoutPath>
485
+      <RteFlg>0</RteFlg>
486
+      <bShared>0</bShared>
487
+    </File>
459 488
   </Group>
460 489
 
461 490
   <Group>
@@ -466,9 +495,9 @@
466 495
     <RteFlg>0</RteFlg>
467 496
     <File>
468 497
       <GroupNumber>3</GroupNumber>
469
-      <FileNumber>2</FileNumber>
498
+      <FileNumber>3</FileNumber>
470 499
       <FileType>1</FileType>
471
-      <tvExp>1</tvExp>
500
+      <tvExp>0</tvExp>
472 501
       <tvExpOptDlg>0</tvExpOptDlg>
473 502
       <bDave2>0</bDave2>
474 503
       <PathWithFileName>..\MyDrivers\MyTimer.c</PathWithFileName>
@@ -478,9 +507,9 @@
478 507
     </File>
479 508
     <File>
480 509
       <GroupNumber>3</GroupNumber>
481
-      <FileNumber>3</FileNumber>
510
+      <FileNumber>4</FileNumber>
482 511
       <FileType>1</FileType>
483
-      <tvExp>1</tvExp>
512
+      <tvExp>0</tvExp>
484 513
       <tvExpOptDlg>0</tvExpOptDlg>
485 514
       <bDave2>0</bDave2>
486 515
       <PathWithFileName>..\MyDrivers\MyPWM.c</PathWithFileName>
@@ -498,7 +527,7 @@
498 527
     <RteFlg>0</RteFlg>
499 528
     <File>
500 529
       <GroupNumber>4</GroupNumber>
501
-      <FileNumber>4</FileNumber>
530
+      <FileNumber>5</FileNumber>
502 531
       <FileType>1</FileType>
503 532
       <tvExp>0</tvExp>
504 533
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -510,7 +539,7 @@
510 539
     </File>
511 540
     <File>
512 541
       <GroupNumber>4</GroupNumber>
513
-      <FileNumber>5</FileNumber>
542
+      <FileNumber>6</FileNumber>
514 543
       <FileType>1</FileType>
515 544
       <tvExp>0</tvExp>
516 545
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -522,7 +551,7 @@
522 551
     </File>
523 552
     <File>
524 553
       <GroupNumber>4</GroupNumber>
525
-      <FileNumber>6</FileNumber>
554
+      <FileNumber>7</FileNumber>
526 555
       <FileType>1</FileType>
527 556
       <tvExp>0</tvExp>
528 557
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -534,7 +563,7 @@
534 563
     </File>
535 564
     <File>
536 565
       <GroupNumber>4</GroupNumber>
537
-      <FileNumber>7</FileNumber>
566
+      <FileNumber>8</FileNumber>
538 567
       <FileType>1</FileType>
539 568
       <tvExp>0</tvExp>
540 569
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -546,7 +575,7 @@
546 575
     </File>
547 576
     <File>
548 577
       <GroupNumber>4</GroupNumber>
549
-      <FileNumber>8</FileNumber>
578
+      <FileNumber>9</FileNumber>
550 579
       <FileType>1</FileType>
551 580
       <tvExp>0</tvExp>
552 581
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -566,7 +595,7 @@
566 595
     <RteFlg>0</RteFlg>
567 596
     <File>
568 597
       <GroupNumber>5</GroupNumber>
569
-      <FileNumber>9</FileNumber>
598
+      <FileNumber>10</FileNumber>
570 599
       <FileType>5</FileType>
571 600
       <tvExp>0</tvExp>
572 601
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -586,7 +615,7 @@
586 615
     <RteFlg>0</RteFlg>
587 616
     <File>
588 617
       <GroupNumber>6</GroupNumber>
589
-      <FileNumber>10</FileNumber>
618
+      <FileNumber>11</FileNumber>
590 619
       <FileType>1</FileType>
591 620
       <tvExp>0</tvExp>
592 621
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -606,7 +635,7 @@
606 635
     <RteFlg>0</RteFlg>
607 636
     <File>
608 637
       <GroupNumber>7</GroupNumber>
609
-      <FileNumber>11</FileNumber>
638
+      <FileNumber>12</FileNumber>
610 639
       <FileType>2</FileType>
611 640
       <tvExp>0</tvExp>
612 641
       <tvExpOptDlg>0</tvExpOptDlg>

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

@@ -391,6 +391,13 @@
391 391
         </Group>
392 392
         <Group>
393 393
           <GroupName>User Services</GroupName>
394
+          <Files>
395
+            <File>
396
+              <FileName>Moteur.c</FileName>
397
+              <FileType>1</FileType>
398
+              <FilePath>..\Services\Moteur.c</FilePath>
399
+            </File>
400
+          </Files>
394 401
         </Group>
395 402
         <Group>
396 403
           <GroupName>MyDrivers</GroupName>
@@ -857,6 +864,13 @@
857 864
         </Group>
858 865
         <Group>
859 866
           <GroupName>User Services</GroupName>
867
+          <Files>
868
+            <File>
869
+              <FileName>Moteur.c</FileName>
870
+              <FileType>1</FileType>
871
+              <FilePath>..\Services\Moteur.c</FilePath>
872
+            </File>
873
+          </Files>
860 874
         </Group>
861 875
         <Group>
862 876
           <GroupName>MyDrivers</GroupName>

+ 3
- 4
MyDrivers/MyPWM.h View File

@@ -1,8 +1,7 @@
1
-#ifndef MYPWM_H
2
-#define MYPWM_H
1
+#ifndef PWM_H
2
+#define PWM_H
3 3
 
4
-#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
5
-#include "stm32f1xx_ll_tim.h"
4
+#include "stm32f103xb.h"
6 5
 
7 6
 
8 7
 void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel);

+ 80
- 0
Services/Moteur.c View File

@@ -0,0 +1,80 @@
1
+
2
+#include "Moteur.h"
3
+#include "MyPWM.h"
4
+#include "MyTimer.h"
5
+
6
+#include "stm32f1xx_ll_bus.h"
7
+#include "stm32f1xx_ll_gpio.h"
8
+#include "stm32f1xx_ll_tim.h"
9
+
10
+
11
+void Moteur_Conf(void) {
12
+	
13
+	//Fpwm = 10kHz = 72Mhz/(7200 = 0x1C20)
14
+	int Arr = 0x1C1F;
15
+	int Psc = 0x0;
16
+	
17
+	//Activation horloge GPIO
18
+	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
19
+	
20
+	//Config broche PA2 -> Sens
21
+	LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
22
+	
23
+	LL_GPIO_StructInit(&My_GPIO_Init_Struct);
24
+	
25
+	My_GPIO_Init_Struct.Pin = PinSens;
26
+	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
27
+	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
28
+	
29
+	LL_GPIO_Init(GPIOPins, &My_GPIO_Init_Struct);
30
+	
31
+	//Config broche PA1 -> PWM
32
+	LL_GPIO_StructInit(&My_GPIO_Init_Struct);
33
+	
34
+	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_1;
35
+	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
36
+	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
37
+	
38
+	LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
39
+	
40
+	
41
+	
42
+	//Activation horloge Timer
43
+	LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
44
+	
45
+	//Configuration initiale du Timer
46
+	MyTimer_Conf(TimerPWM, Arr, Psc);
47
+	//Configuration du Timer en PWM Output
48
+	MyPWM_Conf_Output(TimerPWM, channelPWM);
49
+	
50
+	Moteur_Speed(0);
51
+	Moteur_Sens(0);
52
+	
53
+}
54
+
55
+
56
+
57
+void Moteur_Speed(int speedPercentage) {
58
+	int Arr = 0x1C1F;
59
+	
60
+	if(speedPercentage == 0) {
61
+		MyTimer_Stop(TimerPWM);
62
+	}
63
+	else {
64
+		MyTimer_Start(TimerPWM);
65
+		MyPWM_Set_Impulse_Duration(TimerPWM, Arr*speedPercentage/100, channelPWM);
66
+	}
67
+	
68
+}
69
+
70
+
71
+void Moteur_Sens(int sens) {
72
+	
73
+	if(sens == 0) {
74
+		LL_GPIO_ResetOutputPin(GPIOPins, PinSens);
75
+	}
76
+	else {
77
+		LL_GPIO_SetOutputPin(GPIOPins, PinSens);
78
+	}
79
+	
80
+}

+ 18
- 0
Services/Moteur.h View File

@@ -0,0 +1,18 @@
1
+#ifndef MOTEUR_H
2
+#define MOTEUR_H
3
+
4
+#include "stm32f103xb.h" 
5
+
6
+#define PinSens LL_GPIO_PIN_2
7
+#define PinPWM LL_GPIO_PIN_1
8
+#define GPIOPins GPIOA
9
+#define TimerPWM TIM2
10
+#define channelPWM LL_TIM_CHANNEL_CH2
11
+
12
+void Moteur_Conf(void);
13
+
14
+void Moteur_Speed(int speedPercentage);
15
+
16
+void Moteur_Sens(int sens);
17
+
18
+#endif

+ 0
- 1
Services/services.txt View File

@@ -1 +0,0 @@
1
-Mettre les services ici

+ 14
- 57
Src/main.c View File

@@ -22,6 +22,7 @@
22 22
 #include "stm32f1xx_ll_gpio.h"
23 23
 #include "MyTimer.h"
24 24
 #include "MyPWM.h"
25
+#include "Moteur.h"
25 26
 
26 27
 void  SystemClock_Config(void);
27 28
 
@@ -39,69 +40,25 @@ int main(void)
39 40
   /* Configure the system clock to 72 MHz */
40 41
   SystemClock_Config();
41 42
 	
43
+	/*===Test Moteur===*/
42 44
 	
43
-	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
44
-	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
45
-	LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
45
+	//INIT GPIO MARCHE PAS->PB PIN
46
+	Moteur_Conf();
46 47
 	
47
-	/*===Test Output===*/
48
-	
49
-//	TIM_TypeDef *Timer1 = TIM3;
50
-//	int Channel1 = LL_TIM_CHANNEL_CH2;
51
-//	TIM_TypeDef *Timer2 = TIM4;
52
-//	int Channel2 = LL_TIM_CHANNEL_CH4;
53
-//	
54
-//	MyTimer_Conf(Timer1,0xFFFE, 0x72);
55
-//	MyTimer_Conf(Timer2,0xFFFE, 0x72);
56
-//	
57
-//	MyPWM_Conf_Output(Timer1, Channel1);
58
-//	MyPWM_Conf_Output(Timer2, Channel2);
59
-//	
60
-//	MyPWM_Set_Impulse_Duration(Timer1, 25, Channel1);
61
-//	MyPWM_Set_Impulse_Duration(Timer2, 75, Channel2);
62
-//	
63
-//	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_7;
64
-//	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
65
-//	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
66
-//	My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_2MHz;
67
-//	My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
68
-//	LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
69
-//	
70
-//	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_9;
71
-//	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
72
-//	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
73
-//	My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_2MHz;
74
-//	My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
75
-//	LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
76
-//	
77
-//	MyTimer_Start(Timer1);
78
-//	MyTimer_Start(Timer2);
79
-	
80
-	/*===Test Input===*/
81
-	
82
-	TIM_TypeDef *Timer = TIM4;
83
-	int channel1 = LL_TIM_CHANNEL_CH1;
84
-	int channel2 = LL_TIM_CHANNEL_CH2;
85
-	
86
-	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_6;
87
-	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_FLOATING;
88
-	My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
89
-	LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
90
-
91
-	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_7;
92
-	LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
93
-	
94
-	MyTimer_Conf(Timer,0xFFAD,0x15);
95
-	
96
-	MyPWM_Conf_Input(Timer, channel1, channel2);
97
-	
98
-	int duty_cycle = 0;
48
+	Moteur_Speed(30);
49
+	Moteur_Sens(0);
99 50
   
100 51
   /* Infinite loop */
101
-  while (1)
52
+  for (int i =0; i<0xFFFF; i++)
102 53
   {
103
-		duty_cycle = MyPWM_Duty_Cycle_Permilles(Timer, channel1, channel2);
104 54
   }
55
+	
56
+	Moteur_Speed(60);
57
+	Moteur_Sens(1);
58
+	
59
+	while (1)
60
+	{
61
+	}
105 62
 }
106 63
 
107 64
 

Loading…
Cancel
Save