Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Grazfather committed Jan 16, 2025
1 parent 148ae16 commit 9186848
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 45 deletions.
53 changes: 28 additions & 25 deletions examples/raspberrypi/rp2xxx/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,41 @@ pub fn build(b: *std.Build) void {

const rp2040_only_examples: []const Example = &.{
// RaspberryPi Boards:
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_adc", .file = "src/rp2040_only/adc.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_flash-program", .file = "src/rp2040_only/flash_program.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_flash-id", .file = "src/rp2040_only/flash_id.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_i2c-bus-scan", .file = "src/rp2040_only/i2c_bus_scan.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_pwm", .file = "src/rp2040_only/pwm.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_random", .file = "src/rp2040_only/random.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_rtc", .file = "src/rp2040_only/rtc.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_spi-host", .file = "src/rp2040_only/spi_host.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_uart-echo", .file = "src/rp2040_only/uart_echo.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_uart-log", .file = "src/rp2040_only/uart_log.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_usb-hid", .file = "src/rp2040_only/usb_hid.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_usb-cdc", .file = "src/rp2040_only/usb_cdc.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_multicore", .file = "src/rp2040_only/blinky_core1.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_hd44780", .file = "src/rp2040_only/hd44780.zig" },
// .{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_pcf8574", .file = "src/rp2040_only/pcf8574.zig" },
//
// // WaveShare Boards:
// .{ .target = mb.ports.rp2xxx.boards.waveshare.rp2040_matrix, .name = "rp2040-matrix_tiles", .file = "src/rp2040_only/tiles.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_adc", .file = "src/rp2040_only/adc.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_flash-program", .file = "src/rp2040_only/flash_program.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_flash-id", .file = "src/rp2040_only/flash_id.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_i2c-bus-scan", .file = "src/rp2040_only/i2c_bus_scan.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_pwm", .file = "src/rp2040_only/pwm.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_random", .file = "src/rp2040_only/random.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_rtc", .file = "src/rp2040_only/rtc.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_spi-host", .file = "src/rp2040_only/spi_host.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_uart-echo", .file = "src/rp2040_only/uart_echo.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_uart-log", .file = "src/rp2040_only/uart_log.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_usb-hid", .file = "src/rp2040_only/usb_hid.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_usb-cdc", .file = "src/rp2040_only/usb_cdc.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_multicore", .file = "src/rp2040_only/blinky_core1.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_hd44780", .file = "src/rp2040_only/hd44780.zig" },
.{ .target = mb.ports.rp2xxx.boards.raspberrypi.pico, .name = "pico_pcf8574", .file = "src/rp2040_only/pcf8574.zig" },

// WaveShare Boards:
.{ .target = mb.ports.rp2xxx.boards.waveshare.rp2040_matrix, .name = "rp2040-matrix_tiles", .file = "src/rp2040_only/tiles.zig" },
// .{ .target = "board:waveshare/rp2040_eth", .name = "rp2040-eth" },
// .{ .target = "board:waveshare/rp2040_plus_4m", .name = "rp2040-plus-4m" },
// .{ .target = "board:waveshare/rp2040_plus_16m", .name = "rp2040-plus-16m" },
};

const rp2350_only_examples: []const Example = &.{};
const rp2350_only_examples: []const Example = &.{
// TODO: No RP2350 feature specific examples to show off yet
};

const chip_agnostic_examples: []const ChipAgnosticExample = &.{
// .{ .name = "ws2812", .file = "src/ws2812.zig" },
// .{ .name = "blinky", .file = "src/blinky.zig" },
// .{ .name = "gpio-clock-output", .file = "src/gpio_clock_output.zig" },
// .{ .name = "changing-system-clocks", .file = "src/changing_system_clocks.zig" },
// .{ .name = "custom-clock-config", .file = "src/custom_clock_config.zig" },
// .{ .name = "watchdog-timer", .file = "src/watchdog_timer.zig" },
.{ .name = "squarewave", .file = "src/squarewave.zig" },
.{ .name = "ws2812", .file = "src/ws2812.zig" },
.{ .name = "blinky", .file = "src/blinky.zig" },
.{ .name = "gpio-clock-output", .file = "src/gpio_clock_output.zig" },
.{ .name = "changing-system-clocks", .file = "src/changing_system_clocks.zig" },
.{ .name = "custom-clock-config", .file = "src/custom_clock_config.zig" },
.{ .name = "watchdog-timer", .file = "src/watchdog_timer.zig" },
};

var available_examples = std.ArrayList(Example).init(b.allocator);
Expand Down
2 changes: 0 additions & 2 deletions port/raspberrypi/rp2xxx/src/hal/pio/assembler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ fn format_compile_error(comptime message: []const u8, comptime source: []const u
var line_it = std.mem.tokenize(u8, source, "\n\r");
while (line_it.next()) |line| : (line_num += 1) {
line_str = line_str ++ "\n" ++ line;
// If the line iterator is overlapping the provided index, then we are on the correct line
if (line_it.index >= index) {
// Calculate the column
column = line.len - (line_it.index - index);
line_str = line;
break;
Expand Down
13 changes: 0 additions & 13 deletions port/raspberrypi/rp2xxx/src/hal/pio/assembler/comparison_tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ fn pio_comparison(comptime source: []const u8) !void {
}

fn pio_comparison_chip(comptime chip: Chip, comptime source: []const u8) !void {
// comptime var diags: ?assembler.Diagnostics = null;
// const output = comptime blk: {
// const v = assembler.assemble_impl(chip, source, &diags, .{}) catch |err| {
// @compileLog("err {}", err);
// if (diags != null) {
// std.log.debug("diag {}", .{diags});
// @compileLog("Diag", diags);
// }
// // I want to return an error here but this is comptime?
// break :blk err;
// };
// break :blk v;
// };
const output = comptime assembler.assemble(chip, source, .{});
try std.testing.expect(output.programs.len > 0);

Expand Down
15 changes: 10 additions & 5 deletions port/raspberrypi/rp2xxx/src/hal/pio/assembler/tokenizer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,6 @@ pub fn Tokenizer(chip: Chip) type {
};
},
.RP2350 => {
// This doesn't work: idx_mode's type only exists at comptime,
// even though this is a comptime-only switch :/
// Hardcoding the type
const IdxMode = Token(chip).Instruction.Irq.IdxMode;
const idx_mode: IdxMode = if (try self.peek_arg(diags)) |result| blk: {
const idxmode_lower = try lowercase_bounded(256, result.str);
Expand All @@ -969,7 +966,6 @@ pub fn Tokenizer(chip: Chip) type {
self.consume_peek(result);
break :blk .next;
} else {
// Not specified: direct
break :blk .direct;
}
} else .direct;
Expand Down Expand Up @@ -2144,7 +2140,6 @@ test "tokenize.instr.irq" {

test "tokenize.instr.irq.rel" {
const tokens = try bounded_tokenize(.RP2040, "irq set 2 rel");
// TODO: rp2350 support
try expect_instr_irq(.RP2040, .{
.clear = false,
.wait = false,
Expand All @@ -2153,6 +2148,16 @@ test "tokenize.instr.irq.rel" {
}, tokens.get(0));
}

test "tokenize.instr.irq.relnext" {
const tokens = try bounded_tokenize(.RP2350, "irq set 2 next");
try expect_instr_irq(.RP2350, .{
.clear = false,
.wait = false,
.num = 2,
.idxmode = @intFromEnum(Token(.RP2350).Instruction.Irq.IdxMode.next),
}, tokens.get(0));
}

test "tokenize.instr.set" {
inline for (.{
"pins",
Expand Down

0 comments on commit 9186848

Please sign in to comment.