acia updates (#22)

This commit is contained in:
Stephen Crane 2023-09-27 15:38:16 +01:00 committed by GitHub
parent 67ff1567af
commit 3e90841500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 20 deletions

View File

@ -5,46 +5,58 @@
#include "acia.h"
void ACIA::write(Memory::address a, uint8_t b) {
if (a & 1) {
_device->write(b);
return;
}
if (a & 1)
write_data(b);
else
write_control(b);
}
void ACIA::write_control(uint8_t b) {
if ((b & cd_mask) == reset) {
_device->reset();
_serial->reset();
return;
}
switch (b & ws_mask) {
case ws7e2:
_device->framing(7, 2, even);
_serial->framing(7, 2, even);
break;
case ws7o2:
_device->framing(7, 2, odd);
_serial->framing(7, 2, odd);
break;
case ws7e1:
_device->framing(7, 1, even);
_serial->framing(7, 1, even);
break;
case ws7o1:
_device->framing(7, 1, odd);
_serial->framing(7, 1, odd);
break;
case ws8n2:
_device->framing(8, 2, none);
_serial->framing(8, 2, none);
break;
case ws8n1:
_device->framing(8, 1, none);
_serial->framing(8, 1, none);
break;
case ws8e1:
_device->framing(8, 1, even);
_serial->framing(8, 1, even);
break;
case ws8o1:
_device->framing(8, 1, odd);
_serial->framing(8, 1, odd);
break;
};
// FIXME: more
}
uint8_t ACIA::read(Memory::address a) {
if (a & 1)
return _device->read();
return _device->more()? rdrf | tdre: tdre;
void ACIA::write_data(uint8_t b) {
_serial->write(b);
}
uint8_t ACIA::read(Memory::address a) {
return (a & 1)? read_data(): read_status();
}
uint8_t ACIA::read_data() {
return _serial->read();
}
uint8_t ACIA::read_status() {
return _serial->more()? rdrf | tdre: tdre;
}

11
acia.h
View File

@ -8,7 +8,7 @@ public:
void write(Memory::address, uint8_t);
uint8_t read(Memory::address);
ACIA(serialio &d): _device(&d) {}
ACIA(serialio &s): _serial(&s) {}
// status bits
//
@ -47,7 +47,14 @@ public:
static const uint8_t eri = 1 << 7; // enable receive interrupt
protected:
// overrideable device memory interface
virtual uint8_t read_status();
virtual uint8_t read_data();
virtual void write_control(uint8_t);
virtual void write_data(uint8_t);
private:
class serialio *_device;
class serialio *_serial;
};
#endif

View File

@ -5,4 +5,8 @@ typedef void (*handler_t)(void);
void timer_create(unsigned freq, handler_t handler);
#if !defined(ESP32) && !defined(ESP8266)
#define IRAM_ATTR
#endif
#endif