aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/usartecho/echo.c25
-rw-r--r--examples/usartecho/makefile29
-rwxr-xr-xexamples/usartecho/usart.elfbin0 -> 15401 bytes
-rw-r--r--examples/usartecho/usart.hex63
4 files changed, 117 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);
+}
+
+
diff --git a/examples/usartecho/makefile b/examples/usartecho/makefile
new file mode 100644
index 0000000..343addc
--- /dev/null
+++ b/examples/usartecho/makefile
@@ -0,0 +1,29 @@
+MAKEFLAGS += --no-builtin-rules
+
+MMCU = atmega328p
+F_CPU = 16000000L
+IOE_PREFIX = ../..
+IOE_CFLAGS = -Os -ffunction-sections -fdata-sections -fshort-enums -Wall -g \
+ -DCONFIG_IOE_USART_OUTBUFFER_SIZE=64 \
+ -DCONFIG_IOE_USART_OUTBUFFER_MODE=0
+
+all: usart.hex
+ @echo Flash usart.hex to chip
+
+install: usart.hex
+ # TODO
+
+clean: ioeclean
+ $(RM) echo.o
+ $(RM) usart.elf usart.hex
+
+include ../../avr-ioe.mk
+
+usart.elf: %.elf: $(IOE_OBJ_USART) echo.o
+ avr-gcc -mmcu=$(MMCU) $^ -o $@
+
+usart.hex: %.hex: %.elf
+ avr-objcopy -O ihex -R .eeprom $< $@
+
+echo.o: %.o: %.c
+ avr-gcc $(IOE_CFLAGS) -c -o $@ $<
diff --git a/examples/usartecho/usart.elf b/examples/usartecho/usart.elf
new file mode 100755
index 0000000..211d0e9
--- /dev/null
+++ b/examples/usartecho/usart.elf
Binary files differ
diff --git a/examples/usartecho/usart.hex b/examples/usartecho/usart.hex
new file mode 100644
index 0000000..0eb90f0
--- /dev/null
+++ b/examples/usartecho/usart.hex
@@ -0,0 +1,63 @@
+:100000000C943B000C9458000C9458000C9458002D
+:100010000C9458000C9458000C9458000C94580000
+:100020000C9458000C9458000C9458000C945800F0
+:100030000C9458000C9458000C9458000C945800E0
+:100040000C9458000C9458000C9441010C946C01D1
+:100050000C9458000C9458000C9458000C945800C0
+:100060000C9458000C94580065006A006E007200F1
+:1000700076007F00830011241FBECFEFD8E0DEBFE3
+:10008000CDBF11E0A0E0B1E0ECEBF3E002C00590E1
+:100090000D92A032B107D9F711E0A0E2B1E001C0A2
+:1000A0001D92A736B107E1F70E94B7010C94DC015D
+:1000B0000C9400001092660190E08730910568F57D
+:1000C000FC01EC5CFF4F0C94D60181E08093C500ED
+:1000D00080EA0FC01092C5008FEC0BC01092C500D3
+:1000E00087E607C01092C50083E303C01092C500E5
+:1000F00089E18093C4008091C0008D7F0CC0109274
+:10010000C50082E203C01092C50080E18093C40064
+:100110008091C00082608093C000613059F030F05F
+:10012000623091F48091C20080630CC08091C20063
+:100130008F7C08C08091C2008F7E8093C200809126
+:10014000C20080628093C200413031F0423049F4F5
+:100150008091C200886003C08091C200877F809335
+:10016000C200263079F030F42530F9F48091C200D5
+:10017000897F19C0273079F02830B9F48091C20006
+:10018000866011C08091C2008B7F8093C2008091F5
+:10019000C200826008C08091C2008D7F8093C2003F
+:1001A0008091C20084608093C20088EB8093C1007C
+:1001B0008FE38093250180932401089528E041E096
+:1001C00060E086E00C945A0090916601911106C09F
+:1001D00091E0909366018093C60008959091250167
+:1001E000911105C0909124019F33E1F30BC0409120
+:1001F00024012091250150E030E0215031094217BF
+:100200005307A9F3E0912501F0E0EC5DFE4F8283F6
+:1002100080912501811102C08FE303C080912501E7
+:100220008150809325010895CF93DF93EC0189914C
+:10023000882319F00E94E400FACFDF91CF9108954E
+:100240008091C0008C71089580916601089590910D
+:10025000250180912401981728F480912401909120
+:1002600025010BC09091250180912401891738F454
+:100270008091240190912501805C891B089580E084
+:1002800008951F920F920FB60F9211242F933F9350
+:100290004F935F936F937F938F939F93AF93BF938E
+:1002A000EF93FF93E0912201F0912301309719F031
+:1002B0008091C6000995FF91EF91BF91AF919F91F9
+:1002C0008F917F916F915F914F913F912F910F90FF
+:1002D0000FBE0F901F9018951F920F920FB60F929E
+:1002E00011242F933F934F935F936F937F938F933B
+:1002F0009F93AF93BF93EF93FF93909124018091CD
+:1003000025019817B1F0E0912401F0E0EC5DFE4F7B
+:10031000928180912401811102C08FE303C08091FA
+:100320002401815080932401992319F09093C600F1
+:1003300002C010926601E0912001F09121013097F6
+:1003400009F00995FF91EF91BF91AF919F918F9126
+:100350007F916F915F914F913F912F910F900FBEC1
+:100360000F901F90189581110C94E400089584B1AA
+:10037000866084B90E94DE008FB780688FBF81E6F7
+:100380000E94E40082E60E94E40083E60E94E4000A
+:1003900084E60E94E40080E091E00E94140183EB77
+:1003A00091E09093230180932201FFCFEE0FFF1F76
+:0C03B0000590F491E02D0994F894FFCF23
+:1003BC000A0D48656C6C6F2C207468657265206939
+:1003CC00732055415254206563686F210A0D00005B
+:00000001FF