summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/bq4847.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/bq4847.h')
-rw-r--r--src/devices/machine/bq4847.h121
1 files changed, 48 insertions, 73 deletions
diff --git a/src/devices/machine/bq4847.h b/src/devices/machine/bq4847.h
index 56551d74e1c..50cee115be5 100644
--- a/src/devices/machine/bq4847.h
+++ b/src/devices/machine/bq4847.h
@@ -15,8 +15,6 @@
#include "dirtc.h"
-// ======================> bq4874_device
-
class bq4847_device : public device_t,
public device_nvram_interface,
public device_rtc_interface
@@ -24,100 +22,77 @@ class bq4847_device : public device_t,
public:
bq4847_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- // The watchdog is inactive when the pin is not connected; we offer
- // a method to activate it
- void set_watchdog_active(bool active);
-
- auto interrupt_cb() { return m_interrupt_cb.bind(); }
- auto watchdog_cb() { return m_wdout_cb.bind(); }
-
- // Retrigger the watchdog
- void retrigger_watchdog();
+ auto wdo_handler() { return m_wdo_handler.bind(); }
+ auto int_handler() { return m_int_handler.bind(); }
+ auto rst_handler() { return m_rst_handler.bind(); }
uint8_t read(offs_t address);
void write(offs_t address, uint8_t data);
- DECLARE_READ_LINE_MEMBER(intrq_r);
-
- // Mainly used to disconnect from oscillator
- void connect_osc(bool conn);
-
-private:
- // Inherited from device_rtc_interface
- void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override;
- bool rtc_feature_y2k() const override { return false; }
- bool rtc_feature_leap_year() const override { return true; }
- bool rtc_battery_backed() const override { return true; }
+ void write_wdi(int state); // watchdog disabled if wdi pin is left floating
- // callback called when interrupt pin state changes (may be nullptr)
- devcb_write_line m_interrupt_cb;
+protected:
+ bq4847_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock = 32768);
- // callback called when watchdog times out changes (may be nullptr)
- devcb_write_line m_wdout_cb;
+ // device_t
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_clock_changed() override;
- // Accessible registers
- uint8_t m_reg[16];
+ // device_nvram_interface
+ virtual void nvram_default() override;
+ virtual bool nvram_read(util::read_stream& file) override;
+ virtual bool nvram_write(util::write_stream& file) override;
- // Internal clock registers
- // The clock operates on these registers and copies them to the
- // accessible registers
- uint8_t m_intreg[16];
+ // device_rtc_interface
+ virtual bool rtc_feature_y2k() const override { return false; }
+ virtual bool rtc_feature_leap_year() const override { return true; }
+ virtual bool rtc_battery_backed() const override { return true; }
+ virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override;
- TIMER_CALLBACK_MEMBER(rtc_clock_cb);
- TIMER_CALLBACK_MEMBER(rtc_periodic_cb);
- TIMER_CALLBACK_MEMBER(rtc_watchdog_cb);
-
- void nvram_default() override;
- void nvram_read(emu_file &file) override;
- void nvram_write(emu_file &file) override;
-
- void device_start() override;
+private:
+ optional_memory_region m_region;
- // Sanity-check BCD number
- bool valid_bcd(uint8_t value, uint8_t min, uint8_t max);
+ devcb_write_line m_wdo_handler;
+ devcb_write_line m_int_handler;
+ devcb_write_line m_rst_handler;
- // Check bits in register
- bool is_set(int number, uint8_t flag);
+ TIMER_CALLBACK_MEMBER(update_callback);
+ TIMER_CALLBACK_MEMBER(periodic_callback);
+ TIMER_CALLBACK_MEMBER(watchdog_callback);
- // Increment BCD number
bool increment_bcd(uint8_t& bcdnumber, uint8_t limit, uint8_t min);
- // Set/Reset one or more bits in the register
- void set_register(int number, uint8_t bits, bool set);
-
- // Copy register contents from the internal registers to SRAM
- void transfer_to_access();
-
- // Check matching registers of time and alarm
- bool check_match(int regint, int regalarm);
-
- // Check whether this register is internal
- bool is_internal_register(int regnum);
-
- // Advance
+ bool check_alarm(int now, int alarm);
+ bool is_clock_register(int regnum);
bool advance_hours_bcd();
void advance_days_bcd();
+ void update_int();
+ void set_wdo(int state);
- // Timers
- emu_timer *m_clock_timer;
+ emu_timer *m_update_timer;
emu_timer *m_periodic_timer;
emu_timer *m_watchdog_timer;
- // Set timers
void set_periodic_timer();
- void set_watchdog_timer(bool on);
-
- // Get time from system
- void get_system_time();
-
- // Get the delay until the next second
- int get_delay();
-
- // Flags
- bool m_watchdog_active;
- bool m_watchdog_asserted;
+ void set_watchdog_timer(int rst_state = 1);
+
+ uint8_t m_userbuffer[16];
+ uint8_t m_register[16];
+ int m_wdo_state;
+ int m_int_state;
+ int m_rst_state;
+ int m_wdi_state;
bool m_writing;
};
+class bq4845_device : public bq4847_device
+{
+public:
+ bq4845_device(const machine_config& mconfig, const char* tag, device_t* owner, uint32_t clock);
+};
+
+DECLARE_DEVICE_TYPE(BQ4845, bq4845_device)
DECLARE_DEVICE_TYPE(BQ4847, bq4847_device)
+
#endif