summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2014-07-28 22:55:18 +0300
committerYuval Adam <yuv.adm@gmail.com>2014-07-28 22:55:18 +0300
commita0e3f0373ddea97beeb64270db3d5dd91e1bbc0c (patch)
treea152dabd49ffb8b4ae99b2ea821d5c050542dbd4
Initial code
-rw-r--r--.gitignore3
-rw-r--r--Makefile9
-rw-r--r--README.md36
-rw-r--r--hello.c48
4 files changed, 96 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..01927f8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.hex
+*.o
+*.swp
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..8df710b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,9 @@
+
+default:
+ # compile for attiny86 with warnings, optimizations, and 1 MHz clock frequency
+ avr-gcc -Wall -Os -DF_CPU=1000000 -mmcu=attiny85 -o hello.o hello.c
+ avr-objcopy -j .text -j .data -O ihex hello.o hello.hex
+ avrdude -c usbasp -p t85 -U flash:w:hello.hex:i
+
+clean: /dev/null
+ rm -f hello.o hello.hex
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4fae5e4
--- /dev/null
+++ b/README.md
@@ -0,0 +1,36 @@
+# ATtiny85 Blink
+
+Runs on the Tel Aviv Makers ATtami board.
+
+## Prerequisites
+
+ - AVR GCC
+ - ATMEL USB ISP (USBASP) programmer
+
+Recommended to use the following udev rule:
+
+```bash
+$ cat /etc/udev/rules.d/98-usbasp.rules
+SUBSYSTEM=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", GROUP="users", MODE="0666"
+```
+
+## Usage
+
+Connect the following pins:
+
+ - Vcc
+ - Ground
+ - PB0 -- MOSI
+ - PB1 -- MISO
+ - PB2 -- SCK
+ - PB5 -- RST
+
+Then, run:
+
+```bash
+$ make
+```
+## Credits
+
+Based on work done by https://github.com/casebeer/attiny85-hello-world
+
diff --git a/hello.c b/hello.c
new file mode 100644
index 0000000..e34ba06
--- /dev/null
+++ b/hello.c
@@ -0,0 +1,48 @@
+
+/**
+ *
+ * Blinking LED ATTiny85 "hello world"
+ *
+ * Following the tutorial at:
+ * http://www.instructables.com/id/Honey-I-Shrunk-the-Arduino-Moving-from-Arduino-t/?ALLSTEPS
+ *
+ */
+
+#include <avr/io.h>
+// F_CPU frequency to be defined at command line
+#include <util/delay.h>
+
+// LED is on pin 2, PB3
+#define LED PB3
+#define DELAY_MS 500
+
+int main () {
+ uint8_t high = 0;
+ uint16_t ms = 0;
+
+ // setup LED pin for output in port B's direction register
+ DDRB |= (1 << LED);
+
+ // set LED pin LOW
+ PORTB &= ~(1 << LED);
+
+ while (1) {
+ high = !high;
+
+ if (high) {
+ // set LED pin HIGH
+ PORTB |= (1 << LED);
+ } else {
+ // set LED pin LOW
+ PORTB &= ~(1 << LED);
+ }
+
+ // delay for 500 ms
+ for (ms = DELAY_MS; ms > 0; ms -= 10) {
+ _delay_ms(10);
+ }
+ }
+
+ return 0;
+}
+