-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusart.h
65 lines (53 loc) · 1.15 KB
/
usart.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* usart.h
*
* Created on: 19.05.2015
* Author: dode@luniks.net
*/
#ifndef USART_H_
#define USART_H_
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/setbaud.h>
#include "utils.h"
#define USART_LENGTH 128
#ifndef BAUD
#define BAUD 9600
#endif
/**
* Sets the baudrate and enables the transmitter and receiver.
*/
void initUSART(void);
/**
* Returns true if a CR or LF terminated line of data was received via USART.
*
* @return data was received
*/
bool isUSARTReceived(void);
/**
* Appends the data received via USART to the given string with the given
* length.
*/
void getUSARTData(char *data, size_t length);
/**
* Prints the given string via USART.
*/
void printString(const char *data);
/**
* Prints the given unsigned integer including CR + LF via USART.
*/
void printUint(uint8_t data);
/**
* Prints the given unsigned integer in hex notation including CR + LF
* via USART.
*/
void printHex(uint8_t data);
/**
* Prints the given unsigned integer in binary notation including CR + LF
* via USART.
*/
void printByte(uint8_t data);
#endif /* USART_H_ */