uart improvements and improved definition of how many clock units there are (#16)

wch-ch32v003
Matt Knight 2 years ago committed by GitHub
parent b0b90a7cf0
commit e9af302b69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -82,7 +82,7 @@ pub const Generator = enum(u32) {
} }
const generators = @intToPtr( const generators = @intToPtr(
*volatile [10]GeneratorRegs, *volatile [@typeInfo(Generator).Enum.fields.len]GeneratorRegs,
regs.CLOCKS.base_address, regs.CLOCKS.base_address,
); );

@ -226,6 +226,7 @@ var uart_logger: ?UART.Writer = null;
pub fn initLogger(uart: UART) void { pub fn initLogger(uart: UART) void {
uart_logger = uart.writer(); uart_logger = uart.writer();
uart_logger.?.writeAll("\r\n================ STARTING NEW LOGGER ================\r\n") catch {};
} }
pub fn log( pub fn log(
@ -248,3 +249,16 @@ pub fn log(
uart.print(prefix ++ format ++ "\r\n", .{ seconds, microseconds } ++ args) catch {}; uart.print(prefix ++ format ++ "\r\n", .{ seconds, microseconds } ++ args) catch {};
} }
} }
pub fn panic(
message: []const u8,
_: ?*std.builtin.StackTrace,
_: ?usize,
) noreturn {
if (uart_logger) |writer| {
writer.print("PANIC: {s}\r\n", .{message}) catch {};
}
@breakpoint();
while (true) {}
}

Loading…
Cancel
Save