st2xxx: Add some SPI stubs

This commit is contained in:
AJR 2020-09-08 15:03:49 -04:00
parent 49024d783a
commit 61fb20463b
6 changed files with 100 additions and 0 deletions

View File

@ -152,6 +152,9 @@ void st2204_device::device_start()
state_add(ST_LFRA, "LFRA", m_lfra).mask(0x3f);
state_add(ST_LAC, "LAC", m_lac).mask(0x1f);
state_add(ST_LPWM, "LPWM", m_lpwm).mask(st2xxx_lpwm_mask());
state_add(ST_SCTR, "SCTR", m_sctr);
state_add(ST_SCKR, "SCKR", m_sckr).mask(0x7f);
state_add(ST_SSR, "SSR", m_ssr).mask(0x77);
state_add(ST_UCTR, "UCTR", m_uctr).mask(st2xxx_uctr_mask());
state_add(ST_USR, "USTR", m_usr).mask(0x7f);
state_add(ST_IRCTR, "IRCTR", m_irctr).mask(0xc7);
@ -683,6 +686,9 @@ void st2204_device::common_map(address_map &map)
map(0x004c, 0x004c).rw(FUNC(st2204_device::pl_r), FUNC(st2204_device::pl_w));
// PCL is listed as write-only in ST2202 specification, but DynamiDesk suggests otherwise
map(0x004e, 0x004e).rw(FUNC(st2204_device::pcl_r), FUNC(st2204_device::pcl_w));
map(0x0052, 0x0052).rw(FUNC(st2204_device::sctr_r), FUNC(st2204_device::sctr_w));
map(0x0053, 0x0053).rw(FUNC(st2204_device::sckr_r), FUNC(st2204_device::sckr_w));
map(0x0054, 0x0054).rw(FUNC(st2204_device::ssr_r), FUNC(st2204_device::ssr_w));
map(0x0060, 0x0060).rw(FUNC(st2204_device::uctr_r), FUNC(st2204_device::uctr_w));
map(0x0061, 0x0061).rw(FUNC(st2204_device::usr_r), FUNC(st2204_device::ustr_trg_w));
map(0x0062, 0x0062).rw(FUNC(st2204_device::irctr_r), FUNC(st2204_device::irctr_w));

View File

@ -56,6 +56,7 @@ protected:
virtual u8 st2xxx_lckr_mask() const override { return 0x1f; }
virtual u8 st2xxx_lpwm_mask() const override { return 0x3f; }
virtual unsigned st2xxx_lfr_clocks() const override;
virtual bool st2xxx_has_spi() const override { return true; }
virtual u8 st2xxx_uctr_mask() const override { return 0x0f; }
virtual u8 st2xxx_bctr_mask() const override { return 0x87; }

View File

@ -155,6 +155,10 @@ void st2205u_device::device_start()
state_add(ST_LFRA, "LFRA", m_lfra).mask(0x3f);
state_add(ST_LAC, "LAC", m_lac).mask(0x1f);
state_add(ST_LPWM, "LPWM", m_lpwm).mask(st2xxx_lpwm_mask());
state_add(ST_SCTR, "SCTR", m_sctr);
state_add(ST_SCKR, "SCKR", m_sckr).mask(0x7f);
state_add(ST_SSR, "SSR", m_ssr).mask(0x77);
state_add(ST_SMOD, "SMOD", m_smod).mask(0x0f);
state_add(ST_UCTR, "UCTR", m_uctr).mask(st2xxx_uctr_mask());
state_add(ST_USR, "USR", m_usr).mask(0x7f);
state_add(ST_IRCTR, "IRCTR", m_irctr).mask(0xc7);
@ -731,6 +735,10 @@ void st2205u_device::int_map(address_map &map)
map(0x004c, 0x004c).w(FUNC(st2205u_device::lpal_w));
map(0x004e, 0x004e).rw(FUNC(st2205u_device::pl_r), FUNC(st2205u_device::pl_w));
map(0x004f, 0x004f).rw(FUNC(st2205u_device::pcl_r), FUNC(st2205u_device::pcl_w));
map(0x0052, 0x0052).rw(FUNC(st2205u_device::sctr_r), FUNC(st2205u_device::sctr_w));
map(0x0053, 0x0053).rw(FUNC(st2205u_device::sckr_r), FUNC(st2205u_device::sckr_w));
map(0x0054, 0x0054).rw(FUNC(st2205u_device::ssr_r), FUNC(st2205u_device::ssr_w));
map(0x0055, 0x0055).rw(FUNC(st2205u_device::smod_r), FUNC(st2205u_device::smod_w));
map(0x0057, 0x0057).rw(FUNC(st2205u_device::lvctr_r), FUNC(st2205u_device::lvctr_w));
map(0x0058, 0x0058).rw(FUNC(st2205u_device::dptrl_r), FUNC(st2205u_device::dptrl_w));
map(0x0059, 0x0059).rw(FUNC(st2205u_device::dptrh_r), FUNC(st2205u_device::dptrh_w));

View File

@ -79,6 +79,8 @@ protected:
virtual u8 st2xxx_lckr_mask() const override { return 0x3f; }
virtual u8 st2xxx_lpwm_mask() const override { return 0xff; }
virtual unsigned st2xxx_lfr_clocks() const override;
virtual bool st2xxx_has_spi() const override { return true; }
virtual bool st2xxx_spi_iis() const override { return true; }
virtual u8 st2xxx_uctr_mask() const override { return 0x3f; }
virtual u8 st2xxx_bctr_mask() const override { return 0xb7; }

View File

@ -69,6 +69,10 @@ st2xxx_device::st2xxx_device(const machine_config &mconfig, device_type type, co
, m_lpwm(0)
, m_lcd_ireq(0)
, m_lcd_timer(nullptr)
, m_sctr(0)
, m_sckr(0)
, m_ssr(0)
, m_smod(0)
, m_uctr(0)
, m_usr(0)
, m_irctr(0)
@ -186,6 +190,14 @@ void st2xxx_device::save_common_registers()
save_item(NAME(m_lfra));
save_item(NAME(m_lac));
save_item(NAME(m_lpwm));
if (st2xxx_has_spi())
{
save_item(NAME(m_sctr));
save_item(NAME(m_sckr));
save_item(NAME(m_ssr));
if (st2xxx_spi_iis())
save_item(NAME(m_smod));
}
if (st2xxx_uctr_mask() != 0)
{
save_item(NAME(m_uctr));
@ -246,6 +258,12 @@ void st2xxx_device::device_reset()
m_lpwm = 0;
m_lcd_timer->adjust(attotime::never);
// reset SPI
m_sctr = 0;
m_sckr = 0;
m_ssr = 0;
m_smod = 0;
// reset UART and BRG
m_uctr = 0;
m_usr = BIT(st2xxx_uctr_mask(), 4) ? 0x01 : 0;
@ -758,6 +776,51 @@ void st2xxx_device::lpwm_w(u8 data)
m_lpwm = data & st2xxx_lpwm_mask();
}
u8 st2xxx_device::sctr_r()
{
return m_sctr;
}
void st2xxx_device::sctr_w(u8 data)
{
// TXEMP on wakeup?
if (!BIT(m_sctr, 7) && BIT(data, 7))
m_ssr |= 0x20;
m_sctr = data;
}
u8 st2xxx_device::sckr_r()
{
return m_sckr | 0x80;
}
void st2xxx_device::sckr_w(u8 data)
{
m_sckr = data & 0x7f;
}
u8 st2xxx_device::ssr_r()
{
return m_ssr | 0x88;
}
void st2xxx_device::ssr_w(u8 data)
{
// Write any value to clear
m_ssr = 0;
}
u8 st2xxx_device::smod_r()
{
return m_smod | 0xf0;
}
void st2xxx_device::smod_w(u8 data)
{
m_smod = data & 0x0f;
}
u8 st2xxx_device::uctr_r()
{
return m_uctr | ~st2xxx_uctr_mask();

View File

@ -57,6 +57,10 @@ public:
ST_LFRA,
ST_LAC,
ST_LPWM,
ST_SCTR,
ST_SCKR,
ST_SSR,
ST_SMOD,
ST_UCTR,
ST_USR,
ST_IRCTR,
@ -106,6 +110,8 @@ protected:
virtual u8 st2xxx_lckr_mask() const = 0;
virtual u8 st2xxx_lpwm_mask() const = 0;
virtual unsigned st2xxx_lfr_clocks() const = 0;
virtual bool st2xxx_has_spi() const = 0;
virtual bool st2xxx_spi_iis() const { return false; }
virtual u8 st2xxx_uctr_mask() const = 0;
virtual u8 st2xxx_bctr_mask() const = 0;
@ -212,6 +218,15 @@ protected:
u8 lpwm_r();
void lpwm_w(u8 data);
u8 sctr_r();
void sctr_w(u8 data);
u8 sckr_r();
void sckr_w(u8 data);
u8 ssr_r();
void ssr_w(u8 data);
u8 smod_r();
void smod_w(u8 data);
u8 uctr_r();
void uctr_w(u8 data);
u8 usr_r();
@ -279,6 +294,11 @@ protected:
u16 m_lcd_ireq;
emu_timer *m_lcd_timer;
u8 m_sctr;
u8 m_sckr;
u8 m_ssr;
u8 m_smod;
u8 m_uctr;
u8 m_usr;
u8 m_irctr;