Эксперимент c Printf через UART

This commit is contained in:
2026-05-25 17:34:18 +03:00
parent 34f14b6b25
commit db04ba0f51
68 changed files with 11860 additions and 270 deletions

View File

@@ -18,10 +18,12 @@
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "usart.h"
#include "gpio.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stdio.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -53,7 +55,13 @@ void SystemClock_Config(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
HAL_StatusTypeDef fputcAnswer;
int fputc(int ch, FILE *f)
{
fputcAnswer = HAL_UART_Transmit(&huart2, (uint8_t*)&ch, 1, 0xFFFF);
return ch;
}
/* USER CODE END 0 */
/**
@@ -83,16 +91,20 @@ int main(void)
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
uint8_t counter = 0;
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
printf("%c", counter++);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */