From 64b8d034d0ba426ca5d2ef8a86d4611f0eb05ebf Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Tue, 19 May 2020 17:12:28 -0400
Subject: initial commit
---
on.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 on.c
(limited to 'on.c')
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
+#define F_CPU 16000000UL
+#include
+
+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;
+}
+
--
cgit