mirror of
https://github.com/jscrane/r65emu.git
synced 2025-01-20 06:30:31 +00:00
refactor ACIA + allow compile with no hw def
This commit is contained in:
parent
2baab0f856
commit
072c15ff33
31
acia.cpp
31
acia.cpp
@ -1,4 +1,4 @@
|
|||||||
#include <stdint.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "serialio.h"
|
#include "serialio.h"
|
||||||
@ -13,40 +13,35 @@ void ACIA::write(Memory::address a, uint8_t b) {
|
|||||||
|
|
||||||
void ACIA::write_control(uint8_t b) {
|
void ACIA::write_control(uint8_t b) {
|
||||||
if ((b & cd_mask) == reset) {
|
if ((b & cd_mask) == reset) {
|
||||||
_serial->reset();
|
acia_reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (b & ws_mask) {
|
switch (b & ws_mask) {
|
||||||
case ws7e2:
|
case ws7e2:
|
||||||
_serial->framing(7, 2, even);
|
acia_framing(SERIAL_7E2);
|
||||||
break;
|
break;
|
||||||
case ws7o2:
|
case ws7o2:
|
||||||
_serial->framing(7, 2, odd);
|
acia_framing(SERIAL_7O2);
|
||||||
break;
|
break;
|
||||||
case ws7e1:
|
case ws7e1:
|
||||||
_serial->framing(7, 1, even);
|
acia_framing(SERIAL_7E1);
|
||||||
break;
|
break;
|
||||||
case ws7o1:
|
case ws7o1:
|
||||||
_serial->framing(7, 1, odd);
|
acia_framing(SERIAL_7O1);
|
||||||
break;
|
break;
|
||||||
case ws8n2:
|
case ws8n2:
|
||||||
_serial->framing(8, 2, none);
|
acia_framing(SERIAL_8N2);
|
||||||
break;
|
break;
|
||||||
case ws8n1:
|
case ws8n1:
|
||||||
_serial->framing(8, 1, none);
|
acia_framing(SERIAL_8N1);
|
||||||
break;
|
break;
|
||||||
case ws8e1:
|
case ws8e1:
|
||||||
_serial->framing(8, 1, even);
|
acia_framing(SERIAL_8E1);
|
||||||
break;
|
break;
|
||||||
case ws8o1:
|
case ws8o1:
|
||||||
_serial->framing(8, 1, odd);
|
acia_framing(SERIAL_8O1);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
// FIXME: more
|
|
||||||
}
|
|
||||||
|
|
||||||
void ACIA::write_data(uint8_t b) {
|
|
||||||
_serial->write(b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ACIA::read(Memory::address a) {
|
uint8_t ACIA::read(Memory::address a) {
|
||||||
@ -57,10 +52,6 @@ uint8_t ACIA::read(Memory::address a) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ACIA::read_data() {
|
|
||||||
return _serial->read();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t ACIA::read_status() {
|
uint8_t ACIA::read_status() {
|
||||||
return _serial->more()? rdrf | tdre: tdre;
|
return acia_more()? rdrf | tdre: tdre;
|
||||||
}
|
}
|
||||||
|
12
acia.h
12
acia.h
@ -8,8 +8,7 @@ public:
|
|||||||
void write(Memory::address, uint8_t);
|
void write(Memory::address, uint8_t);
|
||||||
uint8_t read(Memory::address);
|
uint8_t read(Memory::address);
|
||||||
|
|
||||||
ACIA(serialio &s): _serial(&s) {}
|
virtual void acia_reset() {}
|
||||||
void set_device(serialio *s) { _serial = s; }
|
|
||||||
|
|
||||||
// status bits
|
// status bits
|
||||||
//
|
//
|
||||||
@ -51,11 +50,10 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
// overrideable device memory interface
|
// overrideable device memory interface
|
||||||
virtual uint8_t read_status();
|
virtual uint8_t read_status();
|
||||||
virtual uint8_t read_data();
|
virtual uint8_t read_data() = 0;
|
||||||
virtual void write_control(uint8_t);
|
virtual void write_control(uint8_t);
|
||||||
virtual void write_data(uint8_t);
|
virtual void write_data(uint8_t) = 0;
|
||||||
|
virtual void acia_framing(uint32_t config) {}
|
||||||
private:
|
virtual bool acia_more() = 0;
|
||||||
serialio *_serial;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <stdarg.h>
|
#include <Arduino.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
|
|
||||||
|
#if defined(USE_SD) || defined(USE_SPIFFS) || defined(USE_LITTLEFS) || defined(USE_SPIRAM)
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(USE_SD)
|
#if defined(USE_SD)
|
||||||
#include <SD.h>
|
#include <SD.h>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
// user-configured hardware description
|
// user-configured hardware description
|
||||||
|
|
||||||
#error "hw/user.h not configured!"
|
#warning "hw/user.h not configured!"
|
||||||
|
@ -10,7 +10,7 @@ enum parity {
|
|||||||
class serialio {
|
class serialio {
|
||||||
public:
|
public:
|
||||||
virtual void reset() {}
|
virtual void reset() {}
|
||||||
virtual void framing(unsigned data_bits, unsigned stop_bits, parity p) {}
|
virtual void framing(uint32_t) {}
|
||||||
virtual void write(uint8_t) {}
|
virtual void write(uint8_t) {}
|
||||||
|
|
||||||
virtual uint8_t read() =0;
|
virtual uint8_t read() =0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user