From a27c7040cea7beebebdd3f569167ed8a0837367d Mon Sep 17 00:00:00 2001 From: Oskar Date: Tue, 16 Dec 2025 17:20:43 +0100 Subject: [PATCH 1/3] =?UTF-8?q?RTC=20pilote=20ajoute,=20reste=20=C3=A0=20t?= =?UTF-8?q?ester?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pilotes/Source/Horloge.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Pilotes/Source/Horloge.c b/Pilotes/Source/Horloge.c index 9f5dca0..a33396a 100644 --- a/Pilotes/Source/Horloge.c +++ b/Pilotes/Source/Horloge.c @@ -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; From 8a8a0b650c5457181b811ef57905f780b9435a27 Mon Sep 17 00:00:00 2001 From: Oskar Date: Tue, 16 Dec 2025 17:52:19 +0100 Subject: [PATCH 2/3] RTC au principal --- Pilotes/Include/RTC.h | 8 ++++++++ Services/Source/RTC.c | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 Pilotes/Include/RTC.h create mode 100644 Services/Source/RTC.c diff --git a/Pilotes/Include/RTC.h b/Pilotes/Include/RTC.h new file mode 100644 index 0000000..c6677c2 --- /dev/null +++ b/Pilotes/Include/RTC.h @@ -0,0 +1,8 @@ +#ifndef RTC_H_ +#define RTC_H_ +#include +initRTC(); +int getTime(); + + +#endif // RTC_H_ diff --git a/Services/Source/RTC.c b/Services/Source/RTC.c new file mode 100644 index 0000000..ee9b83f --- /dev/null +++ b/Services/Source/RTC.c @@ -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); +} + From 262e19844734ab627aff46c13c13a818aabe3fb6 Mon Sep 17 00:00:00 2001 From: Oskar Date: Tue, 16 Dec 2025 17:56:10 +0100 Subject: [PATCH 3/3] RTC au principal --- Application/principal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Application/principal.c b/Application/principal.c index a1e2457..feb4d0e 100644 --- a/Application/principal.c +++ b/Application/principal.c @@ -26,6 +26,11 @@ int main(void) { // Initialisation des modules initAccelo(); initLacheur(); + + //RTC + initRTC(); + getTime(); + for (int p = 0; p