2019-10-11 00:54:29 +00:00
|
|
|
//
|
|
|
|
// 6850.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 10/10/2019.
|
|
|
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Motorola_ACIA_6850_hpp
|
|
|
|
#define Motorola_ACIA_6850_hpp
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include "../../ClockReceiver/ClockReceiver.hpp"
|
2019-10-13 03:46:57 +00:00
|
|
|
#include "../../ClockReceiver/ClockingHintSource.hpp"
|
2019-10-13 03:14:29 +00:00
|
|
|
#include "../SerialPort/SerialPort.hpp"
|
2019-10-11 00:54:29 +00:00
|
|
|
|
|
|
|
namespace Motorola {
|
|
|
|
namespace ACIA {
|
|
|
|
|
2019-10-13 03:46:57 +00:00
|
|
|
class ACIA: public ClockingHint::Source {
|
2019-10-11 00:54:29 +00:00
|
|
|
public:
|
2019-10-13 03:14:29 +00:00
|
|
|
ACIA();
|
|
|
|
|
2019-10-12 04:04:02 +00:00
|
|
|
/*!
|
|
|
|
Reads from the ACIA.
|
|
|
|
|
|
|
|
Bit 0 of the address is used as the ACIA's register select line —
|
|
|
|
so even addresses select control/status registers, odd addresses
|
|
|
|
select transmit/receive data registers.
|
|
|
|
*/
|
2019-10-11 00:54:29 +00:00
|
|
|
uint8_t read(int address);
|
2019-10-12 04:04:02 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Writes to the ACIA.
|
|
|
|
|
|
|
|
Bit 0 of the address is used as the ACIA's register select line —
|
|
|
|
so even addresses select control/status registers, odd addresses
|
|
|
|
select transmit/receive data registers.
|
|
|
|
*/
|
2019-10-11 00:54:29 +00:00
|
|
|
void write(int address, uint8_t value);
|
|
|
|
|
|
|
|
void run_for(HalfCycles);
|
2019-10-12 04:04:02 +00:00
|
|
|
|
2019-10-13 03:46:57 +00:00
|
|
|
bool get_interrupt_line();
|
|
|
|
|
2019-10-13 03:14:29 +00:00
|
|
|
// Input lines.
|
|
|
|
Serial::Line receive;
|
|
|
|
Serial::Line clear_to_send;
|
|
|
|
Serial::Line data_carrier_detect;
|
|
|
|
|
|
|
|
// Output lines.
|
|
|
|
Serial::Line transmit;
|
|
|
|
Serial::Line request_to_send;
|
|
|
|
|
2019-10-12 04:04:02 +00:00
|
|
|
private:
|
|
|
|
int divider_ = 1;
|
2019-10-12 22:19:55 +00:00
|
|
|
enum class Parity {
|
|
|
|
Even, Odd, None
|
|
|
|
} parity_ = Parity::None;
|
2019-10-13 03:14:29 +00:00
|
|
|
int data_bits_ = 7, stop_bits_ = 2;
|
|
|
|
|
|
|
|
static const int NoTransmission = 0x100;
|
|
|
|
int next_transmission_ = NoTransmission;
|
|
|
|
void consider_transmission();
|
|
|
|
|
2019-10-12 22:19:55 +00:00
|
|
|
bool receive_interrupt_enabled_ = false;
|
|
|
|
bool transmit_interrupt_enabled_ = false;
|
2019-10-13 03:46:57 +00:00
|
|
|
|
|
|
|
bool interrupt_request_ = false;
|
|
|
|
|
|
|
|
ClockingHint::Preference preferred_clocking() final;
|
2019-10-11 00:54:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Motorola_ACIA_6850_hpp */
|