diff --git a/ProjetsKEIL/Drivers/Driver_Timer.c b/ProjetsKEIL/Drivers/Driver_Timer.c
index a47af47..d900404 100644
--- a/ProjetsKEIL/Drivers/Driver_Timer.c
+++ b/ProjetsKEIL/Drivers/Driver_Timer.c
@@ -27,27 +27,67 @@ void MyTimer_Base_Init(MyTimer_Struct_TypeDef * Timer)
}
+void MyTimer_Start(TIM_TypeDef * Timer)
+{
+ Timer->CR1 |=1<<0 ;// TIM_CR1_CEN
+}
+
+void MyTimer_Stop(TIM_TypeDef * Timer)
+{
+ Timer->CR1 &=~(1<<0) ;// TIM_CR1_CEN
+}
+
+
+void Bug (void)
+{
+ while(1);
+}
+
+void (*TIM2_fx) (void) = &Bug;
+void (*TIM3_fx) (void) = &Bug;
+void (*TIM4_fx) (void) = &Bug;
+
void MyTimer_ActiveIT (TIM_TypeDef * Timer, char Prio, void (*IT_function)(void))
{
- Timer->DIER |= TIM_DIER_BIE;
+ Timer->DIER |= TIM_DIER_UIE;
if(Timer == TIM1)
{
-
}
if(Timer == TIM2)
{
NVIC_EnableIRQ(TIM2_IRQn);
NVIC_SetPriority(TIM2_IRQn, Prio);
+ TIM2_fx = IT_function;
}
if(Timer == TIM3)
{
NVIC_EnableIRQ(TIM3_IRQn);
NVIC_SetPriority(TIM3_IRQn, Prio);
+ TIM3_fx = IT_function;
}
if(Timer == TIM4)
{
NVIC_EnableIRQ(TIM4_IRQn);
NVIC_SetPriority(TIM4_IRQn, Prio);
+ TIM4_fx = IT_function;
}
}
+void TIM2_IRQHandler (void)
+{
+ TIM2->SR &= ~TIM_SR_UIF;
+ (*TIM2_fx)();
+}
+
+void TIM3_IRQHandler (void)
+{
+ TIM3->SR &= ~TIM_SR_UIF;
+ (*TIM3_fx)();
+}
+
+void TIM4_IRQHandler (void)
+{
+ TIM3->SR &= ~TIM_SR_UIF;
+ (*TIM4_fx)();
+}
+
diff --git a/ProjetsKEIL/Drivers/Driver_Timer.h b/ProjetsKEIL/Drivers/Driver_Timer.h
index ff82893..46012b6 100644
--- a/ProjetsKEIL/Drivers/Driver_Timer.h
+++ b/ProjetsKEIL/Drivers/Driver_Timer.h
@@ -19,8 +19,12 @@ typedef struct
*/
void MyTimer_Base_Init(MyTimer_Struct_TypeDef * Timer);
-#define MyTimer_Base_Start(Timer) ...
+/*#define MyTimer_Base_Start(Timer) ...
#define MyTimer_Base_Stop(Timer) ...
+*/
+
+void MyTimer_Start(TIM_TypeDef * Timer) ;
+void MyTimer_Stop(TIM_TypeDef * Timer) ;
/**
diff --git a/ProjetsKEIL/Projet_Timer/Source/Principal.c b/ProjetsKEIL/Projet_Timer/Source/Principal.c
index a3ccca5..170a480 100644
--- a/ProjetsKEIL/Projet_Timer/Source/Principal.c
+++ b/ProjetsKEIL/Projet_Timer/Source/Principal.c
@@ -2,19 +2,34 @@
#include "stdio.h"
#include "Driver_GPIO.h"
#include "Driver_Timer.h"
-
+void clignote_led(void)
+{
+ //GPIO structure definition
+ MyGPIO_Struct_TypeDef GPIO_led;
+ //MyGPIO_Struct_TypeDef GPIO_button;
+
+ //PA5 (LED) configurated in output
+ GPIO_led.GPIO_Pin = 5;
+ GPIO_led.GPIO_Conf = Out_Ppull;
+ GPIO_led.GPIO = GPIOA;
+ MyGPIO_Init(&GPIO_led);
+
+ MyGPIO_Toggle(GPIO_led.GPIO , GPIO_led.GPIO_Pin);
+
+}
int main (void)
{
- //GPIO structure definition
- MyGPIO_Struct_TypeDef GPIO_led;
- MyGPIO_Struct_TypeDef GPIO_button;
-
-
+
MyTimer_Struct_TypeDef Timer3;
Timer3.Timer = TIM3;
-
+ Timer3.ARR = 2000;
+ Timer3.PSC = 35981;
+ MyTimer_Base_Init(&Timer3);
+ MyTimer_Start(TIM3);
- //PC13 (Button) configurated in input
+ MyTimer_ActiveIT(Timer3.Timer, 0x1, &clignote_led);
+
+ /*//PC13 (Button) configurated in input
GPIO_button.GPIO_Pin = 13;
GPIO_button.GPIO_Conf = In_Floating;
GPIO_button.GPIO = GPIOC;
@@ -38,4 +53,9 @@ int main (void)
MyGPIO_Reset (GPIO_led.GPIO , GPIO_led.GPIO_Pin) ;
}
}while(1);
+ */
+
+ while (1)
+ {
+ }
}
diff --git a/ProjetsKEIL/Projet_Timer/tp.uvoptx b/ProjetsKEIL/Projet_Timer/tp.uvoptx
index 96bb898..aab57e2 100644
--- a/ProjetsKEIL/Projet_Timer/tp.uvoptx
+++ b/ProjetsKEIL/Projet_Timer/tp.uvoptx
@@ -125,7 +125,7 @@
0
DLGDARM
- (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=1104,569,1525,996,1)(121=-1,-1,-1,-1,0)(122=1103,131,1524,558,1)(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=-1,-1,-1,-1,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)
+ (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=1104,569,1525,996,1)(121=-1,-1,-1,-1,0)(122=1103,131,1524,558,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=501,185,1095,936,1)(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)
0
@@ -488,7 +488,7 @@
::Device
- 0
+ 1
0
0
1