Skip to content

Commit

Permalink
Add embedded clock config parser in rust
Browse files Browse the repository at this point in the history
  • Loading branch information
lmbollen authored and hiddemoll committed Dec 21, 2023
1 parent 6964699 commit 8b45bcb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions firmware-binaries/examples/hello/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ fn main() -> ! {
}

uwriteln!(uart, "Going in echo mode!").unwrap();

// Parse config.csv using bittide::clock_config
let config = include_str!("config.csv");
let mut parser = clock_config::ClockConfigParser::new();
for line in config.lines() {
if !parser.is_done() {
match parser.parse_line(line) {
Ok(Some((addr, data))) => {
uwriteln!(uart, "{:04x} {:04x}", addr, data).unwrap();
}
Ok(None) => uwriteln!(uart, "{}", line).unwrap(),
Err(e) => {
uwriteln!(uart, "Error: {}", e).unwrap();
}
}
}
}
loop {
let c = uart.receive();
uart.send(c);
Expand Down

0 comments on commit 8b45bcb

Please sign in to comment.