Skip to content

Instantly share code, notes, and snippets.

@tlindner
Created October 12, 2020 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlindner/431bd2bea2ccb47da53cf10e59fedb0e to your computer and use it in GitHub Desktop.
Save tlindner/431bd2bea2ccb47da53cf10e59fedb0e to your computer and use it in GitHub Desktop.
/* 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