diff --git a/test/rx/main.cpp b/test/rx/main.cpp index 8637985..10b8d0c 100644 --- a/test/rx/main.cpp +++ b/test/rx/main.cpp @@ -8,7 +8,7 @@ */ #define F_CPU 8000000UL #include "../../src/mrf24j.h" -#include "../../lib/usart/src/usart.h" +#include "../usart.h" #include #include diff --git a/test/tx/main.cpp b/test/tx/main.cpp index c3cc9f4..56cf8f1 100644 --- a/test/tx/main.cpp +++ b/test/tx/main.cpp @@ -9,7 +9,7 @@ #define F_CPU 8000000UL #include "../../src/mrf24j.h" -#include "../../lib/usart/src/usart.h" +#include "../usart.h" #include "../../src/driver.h" #include #include diff --git a/test/usart.cpp b/test/usart.cpp new file mode 100644 index 0000000..65b6719 --- /dev/null +++ b/test/usart.cpp @@ -0,0 +1,65 @@ +#include +#include +#include "usart.h" + +namespace usart +{ + namespace { + static FILE mystdout; + } + + void init( unsigned long baud) { + fdev_setup_stream(&mystdout, put_printf, NULL, _FDEV_SETUP_WRITE); + stdout = &mystdout; + const unsigned int ubrr = F_CPU/8/baud-1; + + /*Set baud rate */ + + + #if defined __AVR_ATmega328P__ + UBRR0H = (unsigned char)(ubrr>>8); + UBRR0L = (unsigned char)ubrr; + UCSR0A |= (1<>8); + UBRRL = (unsigned char)ubrr; + UCSRA |= (1< + +namespace usart +{ + void init(unsigned long baud); + void put(char data ); + char get(); + int put_printf(char var, FILE *stream); +} // namespace usart + + +