zig-riscv-embedded

Experimental Zig-based CoAP node for the HiFive1 RISC-V board

git clone https://git.8pit.net/zig-riscv-embedded.git

 1// Copyright © 2021 Sören Tempel
 2//
 3// This program is free software: you can redistribute it and/or modify
 4// it under the terms of the GNU Affero General Public License as
 5// published by the Free Software Foundation, either version 3 of the
 6// License, or (at your option) any later version.
 7//
 8// This program is distributed in the hope that it will be useful, but
 9// WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Affero General Public License for more details.
12//
13// You should have received a copy of the GNU Affero General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16const periph = @import("periph.zig");
17const slipmux = @import("slipmux.zig");
18
19pub fn getStdDbg() slipmux.Frame {
20    const ftype = slipmux.FrameType.diagnostic;
21    return periph.slipmux.newFrame(ftype);
22}
23
24// Write a Slipmux diagnostic message, unbuffered, to the UART.
25pub fn print(comptime fmt: []const u8, args: anytype) void {
26    var stddbg = getStdDbg();
27    defer stddbg.close();
28
29    const w = stddbg.writer();
30    nosuspend w.print(fmt, args) catch return;
31}