-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuart.h
86 lines (74 loc) · 2.34 KB
/
uart.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* This file has been prepared for Doxygen automatic documentation generation.*/
/*! \file *********************************************************************
*
* \brief
* Contains prototypes of functions that handle communication with a computer using RS232
*
* \par Application note:
*
*
* \author
*/
#ifndef UART_H_
#define UART_H_
#include <avr/io.h>
//function protoypes
/*!
* Function uart_init initializes the uart interface.
*
* @ingroup apiGrp
*/
void uart_init(void);
/**
*
* This function provides an easy way to write a chr at the uart interface.
*
* \param c character to be output
*
* @ingroup apiGIO
*/
void uart_putchr(char c);
/*!
* This function provides an easy yet inefficient way to print a string to the uart
*the uC will be waiting for the entire string to be send because of the use of uart_putchr
*
* \param s string to be output
*
* @ingroup apiGIO
*/
void uart_puts(const char *s);
/*!this function will print a 4-bit value as a hexadecimal digit to the uart
*the 4-bit value is right aligned (bits 0-3), bits 4-7 are ignored, and may contain garbage
*/
void uart_puthex(unsigned char n);
/*!this function will print a 8-bit unsigned value as two hexadecimal digits to the uart
*/
void uart_puthex2(unsigned char m);
/*!this function will print a 16-bit unsigned value as four hexadecimal digits to the uart
*/
void uart_puthex4(unsigned int i);
/*!
* This function will wait for a character to be received through the UART and it will then
* return this character in the location given by the pointer passed
* It has a time- out of 10000 rounds. If this timeout occurs the routine will return 0. If a
* character has been succesfully received it will return 1.
*
* \param c output buffer
* \return 1 if no time out occured
*
* @ingroup apiGIO
*/
unsigned char uart_getchr(char *c);
/*!
* This function will call the uart_getchr routine for the amount of times given in the
* length parameter. It will store them in the array past through the first pointer param
* if a string of the specified lenght has been succesfully received the routine will return 1
* if not it will return 0
*
* \param s string to be read from serial interface
* \param length the length of the string
*
* @ingroup apiGIO
*/
unsigned char uart_gets(char *s, unsigned char length);
#endif /*UART_H_*/