Version fonctionnelle : CHRONO TERMINE git statusgit status

This commit is contained in:
Paul Faure 2020-10-05 10:17:20 +02:00
parent 7d408764d7
commit 39063744b9
5 changed files with 219 additions and 58 deletions

View file

@ -153,40 +153,7 @@
<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>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>44</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/main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>47</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/main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
@ -208,7 +175,7 @@
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
<aSer2>1</aSer2>
<aPa>0</aPa>
<viewmode>1</viewmode>
<vrSel>0</vrSel>
@ -350,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=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=908,72,1329,499,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=854,46,1448,797,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=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=908,72,1329,499,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=854,46,1448,797,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=990,76,1438,490,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>
@ -387,6 +354,38 @@
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>139</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218202</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Services\Chrono.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Services/Chrono.c\139</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>82</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218440</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\Services\Chrono.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Services/Chrono.c\82</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>153</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134217996</Address>
@ -401,7 +400,7 @@
<Expression>\\NUCLEO_F103RB\startup_stm32f103xb.s\153</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Number>3</Number>
<Type>0</Type>
<LineNumber>143</LineNumber>
<EnabledFlag>1</EnabledFlag>
@ -417,11 +416,11 @@
<Expression>\\NUCLEO_F103RB\startup_stm32f103xb.s\143</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Number>4</Number>
<Type>0</Type>
<LineNumber>46</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219942</Address>
<Address>134221228</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
@ -454,7 +453,7 @@
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
<aSer2>1</aSer2>
<aPa>0</aPa>
<viewmode>1</viewmode>
<vrSel>0</vrSel>
@ -611,6 +610,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>8</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\LLDrivers\src\stm32f1xx_ll_usart.c</PathWithFileName>
<FilenameWithoutPath>stm32f1xx_ll_usart.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@ -621,7 +632,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>8</FileNumber>
<FileNumber>9</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -641,7 +652,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>9</FileNumber>
<FileNumber>10</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -661,7 +672,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>10</FileNumber>
<FileNumber>11</FileNumber>
<FileType>2</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>

View file

@ -432,6 +432,11 @@
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_gpio.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_usart.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_usart.c</FilePath>
</File>
</Files>
</Group>
<Group>
@ -895,6 +900,11 @@
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_gpio.c</FilePath>
</File>
<File>
<FileName>stm32f1xx_ll_usart.c</FileName>
<FileType>1</FileType>
<FilePath>..\LLDrivers\src\stm32f1xx_ll_usart.c</FilePath>
</File>
</Files>
</Group>
<Group>

View file

@ -6,13 +6,17 @@ Utilise un timer au choix (TIMER1
Utilise la lib MyTimers.h /.c
*/
/* GSM -> SMS
driver*/
#include "Chrono.h"
#include "MyTimer.h"
#include "stm32f1xx_ll_gpio.h"
#include "Chrono.h" //header du chrono
#include "MyTimer.h" //header du timer
#include "stm32f1xx_ll_gpio.h" // GPIO
#include "stm32f1xx_ll_bus.h" // CLock
#include "stm32f1xx_ll_utils.h"
#include "stm32f1xx_ll_utils.h" //Pour la fonction mDelay
#include "stm32f1xx_ll_usart.h" //USART
#define TAILLE_MESSAGE 9 //Taille de chaques messages envoyé (xx:xx:xx: => 9 digits)
// 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
@ -20,9 +24,72 @@ static Time Chrono_Time; // rem : static rend la visibilit
// 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.
// Variable globale qui sert de drapeau de communication entre le BG et chronoTask10ms (et reset)
static char drapeau = 0;
// Structure pour gérer la transmission du message
struct t_transmission {
char message[TAILLE_MESSAGE];// Le message lui même
char end_of_message;// le caractère de fin (Retour Chariot)
int position;// La position du caractere a envoyer
char first_appel;// Booléen sur le premier appel (si true, lire l'heure et construire le message)
};
/**
* @brief Initialise une structure t_transmission.
* @note Structure initialisée : (message -> 00:00:00:, end_of_message -> 0x0D, position -> 0, first_appel -> 1)
* @param @ de la structure a initialiser
* @retval None
*/
void init_t_transmission(struct t_transmission * transmission) {
int i;
for (i=0; i<TAILLE_MESSAGE; i++) {
if (!((i+1) % 3)){
transmission->message[i] = ':';
} else {
transmission->message[i] = 0;
}
}
transmission->end_of_message = 0x0D;
transmission->position = 0;
transmission->first_appel = 1;
}
/**
* @brief Convertir un entier de 2 chiffres en un string.
* @note UNIQUEMENT DES ENTIERS DE 2 DIGITS (eventuellement 1 digit).
* @param n : l'entier a convertir
* buffer : @ du buffer ou stocker la conversion
* @retval None
*/
void itoa(int n, char * buffer) {
buffer[0] = (n/10) + 0x30;
buffer[1] = (n % 10) + 0x30;
}
/**
* @brief Ecrit l'heure dans une t_transmission.
* @note L'heure est inscrite dans le champs message de la structure
* @param @ de la structure dont on souhaite modifier le message
* @retval None
*/
void recuperer_heure(struct t_transmission * transmission) {
itoa(Chrono_Time.Min, transmission->message);
itoa(Chrono_Time.Sec, &(transmission->message[3]));
itoa(Chrono_Time.Hund, &(transmission->message[6]));
}
// déclaration callback appelé toute les 10ms
void Chrono_Task_10ms(void);
/**
* @brief Configure les IOs utiles pour les boutons et la LED.
* @note Bouton Reset : PinC13 -> floating input
Bouton Start/Stop : PinC8 -> floating input
LED : PinC10 -> Opendrain 2MHz
* @param None
* @retval None
*/
void Chrono_Conf_io(void) {
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
@ -33,7 +100,52 @@ void Chrono_Conf_io(void) {
LL_GPIO_SetOutputPin(GPIOC, LL_GPIO_PIN_10); // Car logique négative
}
void Chrono_Background(void) {
/**
* @brief Configure les USARTs
* @note Data : 8bits
Vitesse : 19200Bd
Parity : None
Stop Bit : 1
Sens : Tx only
GPIOs relatif a TX initialisés
* @param USARTx : USART a configurer
* @retval None
*/
void Chrono_Conf_UART(USART_TypeDef * USARTx) {
if (USARTx == USART1) {
LL_APB2_GRP1_EnableClock(RCC_APB2ENR_USART1EN);// ON la clock
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA); //ON la clock du port de TX
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_9, LL_GPIO_MODE_ALTERNATE); //ConfigTX
} else if (USARTx == USART2) {
LL_APB1_GRP1_EnableClock(RCC_APB1ENR_USART2EN); // ON la clock
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA); //ON la clock du port de TX
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_2, LL_GPIO_MODE_ALTERNATE); //ConfigTX
} else if (USARTx == USART3) {
LL_APB1_GRP1_EnableClock(RCC_APB1ENR_USART3EN);// ON la clock
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB); //ON la clock du port de TX
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_10, LL_GPIO_MODE_ALTERNATE); //ConfigTX
}
LL_USART_InitTypeDef USART_InitStruct;
LL_USART_StructInit(&USART_InitStruct);
USART_InitStruct.BaudRate = 19200; //Set Baud rate -> 19200Bd
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; //Set data width -> 8bits
USART_InitStruct.Parity = LL_USART_PARITY_NONE;// Disable Parity
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;// Set stop bit -> 1
USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX;//Set sens -> TX Only
LL_USART_Init(USARTx, &USART_InitStruct);// Applique les modifs
LL_USART_Enable(USARTx);// Rend l'USART enable A FAIRE EN DERNIER
}
/**
* @brief Gere les taches de fond : USART et Boutons
* @param USARTx : USART sur laquelle on souhaite discuter (doit avoir é initialisée)
* @retval None
*/
void Chrono_Background(USART_TypeDef * USARTx) {
// GESTION DES BOUTONS
static int isAllume = 1;
static int Start_Stop_Button_Last_State = 0;
static int Reset_Button_Last_State = 1;
@ -65,15 +177,36 @@ void Chrono_Background(void) {
Chrono_Start();
}
}
//GESTION DE L'AFFICHAGE
static struct t_transmission transmission = {"", 0x0D, 0, 1};
if (drapeau) {
if (transmission.first_appel) {
recuperer_heure(&transmission);
transmission.first_appel = 0;
}
if (LL_USART_IsActiveFlag_TXE(USARTx)) {
if (transmission.position < TAILLE_MESSAGE) {
LL_USART_TransmitData8(USARTx, (uint8_t)(transmission.message[transmission.position]));
transmission.position += 1;
} else {
LL_USART_TransmitData8(USARTx, (uint8_t)(transmission.end_of_message));
init_t_transmission(&transmission);
drapeau = 0;
}
}
}
}
/**
* @brief Configure le chronomètre.
* @brief Configure le chronomètre (Timer, IO, USART).
* @note A lancer avant toute autre fonction.
* @param Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
* USARTx : indique l'USART a utiliser pour communiquer avec le PC
* @retval None
*/
void Chrono_Conf(TIM_TypeDef * Timer)
void Chrono_Conf(TIM_TypeDef * Timer, USART_TypeDef * USARTx)
{
// Reset Time
Chrono_Time.Hund=0;
@ -86,14 +219,18 @@ void Chrono_Conf(TIM_TypeDef * Timer)
// Réglage Timer pour un débordement à 10ms
MyTimer_Conf(Chrono_Timer,999, 719);
// Configuration des IO
Chrono_Conf_io();
// Config du UART
Chrono_Conf_UART(USARTx);
// LES IT TOUJOURS A LA FIN
// 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);
// Configuration des IO
Chrono_Conf_io();
}
@ -137,6 +274,9 @@ void Chrono_Reset(void)
Chrono_Time.Hund=0;
Chrono_Time.Sec=0;
Chrono_Time.Min=0;
// Previens transimition OK
drapeau = 1;
}
@ -185,7 +325,7 @@ void Chrono_Task_10ms(void)
{
Chrono_Time.Hund=0;
}
drapeau = 1;
}

View file

@ -35,7 +35,7 @@ Les fonctions qui g
* @retval None
*/
void Chrono_Background(void);
void Chrono_Background(USART_TypeDef * USARTx);
//=======================================================================================//
@ -59,7 +59,7 @@ typedef struct {
* @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);
void Chrono_Conf(TIM_TypeDef * Timer, USART_TypeDef * USARTx);

View file

@ -40,7 +40,7 @@ int main(void)
/* Add your application code here */
// Configuration chronomètre
Chrono_Conf(TIM3);
Chrono_Conf(TIM3, USART2);
// Lancement chronomètre
Chrono_Start();
@ -50,7 +50,7 @@ int main(void)
/* Infinite loop */
while (1)
{
Chrono_Background();
Chrono_Background(USART2);
}
}