sylveos

Toy Operating System
Log | Files | Refs

echo.zig (712B)


      1 const std = @import("std");
      2 const pi = @import("pi");
      3 
      4 const uart = pi.devices.mini_uart;
      5 const clock = pi.devices.clock;
      6 
      7 pub fn main() !void {
      8     while (true) {
      9         const status = uart.status();
     10         uart.print("rx queue: {d}, rx hw: {d}, rx ready: {any}, tx queue: {d}, tx hw: {d}, tx ready: {any}\n", .{
     11             uart.read_queue_length(),
     12             status.rx_fill_level,
     13             uart.can_read(),
     14             uart.write_queue_length(),
     15             status.tx_fill_level,
     16             uart.can_write(),
     17         });
     18 
     19         while (uart.can_read()) {
     20             const byte = uart.read_byte_sync();
     21             uart.print("  read: 0x{X}\n", .{byte});
     22         }
     23 
     24         clock.delay_s(1);
     25     }
     26 }