From 62c4883af719f5bacd197257387a0071c625e469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 11 Oct 2015 14:13:02 +0200 Subject: Replace usart initialization parameters with configuration Baudrate and other configurations are now defined in compile time by preprocessor flags. This simplifies output code. --- examples/usartecho/echo.c | 9 ++++++--- examples/usartecho/makefile | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'examples/usartecho') 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; diff --git a/examples/usartecho/makefile b/examples/usartecho/makefile index 7475127..48a713c 100644 --- a/examples/usartecho/makefile +++ b/examples/usartecho/makefile @@ -5,10 +5,14 @@ F_CPU = 16000000L IOE_PREFIX = ../.. IOE_CFLAGS = -Os -ffunction-sections -fdata-sections -fshort-enums -Wall \ -DCONFIG_IOE_USART_OUTBUFFER_SIZE=64 \ - -DCONFIG_IOE_USART_OUTBUFFER_MODE=0 + -DCONFIG_IOE_USART_OUTBUFFER_MODE=0 \ + -DCONFIG_IOE_USART_BAUD=115200 \ + -DCONFIG_IOE_USART_PARITY=USART_PARITY_NONE \ + -DCONFIG_IOE_USART_STOPBIT=USART_STOPBIT_SINGLE \ + -DCONFIG_IOE_USART_DATABITS=8 all: usart.hex - @echo Flash usart.hex to chip + @echo Now you can flash usart.hex to your chip. clean: ioeclean $(RM) echo.o -- cgit v1.2.3