mikrokontrollersystemer-pro.../prosjekt.X/uart.h

36 lines
601 B
C
Raw Normal View History

2024-03-06 14:36:24 +00:00
/*
* 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)
void init_uart(uint16_t baud);
void USART3_sendChar(char c);
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 */