/*
* Author: Daniel Lizarazo
* Description: I created this project to interact for the first time with STM32 board.
* Instead of using HAL, I read the documentation and searched for the registers
* that I needed to blink a LED.
*/
#include "stm32c0xx.h"
typedef unsigned long uint32_t;
#define RCC_BASE 0x40021000 //
#define GPIOA_BASE 0X50000000
#define RCC_IOPENR *((volatile uint32_t*) (RCC_BASE + 0x34))
#define GPIO_MODER *((volatile uint32_t*)(GPIOA_BASE + 0x00))
#define GPIO_OTYPER *((volatile uint32_t*)(GPIOA_BASE + 0x04))
#define GPIO_ODR *((volatile uint32_t*)(GPIOA_BASE + 0x14))
int main(void) {
RCC_IOPENR |= (1<<0); //Enabling Clock
//Based on documentation, there might be a delay for the clock to stabilize
volatile uint32_t delay = 200;
while(delay--);
//Setting portA 5 as output, but before we need to clear it
GPIO_MODER &= ~(0b11 << (5 * 2)); // Add 11 to MODE5[11:10] negate and clear
GPIO_MODER |= (0b01 << (5 * 2)); // Basically every mode is represented by two bits
GPIO_ODR |= (0b1 << 5);
while (1) {
GPIO_ODR ^= (1 << 5);
for(delay = 100000; delay > 0; delay--);
}
}
volatile uint32_t delay();