Zi projet iz finich
This commit is contained in:
parent
ebda31ee03
commit
b61941fe41
19 changed files with 724 additions and 91 deletions
|
@ -317,7 +317,7 @@
|
|||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<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=504,37,1150,710,0)(110=60,88,280,548,0)(111=752,104,972,564,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=874,38,1295,465,0)(121=892,96,1313,523,0)(122=674,103,1095,530,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=517,8,1111,759,0)(131=150,13,744,764,0)(132=599,17,1193,768,0)(133=-1,-1,-1,-1,0)(160=674,53,1122,467,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
|
||||
<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>
|
||||
<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>
|
||||
</SetRegEntry>
|
||||
</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>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
|
@ -412,7 +445,7 @@
|
|||
<Wi>
|
||||
<IntNumber>0</IntNumber>
|
||||
<FirstString>((porta & 0x00000800) >> 11 & 0x800) >> 11</FirstString>
|
||||
<SecondString>00800000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274612026203078303030303038303029203E3E2031310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F170000000000000000000000000000000000000076150008</SecondString>
|
||||
<SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303038303029203E3E2031310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F170000000000000000000000000000000000000076150008</SecondString>
|
||||
</Wi>
|
||||
</LogicAnalyzers>
|
||||
<DebugDescription>
|
||||
|
@ -487,6 +520,42 @@
|
|||
<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>
|
||||
|
@ -497,7 +566,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -509,7 +578,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -521,9 +590,9 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\MyDrivers\MyUSART.c</PathWithFileName>
|
||||
|
@ -533,7 +602,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -545,7 +614,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -555,6 +624,18 @@
|
|||
<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>
|
||||
|
@ -565,7 +646,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -577,7 +658,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -589,7 +670,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -601,7 +682,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -613,7 +694,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -623,6 +704,18 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</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>
|
||||
|
@ -633,7 +726,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -653,7 +746,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -673,7 +766,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileType>2</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
|
|
@ -407,6 +407,21 @@
|
|||
<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>
|
||||
|
@ -437,6 +452,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\MyDrivers\GPIO.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ADC.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\MyDrivers\ADC.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -467,6 +487,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\LLDrivers\src\stm32f1xx_ll_usart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_ll_adc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\LLDrivers\src\stm32f1xx_ll_adc.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -905,6 +930,21 @@
|
|||
<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>
|
||||
|
@ -935,6 +975,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\MyDrivers\GPIO.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ADC.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\MyDrivers\ADC.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -965,6 +1010,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\LLDrivers\src\stm32f1xx_ll_usart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f1xx_ll_adc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\LLDrivers\src\stm32f1xx_ll_adc.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#include "ADC_antichavirement.h"
|
||||
#include "Chrono.h"
|
||||
#include "MyTimer.h"
|
||||
#include "ADC.h"
|
||||
#include "stm32f1xx_ll_bus.h"
|
||||
#include "stm32f1xx_ll_tim.h"
|
||||
#include "stm32f1xx_ll_adc.h"
|
||||
#include "stm32f1xx_ll_rcc.h"
|
||||
|
||||
#define seuil_g_pos 1.0
|
||||
#define seuil_g_neg -1.0
|
||||
|
||||
/**
|
||||
* @brief Configure l'ADC pour les différents channels
|
||||
* @note
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void conf_ADC (void) {
|
||||
|
||||
//ADC_REG
|
||||
//Activation de la clock de l'ADC
|
||||
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
|
||||
|
||||
|
@ -19,7 +19,7 @@ void conf_ADC (void) {
|
|||
|
||||
LL_RCC_SetADCClockSource(LL_RCC_ADC_CLKSRC_PCLK2_DIV_6);
|
||||
|
||||
//Bit ADON à 1
|
||||
//Bit ADON à 1 pour lancer la conversion
|
||||
|
||||
LL_ADC_Enable(ADC1);
|
||||
|
||||
|
@ -39,14 +39,18 @@ void conf_ADC (void) {
|
|||
|
||||
LL_ADC_REG_Init(ADC1,&My_LL_ADC_REG_Init_Struct);
|
||||
|
||||
|
||||
//ADC Sampling Time
|
||||
//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;
|
||||
|
@ -86,16 +90,3 @@ float start_ADC (void) {
|
|||
return rapport;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void antichavirement (float rapport) {
|
||||
|
||||
if (rapport >= seuil_g_pos || rapport <= seuil_g_neg){
|
||||
|
||||
//Voiles à 90°
|
||||
MyPWM_Set_Impulse_Duration(TIM1,10000*10/100,LL_TIM_CHANNEL_CH1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
4
MyDrivers/ADC.h
Normal file
4
MyDrivers/ADC.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#include "stm32f103xb.h"
|
||||
|
||||
void conf_ADC (void);
|
||||
float start_ADC (void);
|
|
@ -8,7 +8,6 @@ Configuration de toutes les broches utilis
|
|||
- Accéléromètre : PC.0 et PC.1
|
||||
- Servo : PA.8
|
||||
- Girouette : PA.5, PA.6 et PA.7
|
||||
Manque PC.2 = adc batterie
|
||||
*/
|
||||
|
||||
#include "stm32f103xb.h"
|
||||
|
|
|
@ -18,6 +18,32 @@ 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)
|
||||
{
|
||||
|
||||
//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)
|
||||
{
|
||||
|
@ -56,6 +82,21 @@ void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int
|
|||
}
|
||||
|
||||
|
||||
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;
|
||||
|
|
|
@ -15,6 +15,14 @@ Driver pour la gestion de la PWM de Timers 1
|
|||
*/
|
||||
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 !
|
||||
|
@ -31,6 +39,8 @@ void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2);
|
|||
*/
|
||||
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
|
||||
|
|
|
@ -146,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 =================================
|
||||
|
||||
|
|
|
@ -67,4 +67,12 @@ void MyTimer_IT_Enable(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
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
#include "stm32f1xx_ll_gpio.h"
|
||||
#include "girouette.h"
|
||||
#include "MyTimer.h"
|
||||
#include "stm32f1xx_ll_bus.h"
|
||||
#include "MyPWM.h"
|
||||
#include "stm32f1xx_ll_tim.h"
|
||||
#include "stm32f1xx_ll_adc.h"
|
||||
#include "stm32f1xx_ll_rcc.h"
|
||||
|
||||
//Configuration de l'interruption exterieure
|
||||
/**
|
||||
* @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);
|
||||
|
@ -17,13 +20,23 @@ void exti_ref(void){
|
|||
EXTI->RTSR |= EXTI_RTSR_TR5_Msk;
|
||||
}
|
||||
|
||||
//Configuration de l'interruption du NVIC
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
//redirection de l'interruption
|
||||
/**
|
||||
* @brief redirection de l'interruption
|
||||
* @note
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void EXTI9_5_IRQHandler(void){
|
||||
//CNT A ZERO
|
||||
LL_TIM_SetCounter(TIM3, 0);
|
||||
|
@ -32,31 +45,38 @@ void EXTI9_5_IRQHandler(void){
|
|||
}
|
||||
|
||||
|
||||
|
||||
//configuration interruption + timer 3 en mode encodeur et 4 en mode PWM
|
||||
/**
|
||||
* @brief Configuration des interruptions et des timers
|
||||
* @note
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void conf_girouette(void){
|
||||
|
||||
//interruption
|
||||
//Configuration des interruptions
|
||||
exti_ref();
|
||||
nvic_exti_conf();
|
||||
|
||||
|
||||
//Timer en mode encodeur
|
||||
//Configuration timer en mode encodeur
|
||||
MyTimer_girouette_Conf();
|
||||
|
||||
//Timer en mode PWM
|
||||
MyPWM_Conf_Output(TIM1,LL_TIM_CHANNEL_CH1);
|
||||
//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)
|
||||
*/
|
||||
|
||||
//Calcul position-angle
|
||||
|
||||
float pos_Min=0;
|
||||
float pos_Max=135;
|
||||
//Initialisation des variables
|
||||
float pos_Min=90;
|
||||
float pos_Max=270;
|
||||
float pos_actuelle;
|
||||
|
||||
float duree_Min=1;
|
||||
|
@ -71,16 +91,16 @@ float Pourcentage_calc;
|
|||
|
||||
float Calcul_pourcentage_duree (void){
|
||||
|
||||
pos_actuelle=LL_TIM_GetCounter(TIM3);
|
||||
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 fctn affine
|
||||
//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;
|
||||
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;
|
||||
|
@ -89,10 +109,11 @@ float Calcul_pourcentage_duree (void){
|
|||
duree_calc=duree_Min;
|
||||
}
|
||||
}
|
||||
|
||||
/*if (pos_actuelle > 360 && pos_actuelle < 720){
|
||||
//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_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;
|
||||
|
@ -100,9 +121,9 @@ float Calcul_pourcentage_duree (void){
|
|||
else {
|
||||
duree_calc=duree_Min;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
//Calcul pourcentage
|
||||
//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;
|
7
MyDrivers/girouette.h
Normal file
7
MyDrivers/girouette.h
Normal 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
235
Services/Chrono.c
Normal 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
107
Services/Chrono.h
Normal 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
|
|
@ -72,11 +72,7 @@ void MyRF_Transmit_3s(int bordage_pc, int angle_vent) {
|
|||
"au vent arrière."
|
||||
};
|
||||
|
||||
char heure[2] = "xx";
|
||||
char min[2] = "xx";
|
||||
char sec[2] = "xx";
|
||||
|
||||
char data1[14] = "\" - Bordage : ";
|
||||
char data1[10] = "Bordage : ";
|
||||
char data2[24] = " === Le voilier navigue ";
|
||||
|
||||
int i;
|
||||
|
@ -84,17 +80,7 @@ void MyRF_Transmit_3s(int bordage_pc, int angle_vent) {
|
|||
//Activation de l'émetteur RF
|
||||
LL_GPIO_SetOutputPin(GPIOOut ,PinTXEn);
|
||||
|
||||
//Heure
|
||||
MyUSART_Transmit_Data_8b(USARTOut, heure[0]);
|
||||
MyUSART_Transmit_Data_8b(USARTOut, heure[1]);
|
||||
MyUSART_Transmit_Data_8b(USARTOut, 'h');
|
||||
//Minutes
|
||||
MyUSART_Transmit_Data_8b(USARTOut, min[0]);
|
||||
MyUSART_Transmit_Data_8b(USARTOut, min[1]);
|
||||
MyUSART_Transmit_Data_8b(USARTOut, '\'');
|
||||
//Secondes
|
||||
MyUSART_Transmit_Data_8b(USARTOut, sec[0]);
|
||||
MyUSART_Transmit_Data_8b(USARTOut, sec[1]);
|
||||
|
||||
//Texte 1 (bordage)
|
||||
for(i=0; i<14; i++) {
|
||||
MyUSART_Transmit_Data_8b(USARTOut, data1[i]);
|
||||
|
|
|
@ -38,7 +38,7 @@ void MyRF_Conf(void);
|
|||
* @param None
|
||||
* @retval int : [-100; 100] pour correspondre à la plage du moteur
|
||||
*/
|
||||
int MyRF_Duty_Cycle_Moteur(void);
|
||||
int MyRF_Input_Duty_Cycle(void);
|
||||
|
||||
/**
|
||||
* @brief Transmet un message via l'USART vers l'émetteur RF
|
||||
|
|
|
@ -3,8 +3,15 @@
|
|||
#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) {
|
||||
|
||||
|
@ -28,12 +35,12 @@ void MySequencer_Task_10ms (void) {
|
|||
|
||||
//Transmission données toutes les 3 secondes
|
||||
if(cnt_3sec == 300) {
|
||||
MyRF_Transmit_3s((int)((Calcul_pourcentage_duree()-5.0)*20.0), (int)(Angle_Vent()));
|
||||
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_Duty_Cycle_Moteur();
|
||||
int Duty_Cycle = MyRF_Input_Duty_Cycle();
|
||||
if (Duty_Cycle >= 0) {
|
||||
Moteur_Speed(Duty_Cycle);
|
||||
Moteur_Sens(1);
|
||||
|
@ -43,6 +50,12 @@ void MySequencer_Task_10ms (void) {
|
|||
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);
|
||||
|
||||
}
|
||||
|
|
28
Services/antichavirement.c
Normal file
28
Services/antichavirement.c
Normal 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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
3
Services/antichavirement.h
Normal file
3
Services/antichavirement.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#include "stm32f103xb.h"
|
||||
|
||||
void antichavirement (float rapport);
|
11
Src/main.c
11
Src/main.c
|
@ -24,6 +24,9 @@
|
|||
#include "Moteur.h"
|
||||
#include "MySequencer.h"
|
||||
#include "girouette.h"
|
||||
#include "GPIO.h"
|
||||
#include "ADC.h"
|
||||
#include "Chrono.h"
|
||||
|
||||
|
||||
void SystemClock_Config(void);
|
||||
|
@ -42,9 +45,17 @@ int main(void)
|
|||
/* Configure the system clock to 72 MHz */
|
||||
SystemClock_Config();
|
||||
|
||||
Chrono_Conf(TIM3);
|
||||
Chrono_Conf(TIM1);
|
||||
|
||||
Chrono_Start();
|
||||
|
||||
MyRF_Conf();
|
||||
Moteur_Conf();
|
||||
MySequencer_Conf();
|
||||
conf_girouette();
|
||||
conf_GPIO();
|
||||
conf_ADC();
|
||||
|
||||
/* Infinite loop */
|
||||
while (1)
|
||||
|
|
Loading…
Reference in a new issue