forked from trocache/RefKEIL
63 lines
1.1 KiB
C
63 lines
1.1 KiB
C
#include "stm32f10x.h"
|
|
#include "Driver_GPIO.h"
|
|
#include "Driver_timers.h"
|
|
|
|
|
|
|
|
// PA5 LED
|
|
// PC13 BP
|
|
|
|
MyGPIO_Struct_TypeDef LED;
|
|
MyTimer_Struct_TypeDef Timer_500ms;
|
|
|
|
int delay(){
|
|
int i;
|
|
for(i=0;i<1000000;i++);
|
|
}
|
|
|
|
|
|
int main ( void )
|
|
{
|
|
|
|
LED.GPIO=GPIOA;
|
|
LED.GPIO_Conf=Out_Ppull;
|
|
LED.GPIO_Pin=5;
|
|
|
|
MyGPIO_Init(&LED);
|
|
|
|
LED.GPIO=GPIOC;
|
|
LED.GPIO_Conf = In_PullUp;
|
|
LED.GPIO_Pin=13;
|
|
|
|
|
|
MyGPIO_Init(&LED);
|
|
|
|
|
|
|
|
Timer_500ms.Timer = TIM2;
|
|
Timer_500ms.PSC = 7200; //(1/72Mhz)/7200=0.1ms
|
|
Timer_500ms.ARR = 5000; //0.1*5000 = 500ms
|
|
timer_init(&Timer_500ms);
|
|
MyTimer_Start(&Timer_500ms);
|
|
|
|
|
|
while(1)
|
|
{
|
|
|
|
//if(MyGPIO_Read(GPIOC, 13) == 0)
|
|
//{
|
|
MyGPIO_Set(GPIOA, 5);
|
|
while(Timer_500ms.Timer->CNT != Timer_500ms.ARR -1); //CNT registre qui gère le retour à 0
|
|
MyGPIO_Reset(GPIOA, 5);
|
|
while(Timer_500ms.Timer->CNT != Timer_500ms.ARR -1);
|
|
//}
|
|
|
|
/* OU
|
|
while(Timer_500ms.Timer->CNT != Timer_500ms.ARR -1); //CNT registre qui gère le retour à 0
|
|
MyGPIO_Toggle(GPIOA, 5);
|
|
while(Timer_500ms.Timer->CNT != Timer_500ms.ARR -1); //CNT registre qui gère le retour à 0
|
|
*/
|
|
}
|
|
|
|
|
|
}
|