changeset 0:1569a3836dfb draft

Initial code
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Thu, 16 Aug 2018 15:58:28 +0200
parents
children ef081b9d021c
files code/Makefile code/main.c
diffstat 2 files changed, 101 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/code/Makefile	Thu Aug 16 15:58:28 2018 +0200
@@ -0,0 +1,49 @@
+DEVICE      = attiny85
+CLOCK      = 1000000
+PROGRAMMER = -c usbasp
+OBJECTS    = main.o
+
+# for ATTiny85
+# see http://www.engbedded.com/fusecalc/
+FUSES       = -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
+
+# Tune the lines below only if you know what you are doing:
+AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) -B 1200
+COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
+
+# symbolic targets:
+all:	main.hex
+
+.c.o:
+	$(COMPILE) -c $< -o $@
+
+.S.o:
+	$(COMPILE) -x assembler-with-cpp -c $< -o $@
+
+.c.s:
+	$(COMPILE) -S $< -o $@
+
+flash:	all
+	$(AVRDUDE) -U flash:w:main.hex:i
+
+fuse:
+	$(AVRDUDE) $(FUSES)
+
+# Xcode uses the Makefile targets "", "clean" and "install"
+install: flash fuse
+
+# if you use a bootloader, change the command below appropriately:
+load: all
+	bootloadHID main.hex
+
+clean:
+	rm -f main.hex main.elf $(OBJECTS)
+
+# file targets:
+main.elf: $(OBJECTS)
+	$(COMPILE) -o main.elf $(OBJECTS)
+
+main.hex: main.elf
+	rm -f main.hex
+	avr-objcopy -j .text -j .data -O ihex main.elf main.hex
+	avr-size --format=avr --mcu=$(DEVICE) main.elf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/code/main.c	Thu Aug 16 15:58:28 2018 +0200
@@ -0,0 +1,52 @@
+#include <avr/io.h>
+#include <avr/pgmspace.h>
+#include <util/delay.h>
+
+#define byte unsigned char
+
+#define COL0 PB0
+#define COL1 PB4
+#define COL2 PB1
+#define COL3 PB3
+#define COL4 PB2
+
+const byte PROGMEM VALUES[] = {
+    (COL0 << 4) | COL4,
+    (COL0 << 4) | COL3,
+    (COL0 << 4) | COL2,
+    (COL0 << 4) | COL1,
+
+    (COL1 << 4) | COL4,
+    (COL1 << 4) | COL3,
+    (COL1 << 4) | COL2,
+    (COL1 << 4) | COL0,
+
+    (COL2 << 4) | COL4,
+    (COL2 << 4) | COL3,
+    (COL2 << 4) | COL1,
+    (COL2 << 4) | COL0,
+
+    (COL3 << 4) | COL4,
+    (COL3 << 4) | COL2,
+    (COL3 << 4) | COL1,
+    (COL3 << 4) | COL0,
+
+    (COL4 << 4) | COL3,
+    (COL4 << 4) | COL2,
+    (COL4 << 4) | COL1,
+    (COL4 << 4) | COL0,
+};
+
+
+int main() {
+    while(1) {
+        for (byte i=0; i<20; ++i) {
+            byte value = pgm_read_byte_near(VALUES + i);
+            DDRB = _BV(value & 0x0f) | _BV(value >> 4);
+            PORTB = _BV(value >> 4);
+            _delay_ms(20);
+        }
+        DDRB = 0;
+        _delay_ms(800);
+    }
+}