aboutsummaryrefslogtreecommitdiff
path: root/on.c
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-05-19 17:12:28 -0400
committerHolden Rohrer <hr@hrhr.dev>2020-05-19 17:12:28 -0400
commit64b8d034d0ba426ca5d2ef8a86d4611f0eb05ebf (patch)
tree081695d73fdb3f04b8cabd348d65b0cf71b74b8d /on.c
initial commit
Diffstat (limited to 'on.c')
-rw-r--r--on.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/on.c b/on.c
new file mode 100644
index 0000000..c1f43ab
--- /dev/null
+++ b/on.c
@@ -0,0 +1,32 @@
+#define __AVR_ATmega328P__
+#include <avr/io.h>
+#define F_CPU 16000000UL
+#include <util/delay.h>
+
+typedef enum { false, true } bool;
+
+typedef enum { INSTRUCTION, DATA = 2 } regselect;
+typedef enum { WRITE, READ } readwrite;
+
+static void setregrw(regselect reg, readwrite rw){
+ PORTC = (PORTC & ~3) | reg | rw;
+}
+
+#define enablepin(val) val ? (PORTC |= 4) : (PORTC &= ~4);
+
+static void wdata(uint8_t data){
+ DDRD |= 0xF0;
+ enablepin(true);
+ PORTD = data;
+ __asm__ ("nop;");
+ enablepin(false);
+}
+
+int main(){
+ DDRC = 0x07;
+ DDRD = 0x08;
+ //PORTD = 0x08;
+ _delay_ms(10000);
+ return 0;
+}
+