50 : syncRecv (scheduler)
51 , syncTrans(scheduler)
52 , interf(interf_), clock(scheduler)
65 recvParityEnabled =
false;
75 writeCommand(0, time);
84 result = readTrans(time);
87 result = readStatus(time);
112 writeTrans(value, time);
118 if ((mode & MODE_BAUDRATE) == MODE_SYNCHRONOUS) {
126 if (mode & MODE_SINGLESYNC) {
137 if (value & CMD_RESET) {
140 writeCommand(value, time);
152 void I8251::setMode(
byte newMode)
157 switch (mode & MODE_WORDLENGTH) {
177 switch(mode & MODE_STOP_BITS) {
202 switch (mode & MODE_BAUDRATE) {
220 charLength = (((2 * (1 + unsigned(dataBits) + (parityEnable ? 1 : 0))) +
221 unsigned(stopBits)) * baudrate) / 2;
224 void I8251::writeCommand(
byte value, EmuTime::param time)
226 byte oldCommand = command;
231 interf.
setRTS((command & CMD_RTS) != 0, time);
232 interf.
setDTR((command & CMD_DTR) != 0, time);
234 if (!(command & CMD_TXEN)) {
239 if (command & CMD_RSTERR) {
240 status &= ~(STAT_PE | STAT_OE |
STAT_FE);
242 if (command & CMD_SBRK) {
245 if (command & CMD_HUNT) {
249 if ((command ^ oldCommand) &
CMD_RXE) {
250 if (command & CMD_RXE) {
252 status &= ~(STAT_PE | STAT_OE |
STAT_FE);
257 status &= ~(STAT_PE | STAT_OE |
STAT_FE);
258 status &= ~STAT_RXRDY;
264 byte I8251::readStatus(EmuTime::param time)
266 byte result = status;
267 if (interf.
getDSR(time)) {
273 byte I8251::readTrans(EmuTime::param time)
275 status &= ~STAT_RXRDY;
280 void I8251::writeTrans(
byte value, EmuTime::param time)
282 if (!(command & CMD_TXEN)) {
285 if (status & STAT_TXEMPTY) {
290 status &= ~STAT_TXRDY;
296 recvParityEnabled = enable;
297 recvParityBit = parity;
303 assert(recvReady && (command & CMD_RXE));
304 if (status & STAT_RXRDY) {
320 return (command & CMD_RXE) != 0;
323 void I8251::send(
byte value, EmuTime::param time)
325 status &= ~STAT_TXEMPTY;
335 assert(command & CMD_RXE);
342 assert(!(status & STAT_TXEMPTY) && (command & CMD_TXEN));
345 if (status & STAT_TXRDY) {
349 send(sendBuffer, time);
354 static std::initializer_list<enum_string<SerialDataInterface::DataBits>> dataBitsInfo = {
362 static std::initializer_list<enum_string<SerialDataInterface::StopBits>> stopBitsInfo = {
370 static std::initializer_list<enum_string<SerialDataInterface::ParityBit>> parityBitInfo = {
376 static std::initializer_list<enum_string<I8251::CmdFaze>> cmdFazeInfo = {
386 template<
typename Archive>
389 if (ar.versionAtLeast(version, 2)) {
395 ar.serialize(
"clock", clock,
396 "charLength", charLength,
397 "recvDataBits", recvDataBits,
398 "recvStopBits", recvStopBits,
399 "recvParityBit", recvParityBit,
400 "recvParityEnabled", recvParityEnabled,
402 "recvReady", recvReady,
403 "sendByte", sendByte,
404 "sendBuffer", sendBuffer,
SERIALIZE_ENUM(CassettePlayer::State, stateInfo)
constexpr byte CMD_RSTERR
constexpr byte MODE_PARITYEN
virtual void setParityBit(bool enable, ParityBit parity)=0
virtual void signal(EmuTime::param time)=0
byte peekIO(word port, EmuTime::param time) const
constexpr byte MODE_RATE64
virtual void setDataBits(DataBits bits)=0
void setParityBit(bool enable, ParityBit parity) override
constexpr byte STAT_TXEMPTY
I8251(Scheduler &scheduler, I8251Interface &interf, EmuTime::param time)
uint8_t byte
8 bit unsigned integer
EmuDuration::param getTotalDuration() const
virtual void recvByte(byte value, EmuTime::param time)=0
constexpr byte MODE_RATE16
constexpr byte MODE_PARITEVEN
constexpr byte MODE_BAUDRATE
void serialize(Archive &ar, unsigned version)
constexpr byte STAT_SYNBRK
constexpr byte MODE_SINGLESYNC
virtual void setDTR(bool status, EmuTime::param time)=0
static void restoreOld(Archive &ar, std::vector< Schedulable *> schedulables)
constexpr byte MODE_STOP_INV
constexpr byte MODE_WORDLENGTH
constexpr byte MODE_STOP_2
void writeIO(word port, byte value, EmuTime::param time)
virtual void setRTS(bool status, EmuTime::param time)=0
byte readIO(word port, EmuTime::param time)
Thanks to enen for testing this on a real cartridge:
openmsx::I8251::SyncTrans syncTrans
constexpr byte MODE_STOP_BITS
void reset(EmuTime::param time)
void execTrans(EmuTime::param time)
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr byte MODE_PARITODD
virtual void setStopBits(StopBits bits)=0
constexpr byte MODE_RATE1
constexpr byte STAT_RXRDY
openmsx::I8251::SyncRecv syncRecv
constexpr byte MODE_STOP_15
void execRecv(EmuTime::param time)
constexpr byte MODE_STOP_1
void setSyncPoint(EmuTime::param timestamp)
void recvByte(byte value, EmuTime::param time) override
constexpr byte STAT_TXRDY
virtual void setRxRDY(bool status, EmuTime::param time)=0
constexpr byte MODE_SYNCHRONOUS
virtual bool getDSR(EmuTime::param time)=0