Compare commits
3 Commits
04cb8882a1
...
02f84bab18
Author | SHA1 | Date |
---|---|---|
Rekai Nyangadzayi Musuka | 02f84bab18 | |
Rekai Nyangadzayi Musuka | 37c0a1a745 | |
Rekai Nyangadzayi Musuka | 305cd6b611 |
19
src/lib.zig
19
src/lib.zig
|
@ -44,6 +44,8 @@ pub const Bus = struct {
|
||||||
write8: *const fn (ptr: *anyopaque, address: u32, value: u8) void,
|
write8: *const fn (ptr: *anyopaque, address: u32, value: u8) void,
|
||||||
write16: *const fn (ptr: *anyopaque, address: u32, value: u16) void,
|
write16: *const fn (ptr: *anyopaque, address: u32, value: u16) void,
|
||||||
write32: *const fn (ptr: *anyopaque, address: u32, value: u32) void,
|
write32: *const fn (ptr: *anyopaque, address: u32, value: u32) void,
|
||||||
|
|
||||||
|
reset: *const fn (ptr: *anyopaque) void,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init(obj: anytype) @This() {
|
pub fn init(obj: anytype) @This() {
|
||||||
|
@ -74,17 +76,22 @@ pub const Bus = struct {
|
||||||
|
|
||||||
fn write8(ptr: *anyopaque, address: u32, value: u8) void {
|
fn write8(ptr: *anyopaque, address: u32, value: u8) void {
|
||||||
const self = @ptrCast(P, @alignCast(alignment, ptr));
|
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 {
|
fn write16(ptr: *anyopaque, address: u32, value: u16) void {
|
||||||
const self = @ptrCast(P, @alignCast(alignment, ptr));
|
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 {
|
fn write32(ptr: *anyopaque, address: u32, value: u32) void {
|
||||||
const self = @ptrCast(P, @alignCast(alignment, ptr));
|
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,
|
.write8 = impl.write8,
|
||||||
.write16 = impl.write16,
|
.write16 = impl.write16,
|
||||||
.write32 = impl.write32,
|
.write32 = impl.write32,
|
||||||
|
|
||||||
|
.reset = impl.reset,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -193,6 +202,10 @@ const ExampleBus = struct {
|
||||||
_ = value;
|
_ = value;
|
||||||
_ = address;
|
_ = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reset(self: *@This()) void {
|
||||||
|
self._ = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ExampleScheduler = struct {
|
const ExampleScheduler = struct {
|
||||||
|
|
Loading…
Reference in New Issue