ATtiny85 Template Code
Code snippets for the ATtiny85
Main Page
Files
File List
Globals
All
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
uart_defs.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*
2
* Internal configuration for software UART implementation
3
*---------------------------------------------------------------------------*
4
* 14-Apr-2014 ShaneG
5
*
6
* Provides additional configuration for the software UART implementation
7
* based on the values set in 'hardware.h'.
8
*--------------------------------------------------------------------------*/
9
#ifndef __UART_DEFS_H
10
#define __UART_DEFS_H
11
12
// See what mode we are in
13
#if UART_TX == UART_RX
14
# define UART_ONEPIN
15
# undef UART_INTERRUPT
16
#else
17
# define UART_TWOPIN
18
#endif
19
20
// Calculate delays for the bit bashing functions
21
#ifdef F_CPU
22
/* account for integer truncation by adding 3/2 = 1.5 */
23
# define TXDELAY (int)(((F_CPU/BAUD_RATE)-7 +1.5)/3)
24
# define RXDELAY (int)(((F_CPU/BAUD_RATE)-5 +1.5)/3)
25
# ifdef UART_INTERRUPT
26
// Reduce the stop bit delay to allow for ISR entry code
27
# define RXDELAY2 (int)(((RXDELAY*1.5)-2.5) - 8)
28
# else
29
# define RXDELAY2 (int)((RXDELAY*1.5)-2.5)
30
# endif
31
# define RXROUNDED (((F_CPU/BAUD_RATE)-5 +2)/3)
32
# if RXROUNDED > 127
33
# error low baud rates unsupported - use higher BAUD_RATE
34
# endif
35
#else
36
# error CPU frequency F_CPU undefined
37
#endif
38
39
#endif
/* __UART_DEFS_H */
shared
uart_defs.h
Generated on Wed Jun 4 2014 17:16:48 for ATtiny85 Template Code by
1.8.6