aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-10-17 15:40:51 +0200
committerKarel Kočí <cynerd@email.cz>2015-10-17 15:40:51 +0200
commitb0d8f22f3492fbb3f6dc0e8026e63c803af59007 (patch)
treeeb9707612e87856962474885f2a18ae1621d214e /examples
parent8fa9db4244f4ee33aa47561c569edfa62fe37928 (diff)
downloadavr-ioe-b0d8f22f3492fbb3f6dc0e8026e63c803af59007.tar.gz
avr-ioe-b0d8f22f3492fbb3f6dc0e8026e63c803af59007.tar.bz2
avr-ioe-b0d8f22f3492fbb3f6dc0e8026e63c803af59007.zip
Complete commit of current work
Diffstat (limited to 'examples')
-rw-r--r--examples/dht22usart/dht22.c26
-rw-r--r--examples/dht22usart/makefile39
-rw-r--r--examples/spiblink/makefile3
-rw-r--r--examples/usartecho/makefile17
4 files changed, 78 insertions, 7 deletions
diff --git a/examples/dht22usart/dht22.c b/examples/dht22usart/dht22.c
new file mode 100644
index 0000000..97a91ee
--- /dev/null
+++ b/examples/dht22usart/dht22.c
@@ -0,0 +1,26 @@
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <string.h>
+#include "../../usart.h"
+#include "../../sensor_dht22.h"
+
+void rec(uint8_t data) {
+ if (data == '\r') {
+ // TODO read sensor and send data
+ }
+}
+
+const struct dht22_port dht22_ports[] = {
+ {&DDRC, &PORTC, &PINC, _BV(PORTC4), NULL, 0}
+};
+
+int main() {
+ //usart_async_open();
+ //sei();
+ //usart_receive = rec;
+ //dht22_init(0);
+
+ timer_init(COUNTER0_PWM);
+ while (1);
+}
diff --git a/examples/dht22usart/makefile b/examples/dht22usart/makefile
new file mode 100644
index 0000000..214aa63
--- /dev/null
+++ b/examples/dht22usart/makefile
@@ -0,0 +1,39 @@
+MAKEFLAGS += --no-builtin-rules
+
+MMCU = atmega328p
+F_CPU = 16000000L
+IOE_PREFIX = ../..
+IOE_SHORTOUTPUT=y
+IOE_CFLAGS = -Os -ffunction-sections -fdata-sections -fshort-enums -Wall \
+ -DF_CPU=$(F_CPU) -mmcu=$(MMCU) \
+ -DCONFIG_IOE_USART \
+ -DCONFIG_IOE_USART_OUTBUFFER_SIZE=64 \
+ -DCONFIG_IOE_USART_OUTBUFFER_MODE=0 \
+ -DCONFIG_IOE_USART_OUTFILE \
+ -DCONFIG_IOE_USART_BAUD=115200 \
+ -DCONFIG_IOE_USART_PARITY=USART_PARITY_NONE \
+ -DCONFIG_IOE_USART_STOPBIT=USART_STOPBIT_SINGLE \
+ -DCONFIG_IOE_USART_DATABITS=8 \
+ -DCONFIG_IOE_TIMERS \
+ -DCONFIG_IOE_SENSOR_DHT22
+
+all: dht22.hex
+ @echo Now you can flash dht22.hex to your chip.
+
+clean: ioeclean
+ $(RM) dht22.o
+ $(RM) dht22.elf dht22.hex
+
+include ../../avr-ioe.mk
+
+dht22.elf: %.elf: $(IOE_OBJ) dht22.o
+ @echo " LD $@"
+ @avr-gcc -Os -mmcu=$(MMCU) $^ -o $@
+
+dht22.hex: %.hex: %.elf
+ @echo " OBJCOPY $@"
+ @avr-objcopy -O ihex -R .eeprom $< $@
+
+dht22.o: %.o: %.c
+ @echo " CC $@"
+ @avr-gcc $(IOE_CFLAGS) -c -o $@ $<
diff --git a/examples/spiblink/makefile b/examples/spiblink/makefile
index bb3b94a..60ba9c9 100644
--- a/examples/spiblink/makefile
+++ b/examples/spiblink/makefile
@@ -4,7 +4,8 @@ MMCU = atmega328p
F_CPU = 16000000L
IOE_PREFIX = ../..
IOE_CFLAGS ?= -Os -ffunction-sections -fdata-sections -fshort-enums -g -Wall \
- -DF_CPU=$(F_CPU) -mmcu=$(MMCU)
+ -DF_CPU=$(F_CPU) -mmcu=$(MMCU) \
+ -DCONFIG_IOE_SPI
.PHONY: all
all: master.hex slave.hex
diff --git a/examples/usartecho/makefile b/examples/usartecho/makefile
index fa10cd2..15254c6 100644
--- a/examples/usartecho/makefile
+++ b/examples/usartecho/makefile
@@ -3,8 +3,10 @@ MAKEFLAGS += --no-builtin-rules
MMCU = atmega328p
F_CPU = 16000000L
IOE_PREFIX = ../..
-IOE_CFLAGS = -Os -ffunction-sections -fdata-sections -fshort-enums -Wall \
- -DF_CPU=$(F_CPU) -mmcu=$(MMCU) \
+IOE_SHORTOUTPUT=y
+IOE_CFLAGS = -Os -fshort-enums -Wall \
+ -DF_CPU=$(F_CPU) -mmcu=$(MMCU) \
+ -DCONFIG_IOE_USART \
-DCONFIG_IOE_USART_OUTBUFFER_SIZE=64 \
-DCONFIG_IOE_USART_OUTBUFFER_MODE=0 \
-DCONFIG_IOE_USART_BAUD=115200 \
@@ -21,11 +23,14 @@ clean: ioeclean
include ../../avr-ioe.mk
-usart.elf: %.elf: $(IOE_OBJ_USART) echo.o
- avr-gcc -mmcu=$(MMCU) $^ -o $@
+usart.elf: %.elf: $(IOE_OBJ) echo.o
+ @echo " LD $@"
+ @avr-gcc -Os -mmcu=$(MMCU) $^ -o $@
usart.hex: %.hex: %.elf
- avr-objcopy -O ihex -R .eeprom $< $@
+ @echo " OBJCOPY $@"
+ @avr-objcopy -O ihex -R .eeprom $< $@
echo.o: %.o: %.c
- avr-gcc $(IOE_CFLAGS) -c -o $@ $<
+ @echo " CC $@"
+ @avr-gcc $(IOE_CFLAGS) -c -o $@ $<