Skip to content

Commit

Permalink
serial: stubbed
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCzekanski committed Apr 30, 2020
1 parent 709c21f commit e1d08a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/device/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand All @@ -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);
}
1 change: 1 addition & 0 deletions src/device/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class Serial {
static const uint32_t BASE_ADDRESS = 0x1F801050;
Reg32 status;
Reg16 control;
Reg16 baud;

void reset();
Expand Down

0 comments on commit e1d08a8

Please sign in to comment.