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 +initRTC(); +int getTime(); + + +#endif // RTC_H_ 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; 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); +} +