mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-27 17:18:05 +11:00
97a46a7b9b
My idea of plugging a RC2014 bridge directly onto a Sega Master System cartridge doesn't work. The SMS eats all I/O addr space, we can't use it. Therefore, this naive idea, in the emulator, of reusing sdc.c in sms.c as-is, doesn't work either. I'll have to find another way of communicating to a SPI device on the SMS. I'll probably do it through a controller port. Meanwhile, I need to decouple SPI from SDC in the emulator code so that I can reuse sdc.c. This is what is done here.
18 lines
402 B
C
18 lines
402 B
C
#include "emul.h"
|
|
|
|
/* Emulates a SPI relay designed for the RC2014, enabled by poking on the CTL
|
|
port, then allowing a SPI exchange by writing to, then reading from, the
|
|
data port.
|
|
*/
|
|
|
|
typedef struct {
|
|
bool selected;
|
|
byte resp;
|
|
EXCH spixfn;
|
|
} SPI;
|
|
|
|
void spi_init(SPI *spi, EXCH spixfn);
|
|
void spi_ctl_wr(SPI *spi, byte val);
|
|
void spi_wr(SPI *spi, byte val);
|
|
byte spi_rd(SPI *spi);
|