1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-10 02:28:06 +11:00
collapseos/emul/z80/rc2014_spi.c

29 lines
517 B
C
Raw Normal View History

#include "rc2014_spi.h"
void spi_init(SPI *spi, EXCH spixfn)
{
spi->selected = false;
spi->resp = 0xff;
spi->spixfn = spixfn;
}
// TODO: for now, any nonzero value enables the SPI. To allow
// emulation of systems with multi-devices SPI relay, change
// this.
void spi_ctl_wr(SPI *spi, byte val)
{
spi->selected = val;
}
void spi_wr(SPI *spi, byte val)
{
if (spi->selected) {
spi->resp = spi->spixfn(val);
}
}
byte spi_rd(SPI *spi)
{
return spi->selected ? spi->resp : 0xff;
}