Compare commits

...

31 commits

Author SHA1 Message Date
Neluji
b61941fe41 Zi projet iz finich 2020-11-24 22:56:56 +01:00
Neluji
ebda31ee03 Comment. + début mise en commun (GPIO) 2020-11-24 19:52:32 +01:00
Neluji
fc622094a9 Merge branch 'Sequencer' into develop 2020-11-24 11:07:09 +01:00
Neluji
35c3561ad9 Basic fonct 2020-11-24 11:06:42 +01:00
Neluji
45bc1d4b7d Merge branch 'SysTick' into develop
# Conflicts:
#	MDK-ARM/Project.uvoptx
#	MDK-ARM/Project.uvprojx
#	Src/main.c
2020-11-24 10:31:43 +01:00
Neluji
1fcc556499 Merge branch 'RF' into develop 2020-11-24 10:29:00 +01:00
Neluji
830ccb8cb7 Basic fonct. 2020-11-24 10:27:53 +01:00
Neluji
d91e0bc8ed Ajout activation/desact. module RF (PA.11) 2020-11-24 08:59:39 +01:00
Neluji
5723b95405 ajout de seuils sur Duty_Cycle 2020-11-24 08:15:55 +01:00
Neluji
27c8c1a005 Transmission : conf et foncts 2020-11-23 22:12:28 +01:00
Neluji
b8e0d2bcd8 Merge branch 'develop' into RF
# Conflicts:
#	MDK-ARM/Project.uvoptx
#	MDK-ARM/Project.uvprojx
#	Src/main.c
2020-11-23 18:55:34 +01:00
Neluji
d6cedd7e09 Merge branch 'USART' into develop
# Conflicts:
#	MDK-ARM/Project.uvoptx
#	MDK-ARM/Project.uvprojx
2020-11-23 18:53:38 +01:00
Neluji
1556c5145f Configuration fonct OK 2020-11-22 18:49:30 +01:00
Neluji
7c30feb7fa Merge branch 'Moteur' into develop 2020-11-22 18:40:45 +01:00
Neluji
9fda5dccec Merge branch 'PWM' into develop 2020-11-22 18:38:04 +01:00
Neluji
efcee57846 Récepteur RF OK 2020-11-22 18:22:41 +01:00
Neluji
67a1107044 Merge branch 'PWM' into RF 2020-11-22 17:13:19 +01:00
Neluji
17efd9c1a2 Merge branch 'PWM' into Moteur
# Conflicts:
#	MDK-ARM/Project.uvoptx
#	MyDrivers/MyPWM.h
#	Src/main.c
2020-11-22 17:07:26 +01:00
Neluji
0d390c9c27 Merge remote-tracking branch 'origin/PWM' into PWM
# Conflicts:
#	MDK-ARM/Project.uvoptx
2020-11-22 17:03:53 +01:00
Neluji
04f1835265 PWM input -> Duty_Cycle_Permilles 2020-11-22 16:59:36 +01:00
Neluji
88050db15f PWM input -> Duty_Cycle_Permilles 2020-11-22 16:48:42 +01:00
Neluji
3aa8003776 GPIO configuration fixed - Moteur OK 2020-11-22 13:05:16 +01:00
Neluji
7e745ca4f9 Fin séance 10 -> pb conf gpio 2020-11-17 11:09:17 +01:00
Neluji
506c519386 Moteur_conf(), moteur_speed() et moteur_sens() 2020-11-17 10:09:04 +01:00
Neluji
49f261078b changed set_imulse_duration parameters 2020-11-17 08:31:51 +01:00
Neluji
6e1c2b1766 Output ok, + choix canal pour Set_Impulse_Duration 2020-11-07 19:09:20 +01:00
Neluji
5c38d5e1da PWM fin séance 9 2020-11-04 12:35:58 +01:00
Neluji
11a7310a43 PWM input 2020-11-04 12:06:23 +01:00
Neluji
325154c167 l.17 2020-11-04 10:19:57 +01:00
Neluji
9c195f3020 PWM init 2020-11-04 09:28:38 +01:00
Neluji
fff46d3a15 USART init 2020-11-04 09:27:31 +01:00
29 changed files with 2113 additions and 29 deletions

View file

@ -300,12 +300,12 @@
<bEvRecOn>1</bEvRecOn> <bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf> <bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf> <bTchkAxf>0</bTchkAxf>
<nTsel>5</nTsel> <nTsel>6</nTsel>
<sDll></sDll> <sDll></sDll>
<sDllPa></sDllPa> <sDllPa></sDllPa>
<sDlgDll></sDlgDll> <sDlgDll></sDlgDll>
<sDlgPa></sDlgPa> <sDlgPa></sDlgPa>
<sIfile></sIfile> <sIfile>..\..\inifiles\Simu_Pulse.ini</sIfile>
<tDll></tDll> <tDll></tDll>
<tDllPa></tDllPa> <tDllPa></tDllPa>
<tDlgDll></tDlgDll> <tDlgDll></tDlgDll>
@ -317,7 +317,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>DLGDARM</Key> <Key>DLGDARM</Key>
<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=98,107,519,534,0)(121=-1,-1,-1,-1,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=-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> <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>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@ -350,7 +350,40 @@
<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> <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>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint/> <Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>46</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134231148</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Src\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/main.c\46</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>58</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134231188</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Src\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/main.c\58</Expression>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@ -358,6 +391,14 @@
<ItemText>time</ItemText> <ItemText>time</ItemText>
</Ww> </Ww>
</WatchWindow1> </WatchWindow1>
<MemoryWindow1>
<Mm>
<WinNumber>1</WinNumber>
<SubType>0</SubType>
<ItemText>0x08001778</ItemText>
<AccSizeX>0</AccSizeX>
</Mm>
</MemoryWindow1>
<Tracepoint> <Tracepoint>
<THDelay>0</THDelay> <THDelay>0</THDelay>
</Tracepoint> </Tracepoint>
@ -366,7 +407,7 @@
<periodic>1</periodic> <periodic>1</periodic>
<aLwin>1</aLwin> <aLwin>1</aLwin>
<aCover>0</aCover> <aCover>0</aCover>
<aSer1>0</aSer1> <aSer1>1</aSer1>
<aSer2>0</aSer2> <aSer2>0</aSer2>
<aPa>0</aPa> <aPa>0</aPa>
<viewmode>1</viewmode> <viewmode>1</viewmode>
@ -378,7 +419,7 @@
<AscS3>0</AscS3> <AscS3>0</AscS3>
<aSer3>0</aSer3> <aSer3>0</aSer3>
<eProf>0</eProf> <eProf>0</eProf>
<aLa>0</aLa> <aLa>1</aLa>
<aPa1>0</aPa1> <aPa1>0</aPa1>
<AscS4>0</AscS4> <AscS4>0</AscS4>
<aSer4>0</aSer4> <aSer4>0</aSer4>
@ -400,6 +441,13 @@
<pszMrulep></pszMrulep> <pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp> <pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp> <pMultCmdsp></pMultCmdsp>
<LogicAnalyzers>
<Wi>
<IntNumber>0</IntNumber>
<FirstString>((porta &amp; 0x00000800) &gt;&gt; 11 &amp; 0x800) &gt;&gt; 11</FirstString>
<SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303038303029203E3E2031310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F170000000000000000000000000000000000000076150008</SecondString>
</Wi>
</LogicAnalyzers>
<DebugDescription> <DebugDescription>
<Enable>1</Enable> <Enable>1</Enable>
<EnableFlashSeq>0</EnableFlashSeq> <EnableFlashSeq>0</EnableFlashSeq>
@ -420,7 +468,7 @@
<GroupNumber>1</GroupNumber> <GroupNumber>1</GroupNumber>
<FileNumber>1</FileNumber> <FileNumber>1</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>../Src/main.c</PathWithFileName> <PathWithFileName>../Src/main.c</PathWithFileName>
@ -436,6 +484,78 @@
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>2</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\Services\MyRF.c</PathWithFileName>
<FilenameWithoutPath>MyRF.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>3</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\Services\Moteur.c</PathWithFileName>
<FilenameWithoutPath>Moteur.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>4</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\Services\MySequencer.c</PathWithFileName>
<FilenameWithoutPath>MySequencer.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>5</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\MyDrivers\girouette.c</PathWithFileName>
<FilenameWithoutPath>girouette.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>6</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\Services\antichavirement.c</PathWithFileName>
<FilenameWithoutPath>antichavirement.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>7</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\Services\Chrono.c</PathWithFileName>
<FilenameWithoutPath>Chrono.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group> </Group>
<Group> <Group>
@ -446,9 +566,9 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>2</FileNumber> <FileNumber>8</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\MyDrivers\MyTimer.c</PathWithFileName> <PathWithFileName>..\MyDrivers\MyTimer.c</PathWithFileName>
@ -456,6 +576,66 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>9</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\MyDrivers\MyPWM.c</PathWithFileName>
<FilenameWithoutPath>MyPWM.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>10</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\MyDrivers\MyUSART.c</PathWithFileName>
<FilenameWithoutPath>MyUSART.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>11</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\MyDrivers\MySysTick.c</PathWithFileName>
<FilenameWithoutPath>MySysTick.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>12</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\MyDrivers\GPIO.c</PathWithFileName>
<FilenameWithoutPath>GPIO.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>13</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\MyDrivers\ADC.c</PathWithFileName>
<FilenameWithoutPath>ADC.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group> </Group>
<Group> <Group>
@ -466,7 +646,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>3</FileNumber> <FileNumber>14</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -478,7 +658,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>4</FileNumber> <FileNumber>15</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -490,7 +670,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>5</FileNumber> <FileNumber>16</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -502,7 +682,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>6</FileNumber> <FileNumber>17</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -514,7 +694,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>7</FileNumber> <FileNumber>18</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -524,6 +704,18 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>19</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\LLDrivers\src\stm32f1xx_ll_adc.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_ll_adc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group> </Group>
<Group> <Group>
@ -534,7 +726,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>5</GroupNumber> <GroupNumber>5</GroupNumber>
<FileNumber>8</FileNumber> <FileNumber>20</FileNumber>
<FileType>5</FileType> <FileType>5</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -554,7 +746,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>9</FileNumber> <FileNumber>21</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -574,7 +766,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>7</GroupNumber> <GroupNumber>7</GroupNumber>
<FileNumber>10</FileNumber> <FileNumber>22</FileNumber>
<FileType>2</FileType> <FileType>2</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>

View file

@ -391,6 +391,38 @@
</Group> </Group>
<Group> <Group>
<GroupName>User Services</GroupName> <GroupName>User Services</GroupName>
<Files>
<File>
<FileName>MyRF.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\MyRF.c</FilePath>
</File>
<File>
<FileName>Moteur.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\Moteur.c</FilePath>
</File>
<File>
<FileName>MySequencer.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\MySequencer.c</FilePath>
</File>
<File>
<FileName>girouette.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\girouette.c</FilePath>
</File>
<File>
<FileName>antichavirement.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\antichavirement.c</FilePath>
</File>
<File>
<FileName>Chrono.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\Chrono.c</FilePath>
</File>
</Files>
</Group> </Group>
<Group> <Group>
<GroupName>MyDrivers</GroupName> <GroupName>MyDrivers</GroupName>
@ -400,6 +432,31 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\MyDrivers\MyTimer.c</FilePath> <FilePath>..\MyDrivers\MyTimer.c</FilePath>
</File> </File>
<File>
<FileName>MyPWM.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\MyPWM.c</FilePath>
</File>
<File>
<FileName>MyUSART.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\MyUSART.c</FilePath>
</File>
<File>
<FileName>MySysTick.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\MySysTick.c</FilePath>
</File>
<File>
<FileName>GPIO.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\GPIO.c</FilePath>
</File>
<File>
<FileName>ADC.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\ADC.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>
@ -430,6 +487,11 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_usart.c</FilePath> <FilePath>..\LLDrivers\src\stm32f1xx_ll_usart.c</FilePath>
</File> </File>
<File>
<FileName>stm32f1xx_ll_adc.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_adc.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>
@ -595,11 +657,11 @@
<RunIndependent>0</RunIndependent> <RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging> <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability> <Capability>1</Capability>
<DriverSelection>4107</DriverSelection> <DriverSelection>4101</DriverSelection>
</Flash1> </Flash1>
<bUseTDR>1</bUseTDR> <bUseTDR>1</bUseTDR>
<Flash2>STLink\ST-LINKIII-KEIL_SWO.dll</Flash2> <Flash2>STLink\ST-LINKIII-KEIL_SWO.dll</Flash2>
<Flash3></Flash3> <Flash3>"" ()</Flash3>
<Flash4></Flash4> <Flash4></Flash4>
<pFcarmOut></pFcarmOut> <pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp> <pFcarmGrp></pFcarmGrp>
@ -852,6 +914,38 @@
</Group> </Group>
<Group> <Group>
<GroupName>User Services</GroupName> <GroupName>User Services</GroupName>
<Files>
<File>
<FileName>MyRF.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\MyRF.c</FilePath>
</File>
<File>
<FileName>Moteur.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\Moteur.c</FilePath>
</File>
<File>
<FileName>MySequencer.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\MySequencer.c</FilePath>
</File>
<File>
<FileName>girouette.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\girouette.c</FilePath>
</File>
<File>
<FileName>antichavirement.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\antichavirement.c</FilePath>
</File>
<File>
<FileName>Chrono.c</FileName>
<FileType>1</FileType>
<FilePath>..\Services\Chrono.c</FilePath>
</File>
</Files>
</Group> </Group>
<Group> <Group>
<GroupName>MyDrivers</GroupName> <GroupName>MyDrivers</GroupName>
@ -861,6 +955,31 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\MyDrivers\MyTimer.c</FilePath> <FilePath>..\MyDrivers\MyTimer.c</FilePath>
</File> </File>
<File>
<FileName>MyPWM.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\MyPWM.c</FilePath>
</File>
<File>
<FileName>MyUSART.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\MyUSART.c</FilePath>
</File>
<File>
<FileName>MySysTick.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\MySysTick.c</FilePath>
</File>
<File>
<FileName>GPIO.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\GPIO.c</FilePath>
</File>
<File>
<FileName>ADC.c</FileName>
<FileType>1</FileType>
<FilePath>..\MyDrivers\ADC.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>
@ -891,6 +1010,11 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_usart.c</FilePath> <FilePath>..\LLDrivers\src\stm32f1xx_ll_usart.c</FilePath>
</File> </File>
<File>
<FileName>stm32f1xx_ll_adc.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_adc.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>

92
MyDrivers/ADC.c Normal file
View file

@ -0,0 +1,92 @@
#include "ADC.h"
#include "stm32f1xx_ll_bus.h"
#include "stm32f1xx_ll_adc.h"
#include "stm32f1xx_ll_rcc.h"
/**
* @brief Configure l'ADC pour les différents channels
* @note
* @param None
* @retval None
*/
void conf_ADC (void) {
//Activation de la clock de l'ADC
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
//Division pour etre < 14 MHz
LL_RCC_SetADCClockSource(LL_RCC_ADC_CLKSRC_PCLK2_DIV_6);
//Bit ADON à 1 pour lancer la conversion
LL_ADC_Enable(ADC1);
//Définition
LL_ADC_REG_InitTypeDef My_LL_ADC_REG_Init_Struct;
//Initialisation
LL_ADC_REG_StructInit(&My_LL_ADC_REG_Init_Struct);
My_LL_ADC_REG_Init_Struct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_1RANK ;
LL_ADC_StartCalibration(ADC1);
//Application a l'ADC1
LL_ADC_REG_Init(ADC1,&My_LL_ADC_REG_Init_Struct);
//Configuration du Sampling Time
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_10, LL_ADC_SAMPLINGTIME_239CYCLES_5);
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_11, LL_ADC_SAMPLINGTIME_239CYCLES_5);
}
/**
* @brief Règle les différentes entrées et sortie nécessaire à la girouette
* @note
* @param None
* @retval valeur du rapport "X/Y" [0 infini]
*/
uint32_t X;
uint32_t Y;
float rapport;
float start_ADC (void) {
//Conversion X
LL_ADC_REG_SetSequencerRanks(ADC1,LL_ADC_REG_RANK_1,LL_ADC_CHANNEL_10);
LL_ADC_Enable(ADC1);
LL_ADC_REG_StartConversionSWStart(ADC1);
while ( LL_ADC_IsActiveFlag_EOS(ADC1) == 0);
X=LL_ADC_REG_ReadConversionData32(ADC1);
//Conversion Y
LL_ADC_REG_SetSequencerRanks(ADC1,LL_ADC_REG_RANK_1,LL_ADC_CHANNEL_11);
LL_ADC_Enable(ADC1);
LL_ADC_REG_StartConversionSWStart(ADC1);
while ( LL_ADC_IsActiveFlag_EOS(ADC1) == 0);
Y=LL_ADC_REG_ReadConversionData32(ADC1);
//Calcul rapport
rapport = X/Y;
return rapport;
}

4
MyDrivers/ADC.h Normal file
View file

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

168
MyDrivers/GPIO.c Normal file
View file

@ -0,0 +1,168 @@
#include "stm32f1xx_ll_gpio.h"
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
#include "GPIO.h"
void conf_GPIO_girouette(void){
//PA5,6,7
//Définition
LL_GPIO_InitTypeDef My_LL_GPIO_Init_Struct;
//Initialisation
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
//GPIOA - PIN 5 (INDEX)
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_INPUT;
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_5;
My_LL_GPIO_Init_Struct.Pull=LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIOA,&My_LL_GPIO_Init_Struct);
//Initialisation
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
//GIOA - PIN 6 (CHA)
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_INPUT;
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_6;
My_LL_GPIO_Init_Struct.Pull=LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIOA,&My_LL_GPIO_Init_Struct);
//Initialisation
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
//GPIOA - PIN 7 (CHB)
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_INPUT;
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_7;
My_LL_GPIO_Init_Struct.Pull=LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIOA,&My_LL_GPIO_Init_Struct);
//Initialisation
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
//GPIOA - PIN 8 (PWM)
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_ALTERNATE;
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_8;
My_LL_GPIO_Init_Struct.OutputType=LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOA,&My_LL_GPIO_Init_Struct);
}
void conf_GPIO_roulis(void){
//PC 0,1
//Définition
LL_GPIO_InitTypeDef My_LL_GPIO_Init_Struct;
//Initialisation
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
//GPIOC - PIN 0
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_ANALOG;
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_0;
My_LL_GPIO_Init_Struct.Pull=LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIOC,&My_LL_GPIO_Init_Struct);
//Initialisation
LL_GPIO_StructInit(&My_LL_GPIO_Init_Struct);
//GPIOC - PIN 1
My_LL_GPIO_Init_Struct.Mode=LL_GPIO_MODE_ANALOG;
My_LL_GPIO_Init_Struct.Pin=LL_GPIO_PIN_1;
My_LL_GPIO_Init_Struct.Pull=LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIOC,&My_LL_GPIO_Init_Struct);
};
void conf_GPIO_RF (void) {
LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
//RX : TIM4_CH1/2 (PWM In)
//PB.6 en floating input
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_6;
LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
//PB.7 en floating input
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_7;
LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
//TX : USART1 & Pin EN
//PA.9 en alternate output pp
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;
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
//PA.11 en output pp
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_11;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
}
void conf_GPIO_Moteur (void) {
LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
//Pin Sens
//PA.2 en output pp
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_2;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
//Vitesse : TIM2_CH2 (PWM)
//PA.1 en alternate pp
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_1;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
}
void conf_GPIO(void){
//Activation des horloges des GPIOS
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
conf_GPIO_girouette();
conf_GPIO_roulis();
conf_GPIO_Moteur();
conf_GPIO_RF();
}

23
MyDrivers/GPIO.h Normal file
View file

@ -0,0 +1,23 @@
#ifndef GPIO_H
#define GPIO_H
/*
Configuration de toutes les broches utilisées par les différentes fonctions :
- Moteur : PA.1 et PA.2
- RF : PB.6, PB.7, PA.9 et PA.11
- Accéléromètre : PC.0 et PC.1
- Servo : PA.8
- Girouette : PA.5, PA.6 et PA.7
*/
#include "stm32f103xb.h"
/**
* @brief Configure les broches selon leurs utilisations
* @note Fonction à lancer en début de pgm.
* @param None
* @retval None
*/
void conf_GPIO(void);
#endif

107
MyDrivers/MyPWM.c Normal file
View file

@ -0,0 +1,107 @@
#include "MyPWM.h"
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
#include "stm32f1xx_ll_tim.h"
void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel)
{
LL_TIM_OC_InitTypeDef My_LL_Tim_OC_Init_Struct;
//Configuration du output channel en PWM
LL_TIM_OC_StructInit(&My_LL_Tim_OC_Init_Struct);
//Configure le mode de la PWM : PWM1 = 1 jusqu'à la CompareValue puis 0, PWM2 = l'inverse
My_LL_Tim_OC_Init_Struct.OCMode = LL_TIM_OCMODE_PWM1;
LL_TIM_OC_Init(Timer,channel,&My_LL_Tim_OC_Init_Struct);
//Activation du channel pour le timer considéré
LL_TIM_CC_EnableChannel(Timer, channel);
}
/**
* @brief Configuration du timer en mode PWM
* @note
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* @retval None
*/
void MyPWM_girouette_Conf_Output(TIM_TypeDef *TIMx, uint32_t Channel)
{
//Définition
LL_TIM_OC_InitTypeDef My_LL_Tim_OC_Init_Struct;
//Configuration du output channel en PWM
LL_TIM_OC_StructInit(&My_LL_Tim_OC_Init_Struct);
My_LL_Tim_OC_Init_Struct.OCMode = LL_TIM_OCMODE_PWM1;
LL_TIM_OC_Init(TIMx,Channel,&My_LL_Tim_OC_Init_Struct);
// Réglage du ARR et du PSC du Timer en PWM pour une période de 20ms
LL_TIM_SetAutoReload(TIMx,0x707F);
LL_TIM_SetPrescaler(TIMx,0x31);
//Activation du channel (CH3) pour le timer considéré
LL_TIM_CC_EnableChannel(TIMx, Channel);
}
//Configurer obligatoirement les channels 1 et 2 sur IC1 et IC2 ou IC3 et IC4
void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2)
{
LL_TIM_IC_InitTypeDef My_LL_Tim_IC_Init_Struct;
//Configuration du channel1 (front montant, mappé sur TI1 = valeurs par défaut)
LL_TIM_IC_StructInit(&My_LL_Tim_IC_Init_Struct);
LL_TIM_IC_Init(Timer,channel1,&My_LL_Tim_IC_Init_Struct);
//Configuration du channel2 (front descendant, mappé sur TI1 = valeurs modifiées)
LL_TIM_IC_StructInit(&My_LL_Tim_IC_Init_Struct);
//Détection sur front descendant
My_LL_Tim_IC_Init_Struct.ICPolarity = LL_TIM_IC_POLARITY_FALLING;
//Mappage sur TI1
My_LL_Tim_IC_Init_Struct.ICActiveInput = LL_TIM_ACTIVEINPUT_INDIRECTTI;
LL_TIM_IC_Init(Timer,channel2,&My_LL_Tim_IC_Init_Struct);
//Definition du trigger
LL_TIM_SetTriggerInput(Timer, LL_TIM_TS_TI1FP1);
//Configure le mode esclave en mode RESET
LL_TIM_SetSlaveMode(Timer, LL_TIM_SLAVEMODE_RESET);
//Activation des 2 channels pour le timer considéré
LL_TIM_CC_EnableChannel(Timer, channel1);
LL_TIM_CC_EnableChannel(Timer, channel2);
}
void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int channel)
{
if (channel==LL_TIM_CHANNEL_CH1) LL_TIM_OC_SetCompareCH1(Timer, CompareValue);
else if (channel==LL_TIM_CHANNEL_CH2) LL_TIM_OC_SetCompareCH2(Timer, CompareValue);
else if (channel==LL_TIM_CHANNEL_CH3) LL_TIM_OC_SetCompareCH3(Timer, CompareValue);
else LL_TIM_OC_SetCompareCH4(Timer, CompareValue);
}
void MyPWM_girouette_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage, int channel)
{
static uint32_t Val_ARR;
static uint32_t CompareValue;
Val_ARR = LL_TIM_GetAutoReload(Timer);
CompareValue = (Val_ARR * Percentage)/10000;
if (channel==LL_TIM_CHANNEL_CH1) LL_TIM_OC_SetCompareCH1(Timer, CompareValue);
else if (channel==LL_TIM_CHANNEL_CH2) LL_TIM_OC_SetCompareCH2(Timer, CompareValue);
else if (channel==LL_TIM_CHANNEL_CH3) LL_TIM_OC_SetCompareCH3(Timer, CompareValue);
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;
}
else {
return -1;
}
}

52
MyDrivers/MyPWM.h Normal file
View file

@ -0,0 +1,52 @@
#ifndef MYPWM_H
#define MYPWM_H
/*
Driver pour la gestion de la PWM de Timers 1 à 4
*/
#include "stm32f103xb.h"
/**
* @brief Configure un signal PWM en mode Output
* @note Penser à appeler Timer_Conf() de Timer.h avant !
* @param 1 timer, 1 channel
* @retval None
*/
void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel);
/**
* @brief Configuration du timer en mode PWM
* @note
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* @retval None
*/
void MyPWM_girouette_Conf_Output(TIM_TypeDef *TIMx, uint32_t Channel);
/**
* @brief Configure un timer en mode PWM Input
* @note Penser à appeler Timer_Conf() de Timer.h avant !
* @param 1 timer, 2 channels associés (1&2 ou 3&4)
* @retval None
*/
void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2);
/**
* @brief Définit la durée de l'impulsion à l'état haut
* @note Fct utilisée en émission
* @param 1 timer, la valeur de changement de la PWM, 1 channel associé au timer
* @retval None
*/
void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int channel);
void MyPWM_girouette_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage, int channel);
/**
* @brief Renvoie le duty cycle de la PWM en entrée
* @note Fct utilisée en réception
* @param 1 timer et 2 channels associés (1&2 ou 3&4)
* @retval renvoie le duty cycle en pour mille pour améliorer la résolution
*/
int MyPWM_Duty_Cycle_Permilles(TIM_TypeDef * Timer, int channel1, int channel2);
#endif

43
MyDrivers/MySysTick.c Normal file
View file

@ -0,0 +1,43 @@
#include "MySysTick.h"
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
#include "stm32f1xx_ll_cortex.h"
void (*Ptr_ItFct_SysTick)(void);
void MySysTick_Conf(uint32_t ticks) {
SysTick_Config(ticks);
MySysTick_IT_Disable();
}
void MySysTick_IT_Conf (void (*IT_function)(void), int Prio) {
//Affectation de la fonction du handler
Ptr_ItFct_SysTick = IT_function;
//Désactivation des IT
LL_SYSTICK_DisableIT();
//Configuration du NVIC
NVIC_SetPriority(SysTick_IRQn, Prio);
NVIC_EnableIRQ(SysTick_IRQn);
}
void MySysTick_IT_Enable (void) {
LL_SYSTICK_EnableIT();
}
void MySysTick_IT_Disable (void) {
LL_SYSTICK_DisableIT();
}
/*========Handler d'IT==========*/
void SysTick_Handler (void) {
(*Ptr_ItFct_SysTick)();
}

15
MyDrivers/MySysTick.h Normal file
View file

@ -0,0 +1,15 @@
#ifndef MY_SYSTICK_H
#define MY_SYSTICK_H
#include "stm32f103xb.h"
void MySysTick_Conf(uint32_t ticks);
void MySysTick_IT_Conf (void (*IT_function)(void), int Prio);
void MySysTick_IT_Enable (void);
void MySysTick_IT_Disable (void);
#endif

View file

@ -32,7 +32,7 @@ void (*Ptr_ItFct_TIM4)(void);
* int Psc : valeur à placer dans PSC * int Psc : valeur à placer dans PSC
* @retval None * @retval None
*/ */
void MyTimer_Conf(TIM_TypeDef * Timer, int Period) void MyTimer_Conf(TIM_TypeDef * Timer, int Arr, int Psc)
{ {
LL_TIM_InitTypeDef My_LL_Tim_Init_Struct; LL_TIM_InitTypeDef My_LL_Tim_Init_Struct;
@ -42,9 +42,6 @@ void MyTimer_Conf(TIM_TypeDef * Timer, int Period)
else if (Timer==TIM3) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3); else if (Timer==TIM3) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
else LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM4); else LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM4);
int Psc = (Period*72*1000000)/256 + 2;
int Arr = (Period*72*1000000)/Psc + 1;
// chargement structure Arr, Psc, Up Count // chargement structure Arr, Psc, Up Count
My_LL_Tim_Init_Struct.Autoreload=Arr; My_LL_Tim_Init_Struct.Autoreload=Arr;
My_LL_Tim_Init_Struct.Prescaler=Psc; My_LL_Tim_Init_Struct.Prescaler=Psc;
@ -149,6 +146,32 @@ void MyTimer_IT_Disable(TIM_TypeDef * Timer)
} }
/**
* @brief Configuration du timer en mode encodeur
* @note
* @param None
* @retval None
*/
void MyTimer_girouette_Conf(void)
{
//Définition
LL_TIM_ENCODER_InitTypeDef My_LL_Tim_Init_Struct;
// Validation horloge locale
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
//Initilisation de la structure au Timer 3
LL_TIM_ENCODER_StructInit(&My_LL_Tim_Init_Struct);
LL_TIM_ENCODER_Init(TIM3, &My_LL_Tim_Init_Struct);
// Réglage Timer 3
LL_TIM_SetAutoReload(TIM3,719);
LL_TIM_SetPrescaler(TIM3,0);
}
/* /*
============ LES INTERRUPTIONS ================================= ============ LES INTERRUPTIONS =================================

View file

@ -18,7 +18,7 @@ Driver pour Timer 1
* int Psc : valeur à placer dans PSC * int Psc : valeur à placer dans PSC
* @retval None * @retval None
*/ */
void MyTimer_Conf(TIM_TypeDef * Timer,int Period); void MyTimer_Conf(TIM_TypeDef * Timer, int Arr, int Psc);
/** /**
@ -67,4 +67,12 @@ void MyTimer_IT_Enable(TIM_TypeDef * Timer);
*/ */
void MyTimer_IT_Disable(TIM_TypeDef * Timer); void MyTimer_IT_Disable(TIM_TypeDef * Timer);
/**
* @brief Configuration du timer en mode encodeur
* @note
* @param None
* @retval None
*/
void MyTimer_girouette_Conf(void);
#endif #endif

36
MyDrivers/MyUSART.c Normal file
View file

@ -0,0 +1,36 @@
#include "MyUSART.h"
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
#include "stm32f1xx_ll_usart.h"
void MyUSART_Conf(USART_TypeDef * USART, int TransferDir)
{
LL_USART_InitTypeDef My_LL_USART_Init_Struct;
LL_USART_ClockInitTypeDef My_LL_USART_Clock;
// Validation horloge locale
if (USART==USART1) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
else if (USART==USART2) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2);
else LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART3);
//Activation clk de l'USART en entrée et sortie
LL_USART_ClockStructInit(&My_LL_USART_Clock);
My_LL_USART_Clock.ClockOutput = LL_USART_CLOCK_ENABLE;
LL_USART_ClockInit(USART, &My_LL_USART_Clock);
//Initialisation de l'USART
LL_USART_StructInit(&My_LL_USART_Init_Struct);
//My_LL_USART_Init_Struct.TransferDirection = TransferDir;
LL_USART_Init(USART, &My_LL_USART_Init_Struct);
LL_USART_Enable(USART);
}
void MyUSART_Transmit_Data_8b(USART_TypeDef * USART, char data)
{
LL_USART_TransmitData8(USART, data);
while (LL_USART_IsActiveFlag_TC(USART) != 1){/*Attendre la fin de l'envoi*/}
}

28
MyDrivers/MyUSART.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef MY_USART_H
#define MY_USART_H
/*
Driver pour USART 1 à 3 du STM32F103RB
*/
#include "stm32f103xb.h"
/**
* @brief Active l'horloge et règle les paramètres de transmission
* @note Fonction à lancer en début de pgm.
* @param USART_TypeDef USART : indique l'usart à utiliser par le uC, USART1, USART2 ou USART3
* @retval None
*/
void MyUSART_Conf(USART_TypeDef * USART, int TransferDir);
/**
* @brief Transmet 8bits de donnée
* @note
* @param USART_TypeDef USART : indique l'usart à utiliser par le uC, USART1, USART2 ou USART3
* @param char data : la donnée sur 8bits à transmettre
* @retval None
*/
void MyUSART_Transmit_Data_8b(USART_TypeDef * USART, char data);
#endif

134
MyDrivers/girouette.c Normal file
View file

@ -0,0 +1,134 @@
#include "stm32f1xx_ll_gpio.h"
#include "girouette.h"
#include "MyTimer.h"
#include "MyPWM.h"
#include "stm32f1xx_ll_tim.h"
/**
* @brief Configuration de l'interruption exterieure
* @note
* @param None
* @retval None
*/
void exti_ref(void){
LL_GPIO_AF_SetEXTISource(LL_GPIO_AF_EXTI_PORTA, LL_GPIO_AF_EXTI_LINE5);
AFIO->EXTICR[2] |= AFIO_EXTICR2_EXTI5_PA;
EXTI->IMR |= EXTI_IMR_MR5_Msk;
EXTI->RTSR |= EXTI_RTSR_TR5_Msk;
}
/**
* @brief Configuration de l'interruption du NVIC
* @note
* @param None
* @retval None
*/
void nvic_exti_conf(void){
NVIC->IP[23]=2<<4;
NVIC->ISER[0]=1<<23;
}
/**
* @brief redirection de l'interruption
* @note
* @param None
* @retval None
*/
void EXTI9_5_IRQHandler(void){
//CNT A ZERO
LL_TIM_SetCounter(TIM3, 0);
//enlever le pin de pending en le mettant a 1
EXTI->PR |= EXTI_PR_PR5_Msk;
}
/**
* @brief Configuration des interruptions et des timers
* @note
* @param None
* @retval None
*/
void conf_girouette(void){
//Configuration des interruptions
exti_ref();
nvic_exti_conf();
//Configuration timer en mode encodeur
MyTimer_girouette_Conf();
//Configuration timer en mode PWM
MyPWM_girouette_Conf_Output(TIM1,LL_TIM_CHANNEL_CH1);
//Activation Timer 1
LL_TIM_EnableAllOutputs(TIM1);
}
/**
* @brief Calcul position-angle à partir de l'encodeur
* @note
* @param None
* @retval Pourcentage "Temps haut/Période" de la PWM [5 10]% (180 valeurs)
*/
//Initialisation des variables
float pos_Min=90;
float pos_Max=270;
float pos_actuelle;
float duree_Min=1;
float duree_Max=2;
float duree_calc;
float Periode=20;
float Pourcentage_Min;
float Pourcentage_Max;
float Pourcentage_calc;
float Calcul_pourcentage_duree (void){
pos_actuelle=LL_TIM_GetCounter(TIM3);//Récupération de la valeur du compteur
//Calcul pourcentage min et max
Pourcentage_Min=duree_Min/Periode;
Pourcentage_Max=duree_Max/Periode;
//Calcul fonction affine "durée Temps haut" en fonction de la valeur du compteur
if (pos_actuelle <= 360){
if (pos_actuelle > 90 && pos_actuelle <= 270) {
duree_calc=((duree_Max-duree_Min)/(pos_Max-pos_Min))*pos_actuelle+duree_Min/duree_Max;
}
else if (pos_actuelle > 270){
duree_calc=duree_Max;
}
else {
duree_calc=duree_Min;
}
}
//Calcul fonction affine "durée Temps haut" en fonction de la valeur du compteur
//Si la girouette dépasse 180° ?
if (pos_actuelle > 360 && pos_actuelle < 720){
if (pos_actuelle > 450 && pos_actuelle < 630) {
duree_calc=((duree_Max-duree_Min)/(pos_Max-pos_Min))*(720-pos_actuelle)+duree_Min/duree_Max;
}
else if (pos_actuelle < 450){
duree_calc=duree_Max;
}
else {
duree_calc=duree_Min;
}
}
//Calcul du pourcentage en fonction de la "durée Temps haut"
Pourcentage_calc=((Pourcentage_Max-Pourcentage_Min)/(duree_Max-duree_Min))*duree_calc;
return Pourcentage_calc;
}
float Angle_Vent(void) {
return pos_actuelle/2.0;
}

7
MyDrivers/girouette.h Normal file
View file

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

235
Services/Chrono.c Normal file
View file

@ -0,0 +1,235 @@
// A COMPLETER
/*
Service permettant de chornométrer jusqu'à 59mn 59s 99 1/100
Utilise un timer au choix (TIMER1 à TIMER4).
Utilise la lib MyTimers.h /.c
*/
#include "Chrono.h"
#include "MyTimer.h"
#include "stm32f1xx_ll_gpio.h"
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
// variable privée de type Time qui mémorise la durée mesurée
static Time Chrono_Time; // rem : static rend la visibilité de la variable Chrono_Time limitée à ce fichier
// variable privée qui mémorise pour le module le timer utilisé par le module
static TIM_TypeDef * Chrono_Timer=TIM1; // init par défaut au cas où l'utilisateur ne lance pas Chrono_Conf avant toute autre fct.
//mémorise l'état précédent du bouton Start/Stop
static int Prev_Start_Stop_BP_Status=0;
//mémorise l'état du chrono (lancé ou pas)
static int Started=1;
// déclaration callback appelé toute les 10ms
void Chrono_Task_10ms(void);
//Configuration des I/O
void Chrono_Conf_io(void);
/**
* @brief Configure le chronomètre.
* @note A lancer avant toute autre fonction.
* @param Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* @retval None
*/
void Chrono_Conf(TIM_TypeDef * Timer)
{
// Reset Time
Chrono_Time.Hund=0;
Chrono_Time.Sec=0;
Chrono_Time.Min=0;
// Fixation du Timer
Chrono_Timer=Timer;
// Réglage Timer par défaut
MyTimer_Conf(Chrono_Timer,0xFFFF,0);
// Réglage interruption du Timer avec callback : Chrono_Task_10ms()
MyTimer_IT_Conf(Chrono_Timer, Chrono_Task_10ms,3);
// Validation IT
MyTimer_IT_Enable(Chrono_Timer);
}
/**
* @brief Démarre le chronomètre.
* @note si la durée dépasse 59mn 59sec 99 Hund, elle est remise à zéro et repart
* @param Aucun
* @retval Aucun
*/
void Chrono_Start(void)
{
Chrono_Timer=TIM3;
MyTimer_Start(Chrono_Timer); //Start Timer 3
Chrono_Timer=TIM1;
MyTimer_Start(Chrono_Timer); //Start Timer 1
}
/**
* @brief Arrête le chronomètre.
* @note
* @param Aucun
* @retval Aucun
*/
void Chrono_Stop(void)
{
MyTimer_Stop(Chrono_Timer);
}
/**
* @brief Remet le chronomètre à 0
* @note
* @param Aucun
* @retval Aucun
*/
void Chrono_Reset(void)
{
// Arrêt Chrono
MyTimer_Stop(Chrono_Timer);
// Reset Time
Chrono_Time.Hund=0;
Chrono_Time.Sec=0;
Chrono_Time.Min=0;
}
/**
* @brief Renvoie l'adresse de la variable Time privée gérée dans le module Chrono.c
* @note
* @param Aucun
* @retval adresse de la variable Time
*/
Time * Chrono_Read(void)
{
return &Chrono_Time;
}
/**
* @brief incrémente la variable privée Chron_Time modulo 60mn
* @note
* @param Aucun
* @retval Aucun
*/
void Chrono_Task_10ms(void)
{
Chrono_Time.Hund++;
if (Chrono_Time.Hund==100)
{
Chrono_Time.Sec++;
Chrono_Time.Hund=0;
LL_GPIO_TogglePin(GPIOA,LL_GPIO_PIN_5);
}
if (Chrono_Time.Sec==60)
{
Chrono_Time.Min++;
Chrono_Time.Sec=0;
}
if (Chrono_Time.Min==60)
{
Chrono_Time.Hund=0;
}
}
/**
* @brief polle les 3 entrées et gènère les actions à faire
* @note Fct à lancer en tâche de fond (non bloquante)
* @param None
* @retval None
*/
void Chrono_Background(void) {
//Lecture PC8 bouton Start/Stop
int Start_Stop_BP_Status = LL_GPIO_IsInputPinSet(GPIOC, LL_GPIO_PIN_8);
//Changement de l'état du chrono sur front montant du BP
if(Start_Stop_BP_Status && (Start_Stop_BP_Status != Prev_Start_Stop_BP_Status)) {
if(!Started){
Chrono_Start();
Started = 1;
}
else {
Chrono_Stop();
Started = 0;
}
}
//Actualisation mémoire BP
Prev_Start_Stop_BP_Status = Start_Stop_BP_Status;
//Reset sur PC13 high
if(!LL_GPIO_IsInputPinSet(GPIOC, LL_GPIO_PIN_13)) {
Chrono_Time.Hund=0;
Chrono_Time.Sec=0;
Chrono_Time.Min=0;
}
}
/**
* @brief configure les 3 pins d'I/O
* @note
* @param None
* @retval None
*/
void Chrono_Conf_io(void) {
//Validation horloge locale
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
GPIO_TypeDef * GPIO;
LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
//PA5 (LED de la carte) en output push-pull
GPIO = GPIOA;
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_5;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_10MHz;
My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIO, &My_GPIO_Init_Struct);
//PC8 en floating input
GPIO = GPIOC;
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_8;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_FLOATING;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
My_GPIO_Init_Struct.Speed = LL_GPIO_SPEED_FREQ_LOW;
My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIO, &My_GPIO_Init_Struct);
//PC13 (USER Button bleu carte) en floating input
GPIO = GPIOC;
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_13;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_FLOATING;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
My_GPIO_Init_Struct.Speed = LL_GPIO_SPEED_FREQ_LOW;
My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIO, &My_GPIO_Init_Struct);
}

107
Services/Chrono.h Normal file
View file

@ -0,0 +1,107 @@
// RIEN A MODIFIER //
#ifndef CHRONO_H
#define CHRONO_H
/*
Service permettant de chornométrer jusqu'à 59mn 59s 99 1/100
Utilise un timer au choix (TIMER1 à TIMER4).
Utilise la lib MyTimers.h /.c
*/
#include "stm32f103xb.h"
/* =====================================================================================
Les fonctions qui gèrent les IO (ajout par rapport à l'activité 1)
=======================================================================================*/
#define PinStart LL_GPIO_PIN_8
#define PinStop LL_GPIO_PIN_6
// à compléter pour la pin reset du chronometre
#define PinLED LL_GPIO_PIN_10
#define GPIO_Pin GPIOC
#define GPIO_LED GPIOC
/**
* @brief polle les 3 entrées et gènère les actions à faire
* @note Fct à lancer en tâche de fond (non bloquante)
* @param None
* @retval None
*/
void Chrono_Background(void);
//=======================================================================================//
// Type de donnée utilisé dans le module
typedef struct {
char Hund;
char Sec;
char Min;
} Time;
/**
* @brief Configure le chronomètre.
* @note A lancer avant toute autre fonction.
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* @retval None
*/
void Chrono_Conf(TIM_TypeDef * Timer);
/**
* @brief Démarre le chronomètre.
* @note si la durée dépasse 59mn 59sec 99 cent, elle est remise à zéro et repart
* @param Aucun
* @retval Aucun
*/
void Chrono_Start(void);
/**
* @brief Arrête le chronomètre.
* @note
* @param Aucun
* @retval Aucun
*/
void Chrono_Stop(void);
/**
* @brief Remet le chronomètre à 0
* @note
* @param Aucun
* @retval Aucun
*/
void Chrono_Reset(void);
/**
* @brief Renvoie l'adresse de la variable Time privée gérée dans le module Chrono.c
* @note
* @param Aucun
* @retval adresse de la variable Time
*/
Time * Chrono_Read(void);
#endif

56
Services/Moteur.c Normal file
View file

@ -0,0 +1,56 @@
#include "Moteur.h"
#include "MyPWM.h"
#include "MyTimer.h"
#include "stm32f1xx_ll_bus.h"
#include "stm32f1xx_ll_gpio.h"
#include "stm32f1xx_ll_tim.h"
void Moteur_Conf(void) {
//Fpwm = 10kHz = 72Mhz/(7200 = 0x1C20)
int Arr = 0x1C1F;
int Psc = 0x0;
//Activation horloge Timer
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
//Configuration initiale du Timer
MyTimer_Conf(TimerPWM, Arr, Psc);
//Configuration du Timer en PWM Output
MyPWM_Conf_Output(TimerPWM, channelPWM);
Moteur_Speed(0);
Moteur_Sens(0);
}
void Moteur_Speed(int speedPercentage) {
int Arr = 0x1C1F;
//Arrêt du Timer si pas de vitesse
if(speedPercentage == 0) {
MyTimer_Stop(TimerPWM);
}
else {
MyTimer_Start(TimerPWM);
MyPWM_Set_Impulse_Duration(TimerPWM, Arr*speedPercentage/100, channelPWM);
}
}
void Moteur_Sens(int sens) {
if(sens == 0) {
LL_GPIO_ResetOutputPin(GPIOPins, PinSens);
}
else {
LL_GPIO_SetOutputPin(GPIOPins, PinSens);
}
}

47
Services/Moteur.h Normal file
View file

@ -0,0 +1,47 @@
#ifndef MOTEUR_H
#define MOTEUR_H
/*
Driver permettant de contrôler le moteur CC qui fait tourner le plateau
La définition des pins utilisées est faites dans un autre fichier (GPIO.c)
Vitesse :
- Timer 2
- Channel 2
- Broche PA.1
Sens :
- Broche PA.2
*/
#include "stm32f103xb.h"
#define PinSens LL_GPIO_PIN_2
#define GPIOPins GPIOA
#define TimerPWM TIM2
#define channelPWM LL_TIM_CHANNEL_CH2
/**
* @brief Configure le moteur
* @note À lancer en début de pgm
* @param None
* @retval None
*/
void Moteur_Conf(void);
/**
* @brief Définit la vitesse de rotation du plateau
* @note
* @param int speedPercentage : [0; 100] (%) de la vitesse max
* @retval None
*/
void Moteur_Speed(int speedPercentage);
/**
* @brief définit le sens de rotation du plateau
* @note
* @param int sens : 0 pour un sens, un int non nul pour l'autre ({0;1} attendu)
* @retval None
*/
void Moteur_Sens(int sens);
#endif

137
Services/MyRF.c Normal file
View file

@ -0,0 +1,137 @@
#include "MyRF.h"
#include "MyTimer.h"
#include "MyPWM.h"
#include "MyUSART.h"
#include "stm32f1xx_ll_tim.h"
#include "stm32f1xx_ll_gpio.h"
#include "stm32f1xx_ll_usart.h"
void MyRF_Conf(void) {
//RX
//Configuration et lancement du Timer PWM Input
MyTimer_Conf(TimerCC,0xFFAD,0x15);
MyPWM_Conf_Input(TimerCC, channelCC1, channelCC2);
MyTimer_Start(TimerCC);
//TX
//Configuration de l'USART
MyUSART_Conf(USARTOut, TransferDirTX);
}
int MyRF_Input_Duty_Cycle(void) {
int duty_cycle_RC = MyPWM_Duty_Cycle_Permilles(TimerCC, channelCC1, channelCC2);
//Seuil de +-10% autour de la valeur centrale
if (74<duty_cycle_RC && duty_cycle_RC<77) {
return 0;
}
else {
//Conversion : 50 à 100 => -100 à 100
return (duty_cycle_RC - 75) * 4;
}
}
void MyRF_Transmit_3s(int bordage_pc, int angle_vent) {
//Conversion bordage int => chaîne de char
char bordage[3] = {bordage_pc/100+48,(bordage_pc%100-bordage_pc%10)/10+48,bordage_pc%100+48};
//Conversion angle du vent int => dénomination de l'allure
int allure_ref;
if(angle_vent <45) {
allure_ref = 0;
}
else if (angle_vent == 45) {
allure_ref = 1;
}
else if (angle_vent < 60) {
allure_ref = 2;
}
else if (angle_vent < 90) {
allure_ref = 3;
}
else if (angle_vent < 120) {
allure_ref = 4;
}
else if (angle_vent < 160) {
allure_ref = 5;
}
else {
allure_ref = 6;
}
char allure[7][16]= {"vent debout.",
"au plus près.",
"au près.",
"au bon plein.",
"au travers.",
"au grand largue.",
"au vent arrière."
};
char data1[10] = "Bordage : ";
char data2[24] = " === Le voilier navigue ";
int i;
//Activation de l'émetteur RF
LL_GPIO_SetOutputPin(GPIOOut ,PinTXEn);
//Texte 1 (bordage)
for(i=0; i<14; i++) {
MyUSART_Transmit_Data_8b(USARTOut, data1[i]);
}
//Bordage
for(i=0; i<3; i++) {
MyUSART_Transmit_Data_8b(USARTOut, bordage[i]);
}
MyUSART_Transmit_Data_8b(USARTOut, '%');
//Texte 2 (allure)
for(i=0; i<24; i++) {
MyUSART_Transmit_Data_8b(USARTOut, data2[i]);
}
//Allure
for(i=0; i<16; i++) {
MyUSART_Transmit_Data_8b(USARTOut, allure[allure_ref][i]);
}
//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);
}

68
Services/MyRF.h Normal file
View file

@ -0,0 +1,68 @@
#ifndef MYRF_H
#define MYRF_H
/*
Driver permettant de communiquer via le module RF
La définition des pins utilisées est faites dans un autre fichier (GPIO.c)
RX :
- Timer 4
- Channels 1 et 2
- Broches PB.6 et PB.7
TX :
- USART1
- Broche PA.9 (Données) et PA.11 (Enable)
*/
#include "stm32f103xb.h"
#define GPIOOut GPIOA
#define PinTXEn LL_GPIO_PIN_11
#define TimerCC TIM4
#define channelCC1 LL_TIM_CHANNEL_CH1
#define channelCC2 LL_TIM_CHANNEL_CH2
#define USARTOut USART1
#define TransferDirTX LL_USART_DIRECTION_TX
/**
* @brief Configure le module RF pour la RX et la TX (Timer4 en PWM In sur CH1/2 et USART1)
* @note À lancer en début de pgm
* @note Période TIM4 = 20ms, Transfer Dir USART = TX
* @param None
* @retval None
*/
void MyRF_Conf(void);
/**
* @brief Retourne le rapport cyclique de la PWM en provenance du récepteur RF
* @note Seuil de détection de +-10% autour du 0
* @param None
* @retval int : [-100; 100] pour correspondre à la plage du moteur
*/
int MyRF_Input_Duty_Cycle(void);
/**
* @brief Transmet un message via l'USART vers l'émetteur RF
* @note Message : "<h>h<min>'<sec>" - Bordage : <bordage>% === Le voilier navigue <allure>."
* @param int bordage_pc : pourcentage du bordage des voiles [0; 100]
* @param int angle_vent : angle du vent par rapport au bateau [0; 180]
* @retval None
*/
void MyRF_Transmit_3s(int bordage_pc, int angle_vent);
/**
* @brief Transmet un message via l'USART vers l'émetteur RF
* @note Message : "/!\ BATTERIE FAIBLE /!\"
* @param None
* @retval None
*/
void MyRF_Transmit_Batterie_Faible(void);
/**
* @brief Transmet un message via l'USART vers l'émetteur RF
* @note Message : "/!\ RISQUE DE CHAVIREMENT /!\"
* @param None
* @retval None
*/
void MyRF_Transmit_Limite_Roulis(void);
#endif

61
Services/MySequencer.c Normal file
View file

@ -0,0 +1,61 @@
#include "MySequencer.h"
#include "MySysTick.h"
#include "Moteur.h"
#include "MyRF.h"
#include "girouette.h"
#include "antichavirement.h"
#include "ADC.h"
#include "MyPWM.h"
#include "stm32f1xx_ll_tim.h"
int cnt_3sec = 0;
float pourcentage = 0.0;
void MySequencer_Task_10ms (void);
void MySequencer_Conf(void) {
MySysTick_Conf(0xAFC80);
MySysTick_IT_Conf(MySequencer_Task_10ms,3);
MySysTick_IT_Enable();
}
/**
* @brief Tâche à lancer toutes les 10ms
* @note None
* @param None
* @retval None
*/
void MySequencer_Task_10ms (void) {
//Incrémentation du compteur pour envoi toutes les 3 secondes
cnt_3sec++;
//Transmission données toutes les 3 secondes
if(cnt_3sec == 300) {
MyRF_Transmit_3s((int)((Calcul_pourcentage_duree()-0.05)*2000.0), (int)(Angle_Vent()));
cnt_3sec = 0;
}
//Réglage sens et vitesse moteur
int Duty_Cycle = MyRF_Input_Duty_Cycle();
if (Duty_Cycle >= 0) {
Moteur_Speed(Duty_Cycle);
Moteur_Sens(1);
}
else {
Moteur_Speed(-Duty_Cycle);
Moteur_Sens(0);
}
//Gestion de l'antichavirement
antichavirement(start_ADC());
//Gestion du bordage
pourcentage = Calcul_pourcentage_duree();
pourcentage *= 1000;
MyPWM_girouette_Set_Impulse_Duration(TIM1,pourcentage,LL_TIM_CHANNEL_CH1);
}

20
Services/MySequencer.h Normal file
View file

@ -0,0 +1,20 @@
#ifndef MY_SEQ_H
#define MY_SEQ_H
/*
Service qui gère le séquenceur principal du pgm
Permet la mise à jour des différentes données du pgm
S'appuie sur le SysTick, réglé pour interruption toutes les 10ms
*/
#include "stm32f103xb.h"
/**
* @brief configure un séquenceur qui s'exécute toutes les 10ms
* @note Fct à lancer en début de programme
* @param None
* @retval None
*/
void MySequencer_Conf(void);
#endif

248
Services/MyTimer.c Normal file
View file

@ -0,0 +1,248 @@
// TOUT A FAIRE !! //
/*
indispensable pour pouvoir adresser les registres des périphériques.
Rem : OBLIGATION d'utiliser les définitions utiles contenues dans ce fichier (ex : TIM_CR1_CEN, RCC_APB1ENR_TIM2EN ...)
pour une meilleure lisibilité du code.
Pour les masques, utiliser également les définitions proposée
Rappel : pour mettre à 1 , reg = reg | Mask (ou Mask est le représente le ou les bits à positionner à 1)
pour mettre à 0 , reg = reg&~ Mask (ou Mask est le représente le ou les bits à positionner à 0)
*/
#include "MyTimer.h"
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
#include "stm32f1xx_ll_tim.h"
// variable pointeur de fonction permettant de mémoriser le callback à appeler depuis
// le handler d'IT
void (*Ptr_ItFct_TIM1)(void);
void (*Ptr_ItFct_TIM2)(void);
void (*Ptr_ItFct_TIM3)(void);
void (*Ptr_ItFct_TIM4)(void);
/**
* @brief Active l'horloge et règle l'ARR et le PSC du timer visé
* @note Fonction à lancer avant toute autre. Le timer n'est pas encore lancé (voir MyTimerStart)
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* int Arr : valeur à placer dans ARR
* int Psc : valeur à placer dans PSC
* @retval None
*/
void MyTimer_Conf(TIM_TypeDef * Timer)
{
LL_TIM_InitTypeDef My_LL_Tim_Init_Struct;
// Validation horloge locale
if (Timer==TIM1) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_TIM1);
else if (Timer==TIM2) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
else if (Timer==TIM3) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
else LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM4);
// chargement structure Arr, Psc, Up Count
My_LL_Tim_Init_Struct.Autoreload=0xFFFF;
My_LL_Tim_Init_Struct.Prescaler=0;
My_LL_Tim_Init_Struct.ClockDivision=LL_TIM_CLOCKDIVISION_DIV1;
My_LL_Tim_Init_Struct.CounterMode=LL_TIM_COUNTERMODE_UP;
My_LL_Tim_Init_Struct.RepetitionCounter=0;
LL_TIM_Init(Timer,&My_LL_Tim_Init_Struct);
// Blocage IT
LL_TIM_DisableIT_UPDATE(Timer);
// Blocage Timer
LL_TIM_DisableCounter(Timer);
}
//CONFIG Timer en compteur
void MyTimer_girouette_Conf(void)
{
LL_TIM_ENCODER_InitTypeDef My_LL_Tim_Init_Struct;
// Validation horloge locale
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
LL_TIM_ENCODER_StructInit(&My_LL_Tim_Init_Struct);
LL_TIM_ENCODER_Init(TIM3, &My_LL_Tim_Init_Struct);
// Réglage Timer 3
LL_TIM_SetAutoReload(TIM3,0xFFFF);
LL_TIM_SetPrescaler(TIM3,0);
}
//CONFIG Timer en PWM
void MyPWM_Conf_Output(TIM_TypeDef *TIMx, uint32_t Channel)
{
LL_TIM_OC_InitTypeDef My_LL_Tim_OC_Init_Struct;
//Configuration du output channel en PWM
LL_TIM_OC_StructInit(&My_LL_Tim_OC_Init_Struct);
My_LL_Tim_OC_Init_Struct.OCMode = LL_TIM_OCMODE_PWM1;
LL_TIM_OC_Init(TIMx,Channel,&My_LL_Tim_OC_Init_Struct);
// Réglage Timer
LL_TIM_SetAutoReload(TIMx,0x707F);
LL_TIM_SetPrescaler(TIMx,0x31);
//Activation du channel (CH3) pour le timer considéré
LL_TIM_CC_EnableChannel(TIMx, Channel);
}
void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage, int channel)
{
static uint32_t Val_ARR;
static uint32_t CompareValue;
Val_ARR = LL_TIM_GetAutoReload(Timer);
CompareValue = (Val_ARR * Percentage)/10000;
if (channel==LL_TIM_CHANNEL_CH1) LL_TIM_OC_SetCompareCH1(Timer, CompareValue);
else if (channel==LL_TIM_CHANNEL_CH2) LL_TIM_OC_SetCompareCH2(Timer, CompareValue);
else if (channel==LL_TIM_CHANNEL_CH3) LL_TIM_OC_SetCompareCH3(Timer, CompareValue);
else LL_TIM_OC_SetCompareCH4(Timer, CompareValue);
}
/**
* @brief PWM servo moteur
* @note
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* @retval None
*/
void MyTimer_PWMservo_Conf(void)
{
MyPWM_Conf_Output(TIM4, LL_TIM_CHANNEL_CH3);
}
/**
* @brief Démarre le timer considéré
* @note
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* @retval None
*/
void MyTimer_Start(TIM_TypeDef * Timer)
{
LL_TIM_EnableCounter(Timer);
}
/**
* @brief Arrêt le timer considéré
* @note
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* @retval None
*/
void MyTimer_Stop(TIM_TypeDef * Timer)
{
LL_TIM_DisableCounter(Timer);
}
/**
* @brief Configure le Timer considéré en interruption sur débordement.
* @note A ce stade, les interruptions ne sont pas validés (voir MyTimer_IT_Enable )
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* void (*IT_function) (void) : nom (adresse) de la fonction à lancer sur interruption
* int Prio : priorité associée à l'interruption
* @retval None
*/
void MyTimer_IT_Conf(TIM_TypeDef * Timer, void (*IT_function) (void),int Prio)
{
// affectation de la fonction
if (Timer==TIM1) Ptr_ItFct_TIM1=IT_function;
else if (Timer==TIM2) Ptr_ItFct_TIM2=IT_function;
else if (Timer==TIM3) Ptr_ItFct_TIM3=IT_function;
else Ptr_ItFct_TIM4=IT_function;
// Blocage IT (il faudra la débloquer voir fct suivante)
LL_TIM_DisableIT_UPDATE(Timer);
// validation du canal NVIC
IRQn_Type TIM_irq;
if (Timer==TIM1) TIM_irq=TIM1_UP_IRQn;
else if (Timer==TIM2) TIM_irq=TIM2_IRQn;
else if (Timer==TIM3) TIM_irq=TIM3_IRQn;
else TIM_irq=TIM4_IRQn;
NVIC_SetPriority(TIM_irq, Prio);
NVIC_EnableIRQ(TIM_irq);
}
/**
* @brief Autorise les interruptions
* @note
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* @retval None
*/
void MyTimer_IT_Enable(TIM_TypeDef * Timer)
{
LL_TIM_EnableIT_UPDATE(Timer);
}
/**
* @brief Interdit les interruptions
* @note
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* @retval None
*/
void MyTimer_IT_Disable(TIM_TypeDef * Timer)
{
LL_TIM_DisableIT_UPDATE(Timer);
}
/*
============ LES INTERRUPTIONS =================================
*/
void TIM1_UP_IRQHandler(void)
{
// rabaisser le flag d'IT
LL_TIM_ClearFlag_UPDATE(TIM1);
(*Ptr_ItFct_TIM1)();
}
void TIM2_IRQHandler(void)
{
// rabaisser le flag d'IT
LL_TIM_ClearFlag_UPDATE(TIM2);
(*Ptr_ItFct_TIM2)();
}
void TIM3_IRQHandler(void)
{
// rabaisser le flag d'IT
LL_TIM_ClearFlag_UPDATE(TIM3);
(*Ptr_ItFct_TIM3)();
}
void TIM4_IRQHandler(void)
{
// rabaisser le flag d'IT
LL_TIM_ClearFlag_UPDATE(TIM4);
(*Ptr_ItFct_TIM4)();
}

View file

@ -0,0 +1,28 @@
#include "antichavirement.h"
#include "MyPWM.h"
#include "stm32f1xx_ll_tim.h"
#include "stm32f1xx_ll_adc.h"
#include "MyRF.h"
#define seuil_g_pos 1.0
#define seuil_g_neg -1.0
/**
* @brief Configure l'antichavirement pour des valeurs seuils
* @note
* @param Rapport "X/Y" [0 infini] (Si Rapport dépasse les valeurs seuils alors on déclenche les voiles)
* @retval None
*/
void antichavirement (float rapport) {
if (rapport >= seuil_g_pos || rapport <= seuil_g_neg){
//Application des voiles à 90°
MyPWM_girouette_Set_Impulse_Duration(TIM1,10000*10/100,LL_TIM_CHANNEL_CH1);
MyRF_Transmit_Limite_Roulis();
}
}

View file

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

View file

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

View file

@ -20,6 +20,15 @@
#include "stm32f1xx_ll_utils.h" // utile dans la fonction SystemClock_Config #include "stm32f1xx_ll_utils.h" // utile dans la fonction SystemClock_Config
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config #include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
#include "MyRF.h"
#include "Moteur.h"
#include "MySequencer.h"
#include "girouette.h"
#include "GPIO.h"
#include "ADC.h"
#include "Chrono.h"
void SystemClock_Config(void); void SystemClock_Config(void);
/* Private functions ---------------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/
@ -36,6 +45,18 @@ int main(void)
/* Configure the system clock to 72 MHz */ /* Configure the system clock to 72 MHz */
SystemClock_Config(); SystemClock_Config();
Chrono_Conf(TIM3);
Chrono_Conf(TIM1);
Chrono_Start();
MyRF_Conf();
Moteur_Conf();
MySequencer_Conf();
conf_girouette();
conf_GPIO();
conf_ADC();
/* Infinite loop */ /* Infinite loop */
while (1) while (1)
{ {
@ -46,8 +67,6 @@ int main(void)
/** /**
* @brief System Clock Configuration * @brief System Clock Configuration
* The system Clock is configured as follow : * The system Clock is configured as follow :
@ -70,7 +89,7 @@ void SystemClock_Config(void)
/* Enable HSE oscillator */ /* Enable HSE oscillator */
// ********* Commenter la ligne ci-dessous pour MCBSTM32 ***************** // ********* Commenter la ligne ci-dessous pour MCBSTM32 *****************
// ********* Conserver la ligne si Nucléo********************************* // ********* Conserver la ligne si Nucl<EFBFBD>o*********************************
LL_RCC_HSE_EnableBypass(); LL_RCC_HSE_EnableBypass();
LL_RCC_HSE_Enable(); LL_RCC_HSE_Enable();
while(LL_RCC_HSE_IsReady() != 1) while(LL_RCC_HSE_IsReady() != 1)