summaryrefslogtreecommitdiff
path: root/src/uart.h
blob: 27c04bd76fe424fd658d6ba25e99b264d1bfc75b (plain)
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
33
34
35
36
37
38
39
/*
 * src/uart.h
 * (c) 2021 Jonas Gunz <himself@jonasgunz.de>
 * License: MIT
 */

/*
 * Interrupt controlled UART with
 * ringbuffers to TX and RX
 */

#ifndef _UART_H_
#define _UART_H_

#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <string.h>

#ifndef BAUD
#warning "BAUD not defined. Dafaulting to 9600"
#define BAUD 9600
#endif

#ifndef F_CPU
#error "F_CPU not defined"
#endif

#define UBRR F_CPU/16/BAUD-1

void uart_init();

uint8_t uart_putchar(char _c);

uint8_t uart_getchar(char *_c);

void uart_putstring(char *_s);

#endif