52,23 → 52,24 |
#include <avr/interrupt.h> |
#include "main.h" |
#include "uart1.h" |
#include "fifo.h" |
#if defined (USE_KILLAGREG) || defined (USE_MK3MAG) |
#include "ubx.h" |
#define USART1_BAUD 57600 |
#else |
#ifdef USE_RC_DSL |
#include "dsl.h" |
#define USART1_BAUD 38400 |
#endif |
#ifdef USE_RC_SPECTRUM |
#include "spectrum.h" |
#define USART1_BAUD 115200 |
#endif |
#endif |
|
#ifndef USART1_BAUD |
#define USART1_BAUD 57600 |
#endif |
|
|
// FIFO-objects and buffers for input and output |
|
//#define BUFSIZE_IN 0x96 |
//volatile uint8_t inbuf[BUFSIZE_IN]; |
//fifo_t infifo; |
|
#define BUFSIZE_OUT 0x96 |
volatile uint8_t outbuf[BUFSIZE_OUT]; |
fifo_t outfifo; |
|
/****************************************************************/ |
/* Initialization of the USART1 */ |
/****************************************************************/ |
126,7 → 127,7 |
// enable RX-Interrupt |
UCSR1B |= (1 << RXCIE1); |
// enable TX-Interrupt |
UCSR1B |= (1 << TXCIE1); |
//UCSR1B |= (1 << TXCIE1); |
// enable DRE interrupt |
//UCSR1B |= (1 << UDRIE1); |
|
134,44 → 135,16 |
// restore global interrupt flags |
SREG = sreg; |
|
// inint FIFO buffer |
//fifo_init (&infifo, inbuf, BUFSIZE_IN); |
//fifo_init (&outfifo, outbuf, BUFSIZE_OUT); |
} |
|
/*int16_t USART1_putc (const uint8_t c) |
{ |
int16_t ret = fifo_put (&outfifo, c); |
// create an data register empty interrupt |
UCSR1B |= (1 << UDRIE1); |
|
return ret; |
} |
*/ |
/*int16_t USART1_getc_nowait () |
{ |
return fifo_get_nowait (&infifo); |
} |
|
|
uint8_t USART1_getc_wait () |
{ |
return fifo_get_wait (&infifo); |
} |
*/ |
|
/****************************************************************/ |
/* USART1 data register empty ISR */ |
/****************************************************************/ |
/*ISR(USART1_UDRE_vect) |
{ |
// Move a character from the output buffer to the data register. |
// When the character was processed the next interrupt is generated. |
// If the output buffer is empty the DRE-interrupt is disabled. |
if (outfifo.count > 0) |
UDR1 = _inline_fifo_get (&outfifo); |
else |
UCSR1B &= ~(1 << UDRIE1); |
|
} |
*/ |
|
192,5 → 165,12 |
c = UDR1; // get data byte |
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
ubx_parser(c); // and put it into the ubx protocol parser |
#else |
#ifdef USE_RC_DSL |
dsl_parser(c); // parse dsl data stream |
#endif |
#ifdef USE_RC_SPECTRUM |
spectrum_parser(c); // parse spectrum data stream |
#endif |
#endif |
} |