mikrokontrollersystemer-pro.../prosjekt.X/uart.h
Sebastian H. Gabrielli 7dd8b67378 Add comments
2024-03-06 15:55:56 +01:00

41 lines
713 B
C

/*
* File: uart.h
* Author: Sebastian H. Gabrielli
*
* Created on March 6, 2024, 3:19 PM
*/
#ifndef UART_H
#define UART_H
#ifdef __cplusplus
extern "C" {
#endif
#include <avr/io.h>
#include <stdio.h>
#ifndef F_CPU
#define F_CPU 4E6
#endif
#define USART3_BAUD_RATE(BAUD_RATE) ((float)(F_CPU * 64 / (16 * (float)BAUD_RATE)) + 0.5)
// Initialize the USART3 controller
void init_uart(uint16_t baud);
// Send a single character over UART
void USART3_sendChar(char c);
// Send a string of characters over UART
int USART3_printChar(char c, FILE *stream);
static FILE USART_stream = FDEV_SETUP_STREAM(USART3_printChar, NULL, _FDEV_SETUP_WRITE);
#ifdef __cplusplus
}
#endif
#endif /* UART_H */