summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/adc1213x.h
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2015-09-13 08:41:44 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2015-09-13 08:41:44 +0200
commitf88cefad27a1737c76e09d99c9fb43e173506081 (patch)
tree2d8167d03579c46e226471747eb4407bd00ed6fa /src/devices/machine/adc1213x.h
parente92ac9e0fa8e99869894bea00589bbb526be30aa (diff)
Move all devices into separate part of src tree (nw)
Diffstat (limited to 'src/devices/machine/adc1213x.h')
-rw-r--r--src/devices/machine/adc1213x.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/devices/machine/adc1213x.h b/src/devices/machine/adc1213x.h
new file mode 100644
index 00000000000..3f2f0dbc63c
--- /dev/null
+++ b/src/devices/machine/adc1213x.h
@@ -0,0 +1,89 @@
+// license:BSD-3-Clause
+// copyright-holders:smf
+/***************************************************************************
+
+ National Semiconductor ADC12130 / ADC12132 / ADC12138
+
+ Self-calibrating 12-bit Plus Sign Serial I/O A/D Converters with MUX
+ and Sample/Hold
+
+***************************************************************************/
+
+#ifndef __ADC1213X_H__
+#define __ADC1213X_H__
+
+
+/***************************************************************************
+ TYPE DEFINITIONS
+***************************************************************************/
+
+typedef device_delegate<double (UINT8 input)> adc1213x_ipt_convert_delegate;
+#define ADC12138_IPT_CONVERT_CB(name) double name(UINT8 input)
+
+/***************************************************************************
+ MACROS / CONSTANTS
+***************************************************************************/
+
+class adc12138_device : public device_t
+{
+public:
+ adc12138_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ adc12138_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
+ ~adc12138_device() {}
+
+ static void set_ipt_convert_callback(device_t &device, adc1213x_ipt_convert_delegate callback) { downcast<adc12138_device &>(device).m_ipt_read_cb = callback; }
+
+ DECLARE_WRITE8_MEMBER( di_w );
+ DECLARE_WRITE8_MEMBER( cs_w );
+ DECLARE_WRITE8_MEMBER( sclk_w );
+ DECLARE_WRITE8_MEMBER( conv_w );
+ DECLARE_READ8_MEMBER( do_r );
+ DECLARE_READ8_MEMBER( eoc_r );
+
+protected:
+ // device-level overrides
+ virtual void device_start();
+ virtual void device_reset();
+
+ void convert(int channel, int bits16, int lsbfirst);
+
+ adc1213x_ipt_convert_delegate m_ipt_read_cb;
+
+private:
+ // internal state
+ int m_cycle;
+ int m_data_out;
+ int m_data_in;
+ int m_conv_mode;
+ int m_auto_cal;
+ int m_auto_zero;
+ int m_acq_time;
+ int m_data_out_sign;
+ int m_input_shift_reg;
+ int m_output_shift_reg;
+ int m_end_conv;
+};
+
+extern const device_type ADC12138;
+
+class adc12130_device : public adc12138_device
+{
+public:
+ adc12130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+};
+
+extern const device_type ADC12130;
+
+class adc12132_device : public adc12138_device
+{
+public:
+ adc12132_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+};
+
+extern const device_type ADC12132;
+
+
+#define MCFG_ADC1213X_IPT_CONVERT_CB(_class, _method) \
+ adc12138_device::set_ipt_convert_callback(*device, adc1213x_ipt_convert_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
+
+#endif /* __ADC1213X_H__ */