aboutsummaryrefslogtreecommitdiff
path: root/examples/usartecho/echo.c
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-10-08 20:59:26 +0200
committerKarel Kočí <cynerd@email.cz>2015-10-08 20:59:26 +0200
commitacdd758e56e28f22846e7d34d87f5533c8682574 (patch)
treed8fda0b554e99d6ace98a9300ecb5835b5bf50e0 /examples/usartecho/echo.c
parent0b534d81ac39eb5bbf2b9a0691519f6f7f0eaa13 (diff)
downloadavr-ioe-acdd758e56e28f22846e7d34d87f5533c8682574.tar.gz
avr-ioe-acdd758e56e28f22846e7d34d87f5533c8682574.tar.bz2
avr-ioe-acdd758e56e28f22846e7d34d87f5533c8682574.zip
Add implementation of USART and more ground changes
Diffstat (limited to 'examples/usartecho/echo.c')
-rw-r--r--examples/usartecho/echo.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/usartecho/echo.c b/examples/usartecho/echo.c
new file mode 100644
index 0000000..4d978f7
--- /dev/null
+++ b/examples/usartecho/echo.c
@@ -0,0 +1,25 @@
+#include <avr/io.h>
+#include <util/delay.h>
+#include <string.h>
+#include "../../usart.h"
+
+void rec(uint8_t data) {
+ if (data)
+ usart_send(data);
+}
+
+int main() {
+ DDRB |= _BV(DDB1) | _BV(DDB2);
+ usart_init_uart();
+ SREG |= _BV(7);
+ usart_send('a');
+ usart_send('b');
+ usart_send('c');
+ usart_send('d');
+ usart_send_str("\n\rHello, there is UART echo!\n\r");
+ usart_receive = rec;
+
+ while (1);
+}
+
+