attempt uart printf

This commit is contained in:
Ajit Ananthadevan 2025-08-24 10:01:32 +10:00
parent 63bef1cd68
commit 84d00d8178

View file

@ -1,25 +1,34 @@
// Tx/Rx: PA09[PA11]/PA10[PA12]
//#include <string.h>
//#include <stdio.h>
#include "stm32g0xx_hal_msp.h"
UART_HandleTypeDef huart1;
char buffer[] = "Hello World\r\n";
#define TXBUFFERSIZE 14 //strlen(buffer)
#define TIMEOUT 1000 //right val?
#define TIMEOUT 0xFFFF
/*
int __io_putchar(int ch)
{
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, TIMEOUT);
return ch;
}
*/
/*
setvbuf(stout, NULL, _IOLBF, 0);
int _write (int file, const void * ptr, size_t len)
{
HAL_UART_Transmit(&huart1, ptr, len, TIMEOUT);
return len;
}
*/
static void uart_init(void)
{
/* USER CODE BEGIN USART1_Init 0 */
/* USER CODE END USART1_Init 0 */
/* USER CODE BEGIN USART1_Init 1 */
/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Instance = USART1; // Defined in CMSIS header as peripheral address
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
@ -44,6 +53,7 @@ int main(void)
while(1)
{
HAL_UART_Transmit(&huart1, (uint8_t *)buffer, TXBUFFERSIZE, TIMEOUT);
//printf("Hello World\r\n");
HAL_Delay(100);
}
}