Compare commits

..

3 Commits

1 changed files with 16 additions and 3 deletions

View File

@ -44,6 +44,8 @@ pub const Bus = struct {
write8: *const fn (ptr: *anyopaque, address: u32, value: u8) void,
write16: *const fn (ptr: *anyopaque, address: u32, value: u16) void,
write32: *const fn (ptr: *anyopaque, address: u32, value: u32) void,
reset: *const fn (ptr: *anyopaque) void,
};
pub fn init(obj: anytype) @This() {
@ -74,17 +76,22 @@ pub const Bus = struct {
fn write8(ptr: *anyopaque, address: u32, value: u8) void {
const self = @ptrCast(P, @alignCast(alignment, ptr));
return self.write(u8, address, value);
self.write(u8, address, value);
}
fn write16(ptr: *anyopaque, address: u32, value: u16) void {
const self = @ptrCast(P, @alignCast(alignment, ptr));
return self.write(u16, address, value);
self.write(u16, address, value);
}
fn write32(ptr: *anyopaque, address: u32, value: u32) void {
const self = @ptrCast(P, @alignCast(alignment, ptr));
return self.write(u32, address, value);
self.write(u32, address, value);
}
fn reset(ptr: *anyopaque) void {
const self = @ptrCast(P, @alignCast(alignment, ptr));
self.reset();
}
};
@ -98,6 +105,8 @@ pub const Bus = struct {
.write8 = impl.write8,
.write16 = impl.write16,
.write32 = impl.write32,
.reset = impl.reset,
},
};
}
@ -193,6 +202,10 @@ const ExampleBus = struct {
_ = value;
_ = address;
}
pub fn reset(self: *@This()) void {
self._ = 0;
}
};
const ExampleScheduler = struct {