RefKEIL/ProjetsKEIL/Projet_GPIO/Source/Principal.c

35 lines
770 B
C

#include "stm32f10x.h"
#include "stdio.h"
#include "Driver_GPIO.h"
int main (void)
{
//GPIO structure definition
MyGPIO_Struct_TypeDef GPIO_led;
MyGPIO_Struct_TypeDef GPIO_button;
//PC13 (Button) configurated in input
GPIO_button.GPIO_Pin = 13;
GPIO_button.GPIO_Conf = In_Floating;
GPIO_button.GPIO = GPIOC;
MyGPIO_Init(&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);
do
{
if(MyGPIO_Read(GPIO_button.GPIO, GPIO_button.GPIO_Pin) == 0x0)
{
MyGPIO_Set (GPIO_led.GPIO , GPIO_led.GPIO_Pin) ;
}
else
{
//MyGPIO_Set (GPIO_led.GPIO , GPIO_led.GPIO_Pin) ;
MyGPIO_Reset (GPIO_led.GPIO , GPIO_led.GPIO_Pin) ;
}
}while(1);
}