diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-05-19 17:12:28 -0400 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-05-19 17:12:28 -0400 |
commit | 64b8d034d0ba426ca5d2ef8a86d4611f0eb05ebf (patch) | |
tree | 081695d73fdb3f04b8cabd348d65b0cf71b74b8d /on.c |
initial commit
Diffstat (limited to 'on.c')
-rw-r--r-- | on.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -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; +} + |