#include "stm32l0xx.c"
#include <stdio.h>
// Where is the led is connected
// Port:A
// Pin:PA5
// Where is the PUSH BTN is connected
// Port:C
// Pin:PC13
#define GPIOAEN (1U<<0)
#define GPIOCEN (1U<<0)
#define PIN5 (1U<<5)
#define LED_PIN PIN5
#define PIN6 (1U<<6)
#define BTN_PIN PIN6
void setup()
{
RCC->IOPENR=GPIOAEN ;
GPIOA->MODER |=(1<<10);
GPIOA->MODER &=~(1<<11);
GPIOA->MODER &=~(1<<12);
GPIOA->MODER &=~(1<<13);
GPIOA->PUPDR &=~(1<<13);
GPIOA->PUPDR |=(1<<12);
while(1)
{
if((GPIOA->IDR & BTN_PIN) )
{
GPIOA->BSRR=LED_PIN;
}
else
{
GPIOA->BSRR=(1<<21);
}
}
}
void loop()
{
}