chore: misc style improvements

This commit is contained in:
2022-05-27 22:09:15 -03:00
parent 4006888629
commit 38afb567b9
5 changed files with 24 additions and 88 deletions

View File

@@ -33,9 +33,7 @@ pub fn deinit(self: Self) void {
pub fn checkedRead(self: *Self, comptime T: type, r15: u32, addr: u32) T {
if (r15 < Self.size) {
// FIXME: Just give up on *const Self on bus reads, Rekai
self.addr_latch = addr;
return self.read(T, addr);
}

View File

@@ -411,10 +411,18 @@ const Eeprom = struct {
.Large => {
if (self.writer.len() == 14) {
const addr = @intCast(u10, self.writer.finish());
// TODO: Bit Verbose eh?
const value_buf = buf[@as(u13, addr) * 8 ..][0..8];
const value = @as(u64, value_buf[7]) << 56 | @as(u64, value_buf[6]) << 48 | @as(u64, value_buf[5]) << 40 | @as(u64, value_buf[4]) << 32 | @as(u64, value_buf[3]) << 24 | @as(u64, value_buf[2]) << 16 | @as(u64, value_buf[1]) << 8 | @as(u64, value_buf[0]) << 0;
// zig fmt: off
const value = @as(u64, value_buf[7]) << 56
| @as(u64, value_buf[6]) << 48
| @as(u64, value_buf[5]) << 40
| @as(u64, value_buf[4]) << 32
| @as(u64, value_buf[3]) << 24
| @as(u64, value_buf[2]) << 16
| @as(u64, value_buf[1]) << 8
| @as(u64, value_buf[0]) << 0;
// zig fmt: on
self.reader.configure(value);
self.state = .RequestEnd;
@@ -422,11 +430,20 @@ const Eeprom = struct {
},
.Small => {
if (self.writer.len() == 6) {
// FIXME: Duplicated code from above
const addr = @intCast(u6, self.writer.finish());
// TODO: Bit Verbose eh?, also duplicate code
const value_buf = buf[@as(u13, addr) * 8 ..][0..8];
const value = @as(u64, value_buf[7]) << 56 | @as(u64, value_buf[6]) << 48 | @as(u64, value_buf[5]) << 40 | @as(u64, value_buf[4]) << 32 | @as(u64, value_buf[3]) << 24 | @as(u64, value_buf[2]) << 16 | @as(u64, value_buf[1]) << 8 | @as(u64, value_buf[0]) << 0;
// zig fmt: off
const value = @as(u64, value_buf[7]) << 56
| @as(u64, value_buf[6]) << 48
| @as(u64, value_buf[5]) << 40
| @as(u64, value_buf[4]) << 32
| @as(u64, value_buf[3]) << 24
| @as(u64, value_buf[2]) << 16
| @as(u64, value_buf[1]) << 8
| @as(u64, value_buf[0]) << 0;
// zig fmt: on
self.reader.configure(value);
self.state = .RequestEnd;