#include <stdint.h>
#include <stdlib.h>
//Registradores RCC
#define BASE_ADDRESS_RCC 0x40021000UL
#define RCC_IOPENR_OFFSET 0x34UL
#define RCC_IOPENR (*(volatile unsigned int *) (BASE_ADDRESS_RCC + RCC_IOPENR_OFFSET))
//Registradores GPIO
#define BASE_ADDRESS_GPIOA 0x50000000UL
#define GPIOA_MODER_OFFSET 0x00UL
#define GPIOA_MODER (*(volatile unsigned int *) (BASE_ADDRESS_GPIOA + GPIOA_MODER_OFFSET))
#define GPIOA_ODR_OFFSET 0x14UL
#define GPIOA_ODR (*(volatile unsigned int *) (BASE_ADDRESS_GPIOA + GPIOA_ODR_OFFSET))
//Mapeamento de Hardware
#define enableGPIOA (1U<<0)
#define pinoLed (1U<<5)
int main() {
uint32_t i;
RCC_IOPENR |= enableGPIOA; //Habilitando o clock para o periférico
GPIOA_MODER |= (1U<<10); //PAS como saída
GPIOA_MODER &= ~(1U<<11); //PAS como saída
GPIOA_ODR |= pinoLed; //User led (LD4) inicià aceso
while(1) {
for(i=0;i<10000;i++)
{
}
GPIOA_ODR ^= pinoLed;
}
}