#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 PIN13
#define PIN13 (1U<<13)
#define BTN_PIN PIN13
void setup()
{
RCC->IOPENR=GPIOAEN ;
RCC->IOPENR=GPIOCEN ;
GPIOA->MODER |=(1<<10);
GPIOA->MODER &=~(1<<11);
GPIOC->MODER &=~(1<<27);
GPIOC->MODER &=~(1<<26);
while(1)
{
if(GPIOC->IDR & BTN_PIN )
{
GPIOA->BSRR=LED_PIN;
}
else
{
GPIOA->BSRR=(1<<21);
}
}
}
void loop()
{
}
Loading
st-nucleo-l031k6
st-nucleo-l031k6