Rev 1180 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1180 | Rev 1199 | ||
---|---|---|---|
Line 50... | Line 50... | ||
50 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
50 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
51 | #include <avr/io.h> |
51 | #include <avr/io.h> |
52 | #include <avr/interrupt.h> |
52 | #include <avr/interrupt.h> |
53 | #include "main.h" |
53 | #include "main.h" |
54 | #include "uart1.h" |
54 | #include "uart1.h" |
55 | #include "fifo.h" |
- | |
56 | #if defined (USE_KILLAGREG) || defined (USE_MK3MAG) |
55 | #if defined (USE_KILLAGREG) || defined (USE_MK3MAG) |
57 | #include "ubx.h" |
56 | #include "ubx.h" |
- | 57 | #define USART1_BAUD 57600 |
|
- | 58 | #else |
|
- | 59 | #ifdef USE_RC_DSL |
|
- | 60 | #include "dsl.h" |
|
- | 61 | #define USART1_BAUD 38400 |
|
- | 62 | #endif |
|
- | 63 | #ifdef USE_RC_SPECTRUM |
|
- | 64 | #include "spectrum.h" |
|
- | 65 | #define USART1_BAUD 115200 |
|
- | 66 | #endif |
|
58 | #endif |
67 | #endif |
Line 59... | Line -... | ||
59 | - | ||
60 | - | ||
61 | - | ||
62 | // FIFO-objects and buffers for input and output |
- | |
63 | 68 | ||
64 | //#define BUFSIZE_IN 0x96 |
- | |
65 | //volatile uint8_t inbuf[BUFSIZE_IN]; |
- | |
66 | //fifo_t infifo; |
- | |
67 | 69 | #ifndef USART1_BAUD |
|
68 | #define BUFSIZE_OUT 0x96 |
- | |
69 | volatile uint8_t outbuf[BUFSIZE_OUT]; |
70 | #define USART1_BAUD 57600 |
Line 70... | Line 71... | ||
70 | fifo_t outfifo; |
71 | #endif |
71 | 72 | ||
72 | /****************************************************************/ |
73 | /****************************************************************/ |
73 | /* Initialization of the USART1 */ |
74 | /* Initialization of the USART1 */ |
Line 124... | Line 125... | ||
124 | 125 | ||
125 | // enable interrupts at the end |
126 | // enable interrupts at the end |
126 | // enable RX-Interrupt |
127 | // enable RX-Interrupt |
127 | UCSR1B |= (1 << RXCIE1); |
128 | UCSR1B |= (1 << RXCIE1); |
128 | // enable TX-Interrupt |
129 | // enable TX-Interrupt |
129 | UCSR1B |= (1 << TXCIE1); |
130 | //UCSR1B |= (1 << TXCIE1); |
130 | // enable DRE interrupt |
131 | // enable DRE interrupt |
Line 131... | Line 132... | ||
131 | //UCSR1B |= (1 << UDRIE1); |
132 | //UCSR1B |= (1 << UDRIE1); |
132 | 133 | ||
Line 133... | Line -... | ||
133 | - | ||
134 | // restore global interrupt flags |
- | |
135 | SREG = sreg; |
- | |
136 | 134 | ||
Line 137... | Line -... | ||
137 | // inint FIFO buffer |
- | |
138 | //fifo_init (&infifo, inbuf, BUFSIZE_IN); |
- | |
139 | //fifo_init (&outfifo, outbuf, BUFSIZE_OUT); |
- | |
140 | } |
- | |
141 | - | ||
142 | /*int16_t USART1_putc (const uint8_t c) |
- | |
143 | { |
- | |
144 | int16_t ret = fifo_put (&outfifo, c); |
- | |
145 | // create an data register empty interrupt |
- | |
146 | UCSR1B |= (1 << UDRIE1); |
- | |
147 | - | ||
148 | return ret; |
- | |
149 | } |
- | |
Line 150... | Line -... | ||
150 | */ |
- | |
151 | /*int16_t USART1_getc_nowait () |
- | |
152 | { |
- | |
153 | return fifo_get_nowait (&infifo); |
- | |
154 | } |
- | |
155 | - | ||
156 | 135 | // restore global interrupt flags |
|
157 | uint8_t USART1_getc_wait () |
136 | SREG = sreg; |
158 | { |
137 | |
159 | return fifo_get_wait (&infifo); |
138 | } |
160 | } |
139 | |
161 | */ |
- | |
162 | - | ||
163 | /****************************************************************/ |
- | |
164 | /* USART1 data register empty ISR */ |
- | |
165 | /****************************************************************/ |
- | |
166 | /*ISR(USART1_UDRE_vect) |
140 | |
167 | { |
- | |
168 | // Move a character from the output buffer to the data register. |
141 | |
169 | // When the character was processed the next interrupt is generated. |
142 | /****************************************************************/ |
Line 170... | Line 143... | ||
170 | // If the output buffer is empty the DRE-interrupt is disabled. |
143 | /* USART1 data register empty ISR */ |
171 | if (outfifo.count > 0) |
144 | /****************************************************************/ |
Line 189... | Line 162... | ||
189 | ISR(USART1_RX_vect) |
162 | ISR(USART1_RX_vect) |
190 | { |
163 | { |
191 | uint8_t c; |
164 | uint8_t c; |
192 | c = UDR1; // get data byte |
165 | c = UDR1; // get data byte |
193 | #if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
166 | #if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
194 | ubx_parser(c); // and put it into the ubx protocol parser |
167 | ubx_parser(c); // and put it into the ubx protocol parser |
- | 168 | #else |
|
- | 169 | #ifdef USE_RC_DSL |
|
- | 170 | dsl_parser(c); // parse dsl data stream |
|
- | 171 | #endif |
|
- | 172 | #ifdef USE_RC_SPECTRUM |
|
- | 173 | spectrum_parser(c); // parse spectrum data stream |
|
- | 174 | #endif |
|
195 | #endif |
175 | #endif |
196 | } |
176 | } |