forked from trocache/RefKEIL
correction of timer and interrupts then test and validation
This commit is contained in:
parent
2310f2b595
commit
675cd92311
4 changed files with 77 additions and 13 deletions
|
@ -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))
|
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 == TIM1)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
if(Timer == TIM2)
|
if(Timer == TIM2)
|
||||||
{
|
{
|
||||||
NVIC_EnableIRQ(TIM2_IRQn);
|
NVIC_EnableIRQ(TIM2_IRQn);
|
||||||
NVIC_SetPriority(TIM2_IRQn, Prio);
|
NVIC_SetPriority(TIM2_IRQn, Prio);
|
||||||
|
TIM2_fx = IT_function;
|
||||||
}
|
}
|
||||||
if(Timer == TIM3)
|
if(Timer == TIM3)
|
||||||
{
|
{
|
||||||
NVIC_EnableIRQ(TIM3_IRQn);
|
NVIC_EnableIRQ(TIM3_IRQn);
|
||||||
NVIC_SetPriority(TIM3_IRQn, Prio);
|
NVIC_SetPriority(TIM3_IRQn, Prio);
|
||||||
|
TIM3_fx = IT_function;
|
||||||
}
|
}
|
||||||
if(Timer == TIM4)
|
if(Timer == TIM4)
|
||||||
{
|
{
|
||||||
NVIC_EnableIRQ(TIM4_IRQn);
|
NVIC_EnableIRQ(TIM4_IRQn);
|
||||||
NVIC_SetPriority(TIM4_IRQn, Prio);
|
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)();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,12 @@ typedef struct
|
||||||
*/
|
*/
|
||||||
void MyTimer_Base_Init(MyTimer_Struct_TypeDef * Timer);
|
void MyTimer_Base_Init(MyTimer_Struct_TypeDef * Timer);
|
||||||
|
|
||||||
#define MyTimer_Base_Start(Timer) ...
|
/*#define MyTimer_Base_Start(Timer) ...
|
||||||
#define MyTimer_Base_Stop(Timer) ...
|
#define MyTimer_Base_Stop(Timer) ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
void MyTimer_Start(TIM_TypeDef * Timer) ;
|
||||||
|
void MyTimer_Stop(TIM_TypeDef * Timer) ;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,19 +2,34 @@
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "Driver_GPIO.h"
|
#include "Driver_GPIO.h"
|
||||||
#include "Driver_Timer.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)
|
int main (void)
|
||||||
{
|
{
|
||||||
//GPIO structure definition
|
|
||||||
MyGPIO_Struct_TypeDef GPIO_led;
|
|
||||||
MyGPIO_Struct_TypeDef GPIO_button;
|
|
||||||
|
|
||||||
|
|
||||||
MyTimer_Struct_TypeDef Timer3;
|
MyTimer_Struct_TypeDef Timer3;
|
||||||
Timer3.Timer = TIM3;
|
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_Pin = 13;
|
||||||
GPIO_button.GPIO_Conf = In_Floating;
|
GPIO_button.GPIO_Conf = In_Floating;
|
||||||
GPIO_button.GPIO = GPIOC;
|
GPIO_button.GPIO = GPIOC;
|
||||||
|
@ -38,4 +53,9 @@ int main (void)
|
||||||
MyGPIO_Reset (GPIO_led.GPIO , GPIO_led.GPIO_Pin) ;
|
MyGPIO_Reset (GPIO_led.GPIO , GPIO_led.GPIO_Pin) ;
|
||||||
}
|
}
|
||||||
}while(1);
|
}while(1);
|
||||||
|
*/
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Key>DLGDARM</Key>
|
<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=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)</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=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)</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
|
@ -488,7 +488,7 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>::Device</GroupName>
|
<GroupName>::Device</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>1</RteFlg>
|
<RteFlg>1</RteFlg>
|
||||||
|
|
Loading…
Reference in a new issue