Rev 1199 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1199 | Rev 1437 | ||
---|---|---|---|
1 | /**************************************************************************** |
1 | /**************************************************************************** |
2 | * Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje * |
2 | * Copyright (C) 2011-2012 by Claas Anders "CaScAdE" Rathje * |
3 | * admiralcascade@gmail.com * |
3 | * admiralcascade@gmail.com * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ * |
5 | * * |
5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * |
6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * |
7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License. * |
8 | * the Free Software Foundation; either version 2 of the License. * |
9 | * * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
13 | * GNU General Public License for more details. * |
14 | * * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ****************************************************************************/ |
19 | ****************************************************************************/ |
20 | 20 | ||
21 | #include "usart1.h" |
21 | #include "usart1.h" |
22 | 22 | ||
23 | #ifdef __AVR_ATmega644P__ |
23 | #ifdef __AVR_ATmega644P__ |
24 | 24 | ||
25 | /** |
25 | /** |
26 | * init usart1 |
26 | * init usart1 |
27 | */ |
27 | */ |
28 | void usart1_init() { |
28 | void usart1_init() { |
29 | UBRR1H = ((F_CPU / (16UL * USART1_BAUD)) - 1) >> 8; |
29 | UBRR1H = ((F_CPU / (16UL * USART1_BAUD)) - 1) >> 8; |
30 | UBRR1L = (F_CPU / (16UL * USART1_BAUD)) - 1; |
30 | UBRR1L = (F_CPU / (16UL * USART1_BAUD)) - 1; |
31 | 31 | ||
32 | // Enable receiver and transmitter; enable RX interrupt |
32 | // Enable receiver and transmitter; enable RX interrupt |
33 | UCSR1B = (1 << RXEN1) | (1 << TXEN1) | (1 << RXCIE1); |
33 | UCSR1B = (1 << RXEN1) | (1 << TXEN1) | (1 << RXCIE1); |
34 | 34 | ||
35 | // set asynchronous mode |
35 | // set asynchronous mode |
36 | UCSR1C &= ~(1 << UMSEL11); |
36 | UCSR1C &= ~(1 << UMSEL11); |
37 | UCSR1C &= ~(1 << UMSEL10); |
37 | UCSR1C &= ~(1 << UMSEL10); |
38 | // no parity |
38 | // no parity |
39 | UCSR1C &= ~(1 << UPM11); |
39 | UCSR1C &= ~(1 << UPM11); |
40 | UCSR1C &= ~(1 << UPM10); |
40 | UCSR1C &= ~(1 << UPM10); |
41 | // 1 stop bit |
41 | // 1 stop bit |
42 | UCSR1C &= ~(1 << USBS1); |
42 | UCSR1C &= ~(1 << USBS1); |
43 | // 8-bit |
43 | // 8-bit |
44 | UCSR1B &= ~(1 << UCSZ12); |
44 | UCSR1B &= ~(1 << UCSZ12); |
45 | UCSR1C |= (1 << UCSZ11); |
45 | UCSR1C |= (1 << UCSZ11); |
46 | UCSR1C |= (1 << UCSZ10); |
46 | UCSR1C |= (1 << UCSZ10); |
47 | 47 | ||
48 | // set direction of RXD1 and TXD1 pins |
48 | // set direction of RXD1 and TXD1 pins |
49 | // set RXD1 (PD2) as an input pin |
49 | // set RXD1 (PD2) as an input pin |
50 | PORTD &= ~(1 << PORTD2); |
50 | PORTD &= ~(1 << PORTD2); |
51 | DDRD &= ~(1 << DDD2); |
51 | DDRD &= ~(1 << DDD2); |
52 | // set TXD1 (PD3) as an output pin |
52 | // set TXD1 (PD3) as an output pin |
53 | //PORTD |= (1 << PORTD3); |
53 | //PORTD |= (1 << PORTD3); |
54 | //DDRD &= ~(1 << DDD3); |
54 | //DDRD &= ~(1 << DDD3); |
55 | 55 | ||
56 | } |
56 | } |
57 | 57 | ||
58 | ISR(USART1_TX_vect, ISR_BLOCK) { |
58 | ISR(USART1_TX_vect, ISR_BLOCK) { |
59 | } |
59 | } |
60 | 60 | ||
61 | ISR(USART1_RX_vect, ISR_BLOCK) { |
61 | ISR(USART1_RX_vect, ISR_BLOCK) { |
62 | } |
62 | } |
63 | 63 | ||
64 | 64 | ||
65 | 65 | ||
66 | #endif // __AVR_ATmega644P__ |
66 | #endif // __AVR_ATmega644P__ |
67 | 67 |