+/*
+ * Waking Up Ogion
+ *
+ * (c) 2013 Martin Mares <mj@ucw.cz>
+ */
+
+/*
+ * Pin assignment (component side view; "*" marks inverted signals)
+ *
+ * +-------------------+
+ * | RESET* VCC |
+ * output RESET* | PB3 SCK |
+ * diagnostic LED* | PB4 MISO |
+ * | GND MOSI |
+ * +-------------------+
+ */
+
+#define F_CPU 1200000UL
+
+#include <avr/io.h>
+#include <avr/sleep.h>
+#include <util/delay.h>
+
+typedef uint8_t byte;
+
+#define B(x) (1U<<(x))
+
+static void sleep(uint16_t millisec)
+{
+ while (millisec) {
+ _delay_ms(1);
+ millisec--;
+ }
+}
+
+int main(void)
+{
+ PORTB &= ~B(PB3); // PB3: tri-stated
+ DDRB |= B(PB4); // PB4: output
+
+ for (byte i=0; i<5; i++) {
+ PORTB &= ~B(PB4);
+ sleep(100);
+ PORTB |= B(PB4);
+ sleep(900);
+ }
+
+ PORTB &= ~B(PB4);
+ DDRB |= B(PB3); // PB3: output 0
+ sleep(300);
+ DDRB &= ~B(PB3); // PB3: tri-state
+ PORTB |= B(PB4);
+
+ for (;;) {
+ set_sleep_mode(SLEEP_MODE_PWR_DOWN);
+ sleep_mode();
+ }
+}