#include <stdint.h>
/* Base addresses (STM32C0 series) */
#define RCC_BASE 0x40021000UL
#define GPIOB_BASE 0x50000400UL
/* RCC registers */
#define RCC_IOPENR (*(volatile uint32_t *)(RCC_BASE + 0x34))
/* GPIOB registers */
#define GPIOB_MODER (*(volatile uint32_t *)(GPIOB_BASE + 0x00))
#define GPIOB_ODR (*(volatile uint32_t *)(GPIOB_BASE + 0x14))
/* Delay function */
void delay(volatile uint32_t d)
{
while (d--);
}
int main(void)
{
/* 1. Enable GPIOB clock (bit 1) */
RCC_IOPENR |= (1 << 1);
//2. Configure PB1-15 as output//
GPIOB_MODER = 0x00000000;
GPIOB_MODER = 0x55555555;
while (1)
{
// Toggle LED//
GPIOB_ODR ^= 0xFFFF;
delay(300000);
}
}