summaryrefslogtreecommitdiff
path: root/project/Core/Src/Homework/hw4.c
blob: 7bafb38a60300d12eddaf2a3ee4d8d9d935bb31b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * hw4.c
 *
 *  Created on: Oct 4, 2025
 *      Author: sowgro
 */

#include "UART.h"
#include "systick.h"
#include "LED.h"
#include <stdio.h>


char read_and_print_char_nonblocking() {
	uint8_t ch = USART_Read_Nonblocking(USART2);
	if (ch) {
		printf("%c", ch);
	}
	if (ch == '\r') {
		printf("\n");
	}
	return ch;
}

void hw4_run() {
	init_systick();
	for (;;) {
		delay_systick();
		LED_Toggle();
		read_and_print_char_nonblocking();
	}
}