#pragma once
#ifndef GPIO_DRIVER_H
#define GPIO_DRIVER_H
#include <stdint.h>
#define RCC_BASE 0x40021000U
#define RCC_ADDRESS 0x18U
#define RCC_APB2ENR (*(volatile uint32_t*)(RCC_BASE + RCC_ADDRESS))
#define GPIOB_BASE 0x40010C00U
#define GPIOB_CRL_OFFSET 0x00000000U
#define GPIOB_CRL (*(volatile uint32_t*)(GPIOB_BASE + GPIOB_CRL_OFFSET))
#define GPIOB_BSRR_OFFSET 0x10U
#define GPIOB_BSRR (*(volatile uint32_t *)(GPIOB_BASE + GPIOB_BSRR_OFFSET))
void gpio_init();
void gpio_write();
void gpio_toggle();
#endif
void setup() {
gpio_init();
}
void loop() {
gpio_toggle();
}
void gpio_init() {
RCC_APB2ENR |= (1 << 3);
GPIOB_CRL &= ~(0xF << 0);
GPIOB_CRL |= (0x2 << 0);
}
void gpio_write() {}
void gpio_toggle() {
GPIOB_BSRR = (1U << 0);
}