aboutsummaryrefslogtreecommitdiff
path: root/examples/usartecho/echo.c
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-10-11 14:13:02 +0200
committerKarel Kočí <cynerd@email.cz>2015-10-11 14:16:52 +0200
commit62c4883af719f5bacd197257387a0071c625e469 (patch)
treec8f37c013c8263f818375d5b45606c10584a7646 /examples/usartecho/echo.c
parent861ed124caf5a403748c948b88afa4ef89cc1787 (diff)
downloadavr-ioe-62c4883af719f5bacd197257387a0071c625e469.tar.gz
avr-ioe-62c4883af719f5bacd197257387a0071c625e469.tar.bz2
avr-ioe-62c4883af719f5bacd197257387a0071c625e469.zip
Replace usart initialization parameters with configuration
Baudrate and other configurations are now defined in compile time by preprocessor flags. This simplifies output code.
Diffstat (limited to 'examples/usartecho/echo.c')
-rw-r--r--examples/usartecho/echo.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/usartecho/echo.c b/examples/usartecho/echo.c
index 4ba9364..12b88f6 100644
--- a/examples/usartecho/echo.c
+++ b/examples/usartecho/echo.c
@@ -4,16 +4,19 @@
#include "../../usart.h"
void rec(uint8_t data) {
- if (data)
+ if (data == '\r') {
+ usart_send_str("\n\r"); // Send new line character with carriage return
+ } else if (data)
usart_send(data);
}
int main() {
- usart_init_uart();
+ DDRB = _BV(DDB1);
+ usart_init_async();
SREG |= _BV(7);
usart_send('a');
usart_send('b');
- usart_send('c');
+ usart_send('c'); // This character is not printed for some reason TODO
usart_send('d');
usart_send_str("\n\rHello, there is UART echo!\n\r");
usart_receive = rec;