serial: stubbed

This commit is contained in:
Jakub Czekański 2020-04-30 19:55:17 +02:00
parent 709c21f366
commit e1d08a8565
2 changed files with 20 additions and 2 deletions

View file

@ -5,12 +5,20 @@ Serial::Serial() { reset(); }
void Serial::step() {}
void Serial::reset() { status._reg = 0x00000005; }
void Serial::reset() { status._reg = 0xffff; }
uint8_t Serial::read(uint32_t address) {
if (address == 0) {
fmt::print("[SERIAL] Rx: ?\n");
return '?';
}
if (address >= 4 && address < 8) {
return status._byte[address - 4];
}
if (address >= 10 && address < 12) {
return control._byte[address - 10];
}
if (address >= 14 && address < 16) {
return baud._byte[address - 14];
}
@ -20,8 +28,17 @@ uint8_t Serial::read(uint32_t address) {
}
void Serial::write(uint32_t address, uint8_t data) {
// fmt::print("[SERIAL] write @ 0x{:02x}: 0x{:02x}\n", address, data);
if (address == 0) {
fmt::print("[SERIAL] TX: 0x{:02x}\n", data);
return;
}
if (address >= 10 && address < 12) {
control._byte[address - 10] = data;
return;
}
if (address >= 14 && address < 16) {
baud._byte[address - 14] = data;
return;
}
fmt::print("[SERIAL] write @ 0x{:02x}: 0x{:02x}\n", address, data);
}

View file

@ -4,6 +4,7 @@
class Serial {
static const uint32_t BASE_ADDRESS = 0x1F801050;
Reg32 status;
Reg16 control;
Reg16 baud;
void reset();