mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-07 01:13:18 +00:00
Misc clang-tidy/comment tweaks
This commit is contained in:
+16
-22
@@ -38,7 +38,9 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr int ADDR_WIDTH = 12;
|
constexpr int ADDR_WIDTH = 12;
|
||||||
}
|
constexpr int CONTROL_WIDTH = 4;
|
||||||
|
constexpr int BYTE_WIDTH = 8;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace avclan {
|
namespace avclan {
|
||||||
|
|
||||||
@@ -52,13 +54,7 @@ bool Bus::is_muted() const { return AVCLAN_ismuted(); };
|
|||||||
auto Bus::read(uint16_t address, Frame *in, Frame::Print print) -> Error::Read {
|
auto Bus::read(uint16_t address, Frame *in, Frame::Print print) -> Error::Read {
|
||||||
struct errtype {
|
struct errtype {
|
||||||
Error::Read errno;
|
Error::Read errno;
|
||||||
union {
|
uint16_t val;
|
||||||
uint8_t val; // BAD_LENGTH_RANGE: the out-of-range length value
|
|
||||||
struct {
|
|
||||||
uint8_t parity; // received (bad) parity bit
|
|
||||||
uint16_t read_val;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} err = {};
|
} err = {};
|
||||||
|
|
||||||
using enum detail::Error::Read;
|
using enum detail::Error::Read;
|
||||||
@@ -69,18 +65,18 @@ auto Bus::read(uint16_t address, Frame *in, Frame::Print print) -> Error::Read {
|
|||||||
bool shouldACK = false;
|
bool shouldACK = false;
|
||||||
uint8_t tmp = 0;
|
uint8_t tmp = 0;
|
||||||
|
|
||||||
err.errno = Error::Read{static_cast<uint8_t>(handle.readstartbit())};
|
err.errno = handle.readstartbit();
|
||||||
if (static_cast<bool>(err.errno))
|
if (err.errno != Error::Read{0})
|
||||||
goto handle_err;
|
goto handle_err;
|
||||||
|
|
||||||
handle.read<1>(&tmp, false);
|
handle.read<1>(&tmp, false);
|
||||||
in->is_unicast = tmp;
|
in->is_unicast = (tmp != 0U);
|
||||||
|
|
||||||
if (auto rerr = handle.read<ADDR_WIDTH>(&in->controller_addr, false);
|
if (auto rerr = handle.read<ADDR_WIDTH>(&in->controller_addr, false);
|
||||||
rerr == BAD_PARITY) {
|
rerr == BAD_PARITY) {
|
||||||
err.errno = BAD_CONTROLLER_PARITY;
|
err.errno = BAD_CONTROLLER_PARITY;
|
||||||
if (print.verbose) {
|
if (print.verbose) {
|
||||||
err.read_val = in->controller_addr;
|
err.val = in->controller_addr;
|
||||||
}
|
}
|
||||||
goto handle_err;
|
goto handle_err;
|
||||||
}
|
}
|
||||||
@@ -91,27 +87,27 @@ auto Bus::read(uint16_t address, Frame *in, Frame::Print print) -> Error::Read {
|
|||||||
rerr == BAD_PARITY) {
|
rerr == BAD_PARITY) {
|
||||||
err.errno = BAD_PERIPHERAL_PARITY;
|
err.errno = BAD_PERIPHERAL_PARITY;
|
||||||
if (print.verbose) {
|
if (print.verbose) {
|
||||||
err.read_val = in->peripheral_addr;
|
err.val = in->peripheral_addr;
|
||||||
}
|
}
|
||||||
goto handle_err;
|
goto handle_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldACK = !is_muted() && (in->peripheral_addr == address);
|
shouldACK = !is_muted() && (in->peripheral_addr == address);
|
||||||
|
|
||||||
if (auto rerr = handle.read<4>(&in->control, shouldACK);
|
if (auto rerr = handle.read<CONTROL_WIDTH>(&in->control, shouldACK);
|
||||||
rerr == BAD_PARITY) {
|
rerr == BAD_PARITY) {
|
||||||
err.errno = BAD_CONTROL_PARITY;
|
err.errno = BAD_CONTROL_PARITY;
|
||||||
if (print.verbose) {
|
if (print.verbose) {
|
||||||
err.read_val = in->control;
|
err.val = in->control;
|
||||||
}
|
}
|
||||||
goto handle_err;
|
goto handle_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto rerr = handle.read<8>(&in->length, shouldACK);
|
if (auto rerr = handle.read<BYTE_WIDTH>(&in->length, shouldACK);
|
||||||
rerr == BAD_PARITY) {
|
rerr == BAD_PARITY) {
|
||||||
err.errno = BAD_LENGTH_PARITY;
|
err.errno = BAD_LENGTH_PARITY;
|
||||||
if (print.verbose) {
|
if (print.verbose) {
|
||||||
err.read_val = in->length;
|
err.val = in->length;
|
||||||
}
|
}
|
||||||
goto handle_err;
|
goto handle_err;
|
||||||
}
|
}
|
||||||
@@ -123,11 +119,11 @@ auto Bus::read(uint16_t address, Frame *in, Frame::Print print) -> Error::Read {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 0; i < in->length; i++) {
|
for (uint8_t i = 0; i < in->length; i++) {
|
||||||
if (auto rerr = handle.read<8>(&in->data[i], shouldACK);
|
if (auto rerr = handle.read<BYTE_WIDTH>(&in->data[i], shouldACK);
|
||||||
rerr == BAD_PARITY) {
|
rerr == BAD_PARITY) {
|
||||||
err.errno = BAD_DATA_PARITY;
|
err.errno = BAD_DATA_PARITY;
|
||||||
if (print.verbose) {
|
if (print.verbose) {
|
||||||
err.read_val = in->data[i];
|
err.val = in->data[i];
|
||||||
}
|
}
|
||||||
goto handle_err;
|
goto handle_err;
|
||||||
}
|
}
|
||||||
@@ -159,9 +155,7 @@ auto Bus::read(uint16_t address, Frame *in, Frame::Print print) -> Error::Read {
|
|||||||
VERBOSE:
|
VERBOSE:
|
||||||
if (print.verbose) {
|
if (print.verbose) {
|
||||||
RS232_Print("; read 0x");
|
RS232_Print("; read 0x");
|
||||||
RS232_PrintHex(err.read_val);
|
RS232_PrintHex(err.val);
|
||||||
RS232_Print(" and got bad parity ");
|
|
||||||
RS232_PrintHex4(err.parity);
|
|
||||||
}
|
}
|
||||||
case BAD_PARITY: __builtin_unreachable();
|
case BAD_PARITY: __builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ constexpr uint8_t cdloading_resp[] = {dev_CD_CHANGER,
|
|||||||
0x01,
|
0x01,
|
||||||
0x02};
|
0x02};
|
||||||
|
|
||||||
constexpr int WIRE_SIZE = 8;
|
constexpr int WIRE_SIZE = 8; // cd state report size in bytes
|
||||||
constexpr int TIME_SKIP = 15;
|
constexpr int TIME_SKIP = 15; // seconds
|
||||||
constexpr int TWODIGIT_MAX = 99;
|
constexpr int TWODIGIT_MAX = 99;
|
||||||
|
|
||||||
/* Pack a 0–TWODIGIT_MAX count into 2-digit BCD. Values >TWODIGIT_MAX (sentinels
|
/* Pack a 0–TWODIGIT_MAX count into 2-digit BCD. Values >TWODIGIT_MAX (sentinels
|
||||||
@@ -275,7 +275,7 @@ void CDChanger::react(Frame *out, detail::Error::Send err) {
|
|||||||
out->reaction = r_SendOnly;
|
out->reaction = r_SendOnly;
|
||||||
break;
|
break;
|
||||||
case r_TrackChange:
|
case r_TrackChange:
|
||||||
setTime(0x00, 0x00);
|
setTime(0, 0);
|
||||||
statustimer_reset(); // Skipped to a whole/round sec; ensure next tick is
|
statustimer_reset(); // Skipped to a whole/round sec; ensure next tick is
|
||||||
// ~1 sec from now
|
// ~1 sec from now
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
@@ -343,9 +343,8 @@ void CDChanger::stopPlaying() {
|
|||||||
AVCLAN_mediaFunction(MEDIA_PLAY_PAUSE);
|
AVCLAN_mediaFunction(MEDIA_PLAY_PAUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize cd_status into the wire format. The struct layout mirrors the wire
|
// Serialize cd_status into the wire format.
|
||||||
// format byte-for-byte, except for track/mins/secs, which need converted from
|
// track/mins/secs, need converted from decimal to BCD
|
||||||
// decimal to BCD
|
|
||||||
void CDChanger::serialize(uint8_t *dst) const {
|
void CDChanger::serialize(uint8_t *dst) const {
|
||||||
*dst++ = cds;
|
*dst++ = cds;
|
||||||
*dst++ = state;
|
*dst++ = state;
|
||||||
|
|||||||
Reference in New Issue
Block a user