#include <stdint.h>
#include "stm32f103xb.h"
#if !defined(__SOFT_FP__) && defined(__ARM_FP)
#warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
#endif
//-------------Ejercicio 1------------
// Plantilla de retardo
void delay_ms(uint16_t t) {
volatile unsigned long l = 0;
for(uint16_t i = 0; i < t; i++) {
for(l = 0; l < 800; l++);
}
}
int main(void) {
// 1. Habilitar reloj para Puerto C (Bit 4)
RCC->APB2ENR |= (1 << 4);
// 2. Configurar PC13 como Salida Push-Pull de 2MHz
// PC13 está en CRH. Los bits son 20-21 (MODE) y 22-23 (CNF)
GPIOC->CRH &= ~((1 << 20) | (1 << 21) | (1 << 22) | (1 << 23)); // Limpiar
GPIOC->CRH |= (1 << 21); // MODE13 = 10 (Output 2MHz)
// CNF13 = 00 (Push-Pull) ya está en 0 por la limpieza anterior
while(1) {
GPIOC->ODR ^= (1 << 13); // Alternar (Toggle) PC13
delay_ms(500);
}
}