/**
******************************************************************************
* @file : main.c
* @author : Auto-generated by STM32CubeIDE
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#include <stdint.h>
#include "stm32f103xb.h"
#include "stm32f103_hal.c"
#include "stm32f103_hal.h"
#include "lcd.h"
void delay_ms(uint16_t ms);
void delay_us(uint16_t us);
const lcd_cfg_t lcd_cfg = {
.interface=LCD_INTERFACE_4BIT,
.timing=LCD_TIMING_DELAY
};
int main(void)
{
RCC->APB2ENR |= 1 << 2; // Enable GPIOA clock
RCC->APB2ENR |= 1 << 4; // Enable GPIOC clock
// PC13 as 2MHz push-pull output
GPIOC->CRH &= ~(0x0F << 20);
GPIOC->CRH |= 1 << 21;
GPIOC->ODR |= (1 << 13);
LCD_Init(&lcd_cfg);
LCD_SetCursor(0, 0);
LCD_Print("Microcontrolador");
LCD_SetCursor(0, 1);
LCD_Print("Tarea 2.1");
// Loop
while ( 1 )
{
}
}
void delay_ms(uint16_t ms) {
volatile unsigned long t = 0;
for(uint16_t i = 0; i < ms; i++)
{
for(t = 0; t < 800; t++);
}
}
void delay_us(uint16_t us)
{
for (volatile unsigned int cycles = 0; cycles < us; cycles++);
}