mirror of
https://github.com/TomHarte/CLK.git
synced 2025-11-27 19:19:29 +00:00
Add comments, correct address decoding.
This commit is contained in:
@@ -38,7 +38,8 @@ bool uPD7002::interrupt() const {
|
||||
}
|
||||
|
||||
void uPD7002::write(const uint16_t address, const uint8_t value) {
|
||||
if(!address) {
|
||||
const auto local_address = address & 3;
|
||||
if(!local_address) {
|
||||
channel_ = value & 3;
|
||||
high_precision_ = value & 8;
|
||||
conversion_time_remaining_ = high_precision_ ? slow_period_ : fast_period_;
|
||||
@@ -47,11 +48,13 @@ void uPD7002::write(const uint16_t address, const uint8_t value) {
|
||||
}
|
||||
|
||||
uint8_t uPD7002::read(const uint16_t address) {
|
||||
if(!address) {
|
||||
const auto local_address = address & 3;
|
||||
if(!local_address) {
|
||||
return status();
|
||||
}
|
||||
|
||||
if(address & 1) {
|
||||
// TODO: verify this decoding.
|
||||
if(local_address & 1) {
|
||||
interrupt_ = false;
|
||||
if(delegate_) delegate_->did_change_interrupt_status(*this);
|
||||
return uint8_t(result_ >> 8);
|
||||
|
||||
@@ -12,11 +12,14 @@ namespace NEC {
|
||||
|
||||
class uPD7002 {
|
||||
public:
|
||||
/// Constructs a PD7002 that will receive @c run_for updates at the specified clock rate.
|
||||
uPD7002(HalfCycles clock_rate);
|
||||
void run_for(HalfCycles);
|
||||
|
||||
/// @returns The current state of the interrupt line.
|
||||
bool interrupt() const;
|
||||
|
||||
/// Defines a mean for an observer to receive notifications upon updates to the interrupt line.
|
||||
struct Delegate {
|
||||
virtual void did_change_interrupt_status(uPD7002 &) = 0;
|
||||
};
|
||||
@@ -25,6 +28,8 @@ public:
|
||||
void write(uint16_t address, uint8_t value);
|
||||
uint8_t read(uint16_t address);
|
||||
|
||||
/// Sets the floating point value, which should be in the range [0.0, 1.0], for the signal currently
|
||||
/// being supplied to @c channel.
|
||||
void set_input(int channel, float value);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user