diff --git a/sdcard/apple1_sdcard/apple1_sdcard.ino b/sdcard/apple1_sdcard/apple1_sdcard.ino new file mode 100644 index 0000000..234de32 --- /dev/null +++ b/sdcard/apple1_sdcard/apple1_sdcard.ino @@ -0,0 +1,133 @@ +// pin definitions + +// VIA 6522 connections + +#define D0 1 /* I/O data bit 0, connects to PA0 on the VIA */ +#define D1 2 /* I/O data bit 1, connects to PA1 on the VIA */ +#define D2 3 /* I/O data bit 2, connects to PA2 on the VIA */ +#define D3 4 /* I/O data bit 3, connects to PA3 on the VIA */ +#define D4 5 /* I/O data bit 4, connects to PA4 on the VIA */ +#define D5 6 /* I/O data bit 5, connects to PA5 on the VIA */ +#define D6 7 /* I/O data bit 6, connects to PA6 on the VIA */ +#define D7 8 /* I/O data bit 7, connects to PA7 on the VIA */ + +#define CPU_CLOCK 9 /* cpu send data clock, VIA.PB0 => MCU */ +#define MCU_CLOCK 10 /* mcu send data clock, VIA.PB1 <= MCU */ + +// utility function for read a bit +#define BIT(data,n) (((data) >> (n)) & 1) + +void setup() { + // debug on serial + Serial.begin(9600); + + pinMode(CPU_CLOCK, INPUT); + pinMode(MCU_CLOCK, OUTPUT); +} + +void loop() { + // applicazione di esempio: manda un messaggio quando riceve il comando 42 + int data = receive_byte_from_cpu(); + + if(data == 42) { + Serial.println("command 42 received from CPU"); + char *msg = "HELLO WORLD!\r\n"; + for(int t=0; t