-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rp2040: add flash id function (#182)
- Loading branch information
1 parent
1ed0296
commit 540a525
Showing
4 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const std = @import("std"); | ||
const microzig = @import("microzig"); | ||
|
||
const rp2040 = microzig.hal; | ||
const time = rp2040.time; | ||
const gpio = rp2040.gpio; | ||
const flash = rp2040.flash; | ||
|
||
const uart = rp2040.uart.num(0); | ||
const baud_rate = 115200; | ||
const uart_tx_pin = gpio.num(0); | ||
const uart_rx_pin = gpio.num(1); | ||
|
||
pub fn panic(message: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn { | ||
std.log.err("panic: {s}", .{message}); | ||
@breakpoint(); | ||
while (true) {} | ||
} | ||
|
||
pub const std_options = struct { | ||
pub const log_level = .debug; | ||
pub const logFn = rp2040.uart.log; | ||
}; | ||
|
||
pub fn main() !void { | ||
uart.apply(.{ | ||
.baud_rate = baud_rate, | ||
.tx_pin = uart_tx_pin, | ||
.rx_pin = uart_rx_pin, | ||
.clock_config = rp2040.clock_config, | ||
}); | ||
|
||
rp2040.uart.init_logger(uart); | ||
|
||
while (true) { | ||
const serial_number = flash.id(); | ||
const hex_serial_number = std.fmt.fmtSliceHexLower(&serial_number); | ||
std.log.info("serial number: {s}", .{hex_serial_number}); | ||
time.sleep_ms(1000); | ||
} | ||
} |