Compare commits

...

5 commits

8 changed files with 295 additions and 23 deletions

10
.gitignore vendored
View file

@ -1,6 +1,6 @@
*.lst
*.uvguix*
MDK-ARM/DebugConfig/
*.scvd
MDK-ARM/NUCLEO-F103RB/
*.o
MDK-ARM/NUCLEO-F103RB
MDK-ARM/*.scvd
MDK-ARM/*.uvguix.*
MDK-ARM/RTE/
*.lst

View file

@ -130,7 +130,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</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=100,127,658,622,0)(121=-1,-1,-1,-1,0)(122=348,235,769,640,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=150,186,744,880,0)(131=-1,-1,-1,-1,0)(132=572,114,1166,808,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)(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=668,263,1044,820,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=1027,281,1448,686,0)(121=-1,-1,-1,-1,0)(122=348,235,769,640,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=87,183,486,528,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=784,58,1378,752,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)(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>
@ -153,7 +153,56 @@
<Name>-U-O142 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -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>59</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218250</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Src\Allure.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/Allure.c\59</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>93</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218278</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Src\Allure.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/Allure.c\93</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>56</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\Src\Allure.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
@ -305,7 +354,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=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=120,153,415,450,0)(120=448,564,869,991,1)(121=-1,-1,-1,-1,0)(122=896,89,1317,516,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=718,360,1312,1111,1)(131=521,17,1115,768,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=251,288,699,702,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=-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=120,153,415,450,0)(120=204,207,625,634,0)(121=-1,-1,-1,-1,0)(122=896,89,1317,516,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=248,17,842,768,0)(131=521,17,1115,768,0)(132=709,34,1303,785,0)(133=-1,-1,-1,-1,0)(160=251,288,699,702,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>
@ -338,7 +387,72 @@
<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>99</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218684</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\MyDrivers\MyTimer.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../MyDrivers/MyTimer.c\99</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>12</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218790</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Src\Voilier.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/Voilier.c\12</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>49</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218416</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Src\Allure.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/Allure.c\49</Expression>
</Bp>
<Bp>
<Number>3</Number>
<Type>0</Type>
<LineNumber>17</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218794</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Src\Voilier.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Src/Voilier.c\17</Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
<count>0</count>
@ -571,8 +685,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\LLDrivers\src\stm32f1xx_ll_tim.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_ll_tim.c</FilenameWithoutPath>
<PathWithFileName>..\LLDrivers\src\stm32f1xx_ll_gpio.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_ll_gpio.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@ -583,8 +697,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\LLDrivers\src\stm32f1xx_ll_gpio.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_ll_gpio.c</FilenameWithoutPath>
<PathWithFileName>..\LLDrivers\src\stm32f1xx_ll_tim.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_ll_tim.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>

View file

@ -447,16 +447,16 @@
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_utils.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_tim.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_tim.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_gpio.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_gpio.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_tim.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_tim.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_exti.c</FileName>
<FileType>1</FileType>
@ -933,16 +933,16 @@
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_utils.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_tim.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_tim.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_gpio.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_gpio.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_tim.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_tim.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_exti.c</FileName>
<FileType>1</FileType>

View file

@ -0,0 +1,96 @@
#include "maths.h" //Pour la valeur absolue
#include "stm32f1xx_ll_gpio.h" // GPIO
#include "stm32f1xx_ll_bus.h" // RCC
#include "stm32f1xx_ll_tim.h" // TIMER
#include "stm32f1xx_ll_exti.h" // External Interrup
int allure;
int initialized = 0;
/**
* @brief Configure la girouette pour la détection de l'allure (sens du vent).
* @note Configuration des ports PA6 et 7 en alternate input pour récupérer les signaux
Configuration des deux channels du TIM3 pour le compteur incrementeur
Configuration du PA5 avec une interruption pour capter les tours de girouette
* @param None
* @retval None
*/
void ConfAllure(void) {
// Configuration des IO
// Liberation de la clock du port A
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
// Configuration des IO -> pin A6 et A7 en alternate imput, pin A5 en interruption
//LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_5, LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_6, LL_GPIO_MODE_FLOATING);
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_7, LL_GPIO_MODE_FLOATING);
LL_GPIO_AF_SetEXTISource(LL_GPIO_AF_EXTI_PORTA, LL_GPIO_AF_EXTI_LINE5);
LL_EXTI_InitTypeDef ExtiInitializer;
LL_EXTI_StructInit(&ExtiInitializer);
ExtiInitializer.Line_0_31 = LL_EXTI_LINE_5;
ExtiInitializer.Mode = LL_EXTI_MODE_IT;
ExtiInitializer.Trigger = LL_EXTI_TRIGGER_RISING;
ExtiInitializer.LineCommand = ENABLE;
LL_EXTI_Init(&ExtiInitializer);
NVIC->IP[23] = 0x43;
NVIC->ISER[0] |= 0x01 <<23;
//Configuration du timer
// Libération de la clock du timer
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
// Configuration des canaux du timer -> TIM3 CH1 et 2 en alternate input
LL_TIM_ENCODER_InitTypeDef Tim3Initializer;
LL_TIM_ENCODER_StructInit(&Tim3Initializer);
Tim3Initializer.EncoderMode = LL_TIM_ENCODERMODE_X2_TI1;
Tim3Initializer.IC1ActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
Tim3Initializer.IC1Filter = LL_TIM_IC_FILTER_FDIV1 ;
Tim3Initializer.IC1Polarity = LL_TIM_IC_POLARITY_RISING;
Tim3Initializer.IC1Prescaler = LL_TIM_ICPSC_DIV1;
Tim3Initializer.IC2ActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
Tim3Initializer.IC2Filter = LL_TIM_IC_FILTER_FDIV1;
Tim3Initializer.IC2Polarity = LL_TIM_IC_POLARITY_RISING;
Tim3Initializer.IC2Prescaler = LL_TIM_ICPSC_DIV1;
LL_TIM_ENCODER_Init(TIM3, &Tim3Initializer);
LL_TIM_SetAutoReload(TIM3, 359);
LL_TIM_EnableCounter(TIM3);
}
int RecupAllure(void) {
if (!initialized) {
return -1000;
} else {
return ((int)LL_TIM_GetCounter(TIM3)) - 180;
}
}
char * ToString(int alpha) {
int alpha_abs = abs(alpha);
if (alpha_abs < 45) {
return "Vent debout";
} else if (alpha < 55) {
return "Près";
} else if (alpha < 65) {
return "Bon plein";
} else if (alpha < 80) {
return "Petit largue";
} else if (alpha < 100) {
return "Travers";
} else if (alpha < 115) {
return "Largue";
} else if (alpha < 155) {
return "Grand largue";
} else if (alpha < 180) {
return "Vent arrière";
} else {
return "ERROR";
}
}
void EXTI9_5_IRQHandler(void) {
LL_TIM_SetCounter(TIM3, 0);
initialized = 1;
LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_5);
}

View file

@ -0,0 +1,41 @@
#ifndef ALLURE_H
#define ALLURE_H
/**
* @brief Configure la girouette pour la détection de l'allure (sens du vent).
* @note Configuration des ports PA6 et 7 en alternate input pour récupérer les signaux
Configuration des deux channels du TIM3 pour le compteur incrementeur
Configuration du PA5 avec une interruption pour capter les tours de girouette
* @param None
* @retval None
*/
void ConfAllure(void);
/**
* @brief Renvoi la valeur de l'allure actuelle
* @note Représentation de la donnée en degrès -> int entre -180 et 180
ATTENTION : -1000 renvoyé si girouette non initialisée
* @param None
* @retval L'allure, représenté en degrès par un entier entre -180 et 180
ATTENTION : -1000 renvoyé si girouette non initialisée
*/
int RecupAllure(void);
/**
* @brief Associe un chaine de caractère a une valeur d'allure.
* @note Une chaine de caractère est associé a des intervalles de alpha :
[-45, 45] -> "Vent debout"
[45, 55] -> "Près" (et intervalle opposé)
[55, 65] -> "Bon plein" (et intervalle opposé)
[65, 80] -> "Petit largue" (et intervalle opposé)
[80, 100] -> "Travers" (et intervalle opposé)
[100, 115] -> "Largue" (et intervalle opposé)
[115, 155] -> "Grand largue" (et intervalle opposé)
[155, -155] -> "Vent arrière"
Autre -> "ERROR"
* @param alpha : un entier représentant l'allure en ° (-180 à 180)
* @retval Une chaine de caractère représentant l'allure
*/
char * ToString(int alpha);
#endif

View file

@ -5,10 +5,12 @@
#include "Heure.h"
#include "Transmission.h"
#include "Voile.h"
#include "stm32f1xx_ll_rcc.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
void SystemClock_Config(void)
{
/* Set FLASH latency */

8
Src/maths.c Normal file
View file

@ -0,0 +1,8 @@
int abs(int a) {
if (a<0) {
return -a;
} else {
return a;
}
}

11
Src/maths.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef MATHS_H
#define MATHS_H
/**
* @brief Valeur absolue.
* @note Si a < 0 renvoi -a, sinon, a
* @param a : un entier
* @retval La valeur absolue de a
*/
int abs(int a);
#endif