7 Copyright John Steggall 2009
12 Copyright 2009 John Steggall (steggall.j@gmail.com)
14 Permission to use, copy, modify, and distribute this software
15 and its documentation for any purpose and without fee is hereby
16 granted, provided that the above copyright notice appear in all
17 copies and that both that the copyright notice and this
18 permission notice and warranty disclaimer appear in supporting
19 documentation, and that the name of the author not be used in
20 advertising or publicity pertaining to distribution of the
21 software without specific, written prior permission.
23 The author disclaim all warranties with regard to this
24 software, including all implied warranties of merchantability
25 and fitness. In no event shall the author be liable for any
26 special, indirect or consequential damages or any damages
27 whatsoever resulting from loss of use, data or profits, whether
28 in an action of contract, negligence or other tortious action,
29 arising out of or in connection with the use or performance of
33 #ifndef UART_SOFT_CONF
34 #define UART_SOFT_CONF
36 #define BITLENGTH 833 // Length of data bit, worked out by F_CPU/desired baud
38 #define TXPIN 1 // Port pin TX is connected to
39 #define RXPIN 0 // Port pin RX is connected to
42 #define RXPORT 0x09 // RX port selection
43 #define TXPORT 0x0B // TX port selection
44 #define TXDIR_REG 0x0A // Data direction port for TX pin
47 #define EXTI_FLAG_REG 0x1C
48 #define EXTI_MASK_REG 0x1D
49 #define EXTI_MASK_BIT 0
51 #define RX_PIN_INT INT0_vect // external interrupt vector for RX pin
52 #define RX_INT_vect TIMER3_COMPC_vect // interrupt vector for OCRnC
53 #define TX_INT_vect TIMER3_COMPB_vect // interrupt vector for OCRnB
55 #define TC_INT_MASK_REG TIMSK3 // interrupt timer mask register for timer(n)
56 #define TC_COUNTL TCNT3L // count high register for timer(n)
57 #define TC_COUNTH TCNT3H // count low register for timer(n)
60 #define TC_RX_COMPEN OCIE3C // interrupt enable for OCRnC (RX bit timer)
61 #define TC_RX_COMPH OCR3CH // OCRnC compare match high register
62 #define TC_RX_COMPL OCR3CL // OCRnC compare match high register
64 /* Transmitter setup */
65 #define TC_TX_COMPEN OCIE3B // interrupt enable for OCRnB (TX bit timer)
66 #define TC_TX_COMPH OCR3BH // OCRnB compare match high register
67 #define TC_TX_COMPL OCR3BL // OCRnB compare match low register
69 #define TC_CTRLB TCCR3B // timer(n) control register B
71 #define TC_INTFLAG_REG 0x18 // timer(n) interupt flag register
72 #define TC_TX_IF_BIT OCIE3B // timer(n) interrupt flag bit for OCRnB
73 #define TC_RX_IF_BIT OCIE3C // timer(n) interrupt flag bit for OCRnC