This commit is contained in:
Jarno Dreschler 2025-12-16 19:26:30 +01:00
commit e9f22497fd
4 changed files with 34 additions and 0 deletions

View file

@ -26,6 +26,11 @@ int main(void) {
// Initialisation des modules
initAccelo();
initLacheur();
//RTC
initRTC();
getTime();
for (int p = 0; p<LONGUEUR_MOY; p++){moyenne[p]=0xFFFF;} // Initialisation du tableau à 0xFFFF, pour ne pas qu'il se déclenche immediatement
LocaliserZero();

8
Pilotes/Include/RTC.h Normal file
View file

@ -0,0 +1,8 @@
#ifndef RTC_H_
#define RTC_H_
#include <stm32f10x.h>
initRTC();
int getTime();
#endif // RTC_H_

View file

@ -29,6 +29,15 @@ void Timer_Init(TIM_TypeDef *Timer, unsigned short Autoreload, unsigned short Pr
}
//La fonction TIM2_IRQHandler existe déjà dans le processeur, on l'a juste redifint, tel qu'à chaque overflow on met un bit 1 dans GPIOA_ODR
void TIM2_IRQHandler(void) { //On redefinit le IRQHandler qui est déjà ecrit dans le code source
if (TIM2->SR & TIM_SR_UIF) { //On met le bit de overflow à un dès qu'on a overflow
TIM2->SR &= ~TIM_SR_UIF; //Remise à zero
if (TIM2_Appel){TIM2_Appel();}
}
}
void MyTimer_ActiveIT(TIM_TypeDef * Timer, char Prio, void(*Interrupt_fonc)(void)) { //On veut créer une fonction qui envoie un signal au cas où il y a debordement, avec une prioritaire, 0 plus importante 15 moins importante
if (Timer == TIM2) {
TIM2_Appel = Interrupt_fonc;

12
Services/Source/RTC.c Normal file
View file

@ -0,0 +1,12 @@
#include "RTC.h"
initRTC(){
RTC -> PRLL = 0x7FFF; // Obtenir un période de 1 seconde
RTC -> PRLH = 0xFFFF; // Le plus grand possible
}
int getTime(){
return(RTC -> PRLH);
}