make reset function more robust (#85)
The reset function should reset cycle a single subsystem. Therefore it should not assume every reset of each subsystem is deasserted, when calling this function. Additionally add some comments for the intent of the function itself. Signed-off-by: Tobias Kohlbau <tobias@kohlbau.de> Co-authored-by: Matt Knight <mattnite@proton.me>
This commit is contained in:
parent
a56b0b4121
commit
545be47670
|
@ -35,11 +35,15 @@ pub const Mask = packed struct(u32) {
|
|||
padding: u7 = 0,
|
||||
};
|
||||
|
||||
// Reset cycle a specific subsystem.
|
||||
pub fn reset(mask: Mask) void {
|
||||
const raw_present = RESETS.RESET.raw;
|
||||
|
||||
const raw_mask = @as(u32, @bitCast(mask));
|
||||
|
||||
RESETS.RESET.raw = raw_mask;
|
||||
RESETS.RESET.raw = 0;
|
||||
// restore state
|
||||
RESETS.RESET.raw = raw_present;
|
||||
|
||||
while ((RESETS.RESET_DONE.raw & raw_mask) != raw_mask) {}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ pub const F = struct {
|
|||
// already moved over to the 12MHz XOSC. We just need to make it x4 that
|
||||
// clock.
|
||||
//
|
||||
// PLL_USB out of reset
|
||||
// PLL_USB reset cycle
|
||||
resets.reset(.{ .pll_usb = true });
|
||||
// Configure it:
|
||||
//
|
||||
|
@ -153,7 +153,7 @@ pub const F = struct {
|
|||
}
|
||||
|
||||
pub fn usb_init_device(device_config: *usb.DeviceConfiguration) void {
|
||||
// Bring USB out of reset
|
||||
// USB reset cycle
|
||||
resets.reset(.{ .usbctrl = true });
|
||||
|
||||
// Clear the control portion of DPRAM. This may not be necessary -- the
|
||||
|
|
Loading…
Reference in New Issue
Block a user