mirror of
https://github.com/holub/mame
synced 2025-06-05 04:16:28 +03:00
sdlc.cpp: WIP added bitbanger device
This commit is contained in:
parent
f28a4eb860
commit
eef80ce011
@ -13,7 +13,7 @@
|
||||
#define LOG_LINESTATE (1U << 3)
|
||||
#define LOG_FRAMING (1U << 4)
|
||||
|
||||
//#define VERBOSE (LOG_GENERAL | LOG_RXBIT | LOG_RXFLAG | LOG_LINESTATE | LOG_FRAMING)
|
||||
//#define VERBOSE (LOG_GENERAL | LOG_RXFLAG | LOG_LINESTATE | LOG_FRAMING)
|
||||
#include "logmacro.h"
|
||||
|
||||
#define LOGRXBIT(...) LOGMASKED(LOG_RXBIT, __VA_ARGS__)
|
||||
@ -22,7 +22,8 @@
|
||||
#define LOGFRAMING(...) LOGMASKED(LOG_FRAMING, __VA_ARGS__)
|
||||
|
||||
|
||||
DEFINE_DEVICE_TYPE(SDLC_LOGGER, sdlc_logger_device, "sdlc_logger", "SDLC/HDLC logger")
|
||||
DEFINE_DEVICE_TYPE(SDLC_LOGGER, sdlc_logger_device, "sdlc_logger", "SDLC/HDLC logger")
|
||||
DEFINE_DEVICE_TYPE(SDLC_BITBANGER, sdlc_bitbanger_device, "sdlc_bitbanger", "SDLC/HDLC bitbanger")
|
||||
|
||||
|
||||
constexpr std::uint16_t device_sdlc_consumer_interface::POLY_SDLC;
|
||||
@ -125,9 +126,8 @@ void device_sdlc_consumer_interface::rx_reset()
|
||||
m_frame_check = 0xffffU;
|
||||
}
|
||||
|
||||
|
||||
sdlc_logger_device::sdlc_logger_device(machine_config const &mconfig, char const *tag, device_t *owner, std::uint32_t clock) :
|
||||
device_t(mconfig, SDLC_LOGGER, tag, owner, clock),
|
||||
sdlc_logger_device::sdlc_logger_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, std::uint32_t clock) :
|
||||
device_t(mconfig, type, tag, owner, clock),
|
||||
device_sdlc_consumer_interface(mconfig, *this),
|
||||
m_data_nrzi(0U),
|
||||
m_clock_active(1U),
|
||||
@ -140,6 +140,11 @@ sdlc_logger_device::sdlc_logger_device(machine_config const &mconfig, char const
|
||||
{
|
||||
}
|
||||
|
||||
sdlc_logger_device::sdlc_logger_device(machine_config const &mconfig, char const *tag, device_t *owner, std::uint32_t clock) :
|
||||
sdlc_logger_device(mconfig, SDLC_LOGGER, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER(sdlc_logger_device::clock_w)
|
||||
{
|
||||
if (bool(state) != bool(m_current_clock))
|
||||
@ -222,7 +227,7 @@ void sdlc_logger_device::shift_residual_bits()
|
||||
}
|
||||
}
|
||||
|
||||
void sdlc_logger_device::log_frame(bool partial) const
|
||||
void sdlc_logger_device::log_frame(bool partial)
|
||||
{
|
||||
if (m_frame_bits)
|
||||
{
|
||||
@ -300,3 +305,23 @@ void sdlc_logger_device::log_frame(bool partial) const
|
||||
logerror("%s\n", msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
sdlc_bitbanger_device::sdlc_bitbanger_device(machine_config const &mconfig, char const *tag, device_t *owner, std::uint32_t clock) : sdlc_logger_device(mconfig, SDLC_BITBANGER, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
void sdlc_bitbanger_device::log_frame(bool partial)
|
||||
{
|
||||
std::uint32_t const frame_bytes(get_frame_bits() >> 3);
|
||||
if (frame_bytes)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
std::uint32_t const residual_bits(get_frame_bits() & 0x0007U);
|
||||
for (std::uint32_t i = 0U; (frame_bytes > i) && (get_buffer_bytes() > i); ++i)
|
||||
util::stream_format(msg, (i & 0x000fU) ? "-%02X" : "\n %02X", get_buffer()[i]);
|
||||
if (residual_bits && (get_buffer_bits() >= get_frame_bits()))
|
||||
util::stream_format(msg, (residual_bits > 4) ? "%s %02X&%02X" : "%s %01X&%01X", (frame_bytes & 0x000fU) ? "" : "\n ", get_buffer()[frame_bytes], (1U << residual_bits) - 1);
|
||||
|
||||
logerror("%s\n", msg.str());
|
||||
}
|
||||
}
|
||||
|
@ -65,11 +65,18 @@ public:
|
||||
DECLARE_WRITE_LINE_MEMBER(clock_active) { m_clock_active = state ? 1U : 0U; }
|
||||
|
||||
protected:
|
||||
sdlc_logger_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, std::uint32_t clock);
|
||||
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
|
||||
using device_t::logerror;
|
||||
|
||||
std::uint32_t get_frame_bits(){ return m_frame_bits; }
|
||||
std::size_t get_buffer_bytes(){ return BUFFER_BYTES; }
|
||||
std::size_t get_buffer_bits(){ return BUFFER_BITS; }
|
||||
std::uint8_t *get_buffer(){ return (std::uint8_t *) (&m_buffer[0]); }
|
||||
|
||||
private:
|
||||
enum : std::size_t
|
||||
{
|
||||
@ -83,7 +90,7 @@ private:
|
||||
virtual void data_bit(bool value) override;
|
||||
|
||||
void shift_residual_bits();
|
||||
void log_frame(bool partial) const;
|
||||
virtual void log_frame(bool partial);
|
||||
|
||||
std::uint8_t m_data_nrzi;
|
||||
std::uint8_t m_clock_active;
|
||||
@ -98,6 +105,19 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class sdlc_bitbanger_device : public sdlc_logger_device
|
||||
{
|
||||
public:
|
||||
sdlc_bitbanger_device(machine_config const &mconfig, char const *tag, device_t *owner, std::uint32_t clock);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
virtual void log_frame(bool partial) override;
|
||||
};
|
||||
|
||||
|
||||
DECLARE_DEVICE_TYPE(SDLC_LOGGER, sdlc_logger_device)
|
||||
DECLARE_DEVICE_TYPE(SDLC_BITBANGER, sdlc_bitbanger_device)
|
||||
|
||||
#endif // MAME_MACHINE_SDLC_H
|
||||
|
Loading…
Reference in New Issue
Block a user