-
-
Save tlindner/431bd2bea2ccb47da53cf10e59fedb0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This sketch emulate a byte of RAM on the CoCo bus. */ | |
/* The single byte is located in the SCS range: FF40 to FF5f */ | |
#define SCS 0 | |
#define RW 1 | |
volatile unsigned int value = 255; | |
const int data_bus[] = {15, 22, 23, 9, 10, 13, 11, 12}; | |
void setup() { | |
/* setup data bus as input */ | |
for( unsigned int i=0; i<8; i++ ) { | |
pinMode(data_bus[i], INPUT); | |
} | |
pinMode(SCS, INPUT); | |
pinMode(RW, INPUT); | |
pinMode(SCS, INPUT); | |
attachInterrupt(SCS, check_io, FALLING); | |
attachInterrupt(SCS, z_state, RISING); | |
} | |
void loop() { | |
} | |
void check_io() { | |
if (digitalRead(RW)) { | |
for( unsigned int i=0; i<8; i++ ) { | |
pinMode(data_bus[i], OUTPUT); | |
} | |
GPIOC_PDOR = value; | |
} | |
else { | |
value = GPIOC_PDIR & 0xff; | |
} | |
} | |
void z_state() | |
{ | |
GPIOC_PDOR = 0; | |
for( unsigned int i=0; i<8; i++ ) { | |
pinMode(data_bus[i], INPUT); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment