Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion examples/raspberrypi/rp2xxx/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ pub fn build(b: *std.Build) void {

const specific_examples: []const Example = &.{
// RaspberryPi Boards:
.{ .target = raspberrypi.pico, .name = "pico_board_blinky", .file = "src/board_blinky.zig" },
.{ .target = raspberrypi.pico, .name = "pico_flash-program", .file = "src/rp2040_only/flash_program.zig" },
.{ .target = raspberrypi.pico, .name = "pico_flash-id", .file = "src/rp2040_only/flash_id.zig" },
.{ .target = raspberrypi.pico, .name = "pico_random", .file = "src/rp2040_only/random.zig" },
.{ .target = raspberrypi.pico, .name = "pico_rtc", .file = "src/rp2040_only/rtc.zig" },
.{ .target = raspberrypi.pico, .name = "pico_multicore", .file = "src/rp2040_only/blinky_core1.zig" },
.{ .target = raspberrypi.pico, .name = "pico_multicore", .file = "src/blinky_core1.zig" },
.{ .target = raspberrypi.pico, .name = "pico_hd44780", .file = "src/rp2040_only/hd44780.zig" },
.{ .target = raspberrypi.pico, .name = "pico_pcf8574", .file = "src/rp2040_only/pcf8574.zig" },
.{ .target = raspberrypi.pico, .name = "pico_i2c_slave", .file = "src/rp2040_only/i2c_slave.zig" },

.{ .target = raspberrypi.pico2_arm, .name = "pico2_arm_multicore", .file = "src/blinky_core1.zig" },
.{ .target = raspberrypi.pico2_arm, .name = "pico2_arm_board_blinky", .file = "src/board_blinky.zig" },

.{ .target = raspberrypi.pico_flashless, .name = "pico_flashless_blinky", .file = "src/blinky.zig" },
.{ .target = raspberrypi.pico_flashless, .name = "pico_flashless_flash-program", .file = "src/rp2040_only/flash_program.zig" },

Expand All @@ -39,6 +43,11 @@ pub fn build(b: *std.Build) void {
.{ .target = raspberrypi.pico2_arm, .name = "pico2_arm_always_on_timer", .file = "src/rp2350_only/always_on_timer.zig" },
.{ .target = raspberrypi.pico2_riscv, .name = "pico2_riscv_always_on_timer", .file = "src/rp2350_only/always_on_timer.zig" },

// Adafruit boards
.{ .target = mb.ports.rp2xxx.boards.adafruit.feather_rp2350, .name = "adafruit_feather_rp2350_blinky", .file = "src/board_blinky.zig" },
.{ .target = mb.ports.rp2xxx.boards.adafruit.feather_rp2350, .name = "adafruit_feather_rp2350_multicore", .file = "src/blinky_core1.zig" },
.{ .target = mb.ports.rp2xxx.boards.adafruit.metro_rp2350, .name = "adafruit_metro_rp2350_blinky", .file = "src/board_blinky.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" },
Expand Down
4 changes: 1 addition & 3 deletions examples/raspberrypi/rp2xxx/src/allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ const pin_config = hal.pins.GlobalConfiguration{
},
};

const pins = pin_config.pins();

// ---- UART Configuration --------------------------------

const baud_rate = 115200;
Expand All @@ -46,7 +44,7 @@ pub fn main() !void {

// --- Set up GPIO -------------------------------

pin_config.apply();
_ = pin_config.apply();

// --- Set up UART -------------------------------

Expand Down
4 changes: 1 addition & 3 deletions examples/raspberrypi/rp2xxx/src/blinky.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ const pin_config: rp2xxx.pins.GlobalConfiguration = .{
},
};

const pins = pin_config.pins();

pub fn main() !void {
pin_config.apply();
const pins = pin_config.apply();

while (true) {
pins.led.toggle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,31 @@ const std = @import("std");

const microzig = @import("microzig");
const rp2xxx = microzig.hal;
const board = microzig.board;
const gpio = rp2xxx.gpio;
const time = rp2xxx.time;
const multicore = rp2xxx.multicore;

const led = gpio.num(25);
const pins = board.pin_config.pins();

fn core1() void {
while (true) {
led.put(1);
time.sleep_ms(250);
led.put(0);
time.sleep_ms(250);
pins.led.put(1);
time.sleep_ms(100);
pins.led.put(0);
time.sleep_ms(100);
}
}

pub fn main() !void {
led.set_function(.sio);
led.set_direction(.out);
_ = board.pin_config.apply();

// Blink a few time on core0
pins.led.put(1);
time.sleep_ms(250);
pins.led.put(0);
time.sleep_ms(250);

multicore.launch_core1(core1);

while (true) {
Expand Down
13 changes: 13 additions & 0 deletions examples/raspberrypi/rp2xxx/src/board_blinky.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const std = @import("std");
const microzig = @import("microzig");
const rp2xxx = microzig.hal;
const board = microzig.board;

pub fn main() !void {
const pins = board.pin_config.apply();

while (true) {
pins.led.toggle();
rp2xxx.time.sleep_ms(250);
}
}
4 changes: 1 addition & 3 deletions examples/raspberrypi/rp2xxx/src/ds18b20.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ const pin_config: rp2xxx.pins.GlobalConfiguration = .{
},
};

const pins = pin_config.pins();

pub fn main() !void {
pin_config.apply();
const pins = pin_config.apply();

var ds18b20_gpio = rp2xxx.drivers.GPIO_Device.init(pins.ds18b20);
const clock_device = rp2xxx.drivers.clock_device();
Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/mlx90640.zig
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn init() !void {
i2c0.apply(i2c.Config{ .clock_config = rp2xxx.clock_config });

rp2xxx.uart.init_logger(uart);
pin_config.apply();
_ = pin_config.apply();

std.log.info("Hello from mlx90640", .{});

Expand Down
4 changes: 1 addition & 3 deletions examples/raspberrypi/rp2xxx/src/pwm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ const pin_config = rp2xxx.pins.GlobalConfiguration{
.GPIO25 = .{ .name = "led", .function = .PWM4_B },
};

const pins = pin_config.pins();

pub fn main() !void {
pin_config.apply();
const pins = pin_config.apply();
pins.led.slice().set_wrap(100);
pins.led.slice().enable();

Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/rp2040_only/i2c_slave.zig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn main() !void {
});
rp2xxx.uart.init_logger(uart);

pin_config.apply();
_ = pin_config.apply();

std.log.info("Hello from i2c_slave.", .{});

Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/rp2040_only/rtc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn rtc_isr() callconv(.c) void {
}

pub fn main() !void {
const pins = pin_config.pins();
const pins = pin_config.apply();

// Configure initial datetime for RTC
rp2xxx.rtc.set_datetime(.{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const pin_config = hal.pins.GlobalConfiguration{
.GPIO0 = .{ .name = "gpio0", .function = .UART0_TX },
};

const pins = pin_config.pins();

pub const microzig_options = microzig.Options{
.log_level = .debug,
.logFn = uart.log,
Expand All @@ -27,7 +25,7 @@ pub fn main() !void {
var buffer: [128]u8 = undefined;
var len: usize = 0;

pin_config.apply();
_ = pin_config.apply();

uart0.apply(.{
.clock_config = hal.clock_config,
Expand Down
4 changes: 1 addition & 3 deletions examples/raspberrypi/rp2xxx/src/rp2350_only/random_data.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ const pin_config = hal.pins.GlobalConfiguration{
.GPIO0 = .{ .name = "gpio0", .function = .UART0_TX },
};

const pins = pin_config.pins();

pub const microzig_options = microzig.Options{
.log_level = .debug,
.logFn = uart.log,
};

pub fn main() !void {
pin_config.apply();
_ = pin_config.apply();

uart0.apply(.{
.clock_config = hal.clock_config,
Expand Down
4 changes: 1 addition & 3 deletions examples/raspberrypi/rp2xxx/src/watchdog_timer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ const pin_config = rp2xxx.pins.GlobalConfiguration{
.direction = .out,
},
};
const pins = pin_config.pins();

pub fn main() !void {
pin_config.apply();
const pins = pin_config.apply();

// Set up different blinking behavior if this reset was due to a WD trip
const wd_reset: bool = if (watchdog.caused_reboot()) |_|
Expand Down
8 changes: 8 additions & 0 deletions port/raspberrypi/rp2xxx/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ chips: struct {

boards: struct {
adafruit: struct {
feather_rp2350: *const microzig.Target,
metro_rp2350: *const microzig.Target,
},
raspberrypi: struct {
Expand Down Expand Up @@ -167,6 +168,13 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
.boards = .{
.adafruit = .{
.feather_rp2350 = chip_rp2350_arm.derive(.{
.board = .{
.name = "Adafruit Faether RP2350",
.url = "https://www.adafruit.com/product/6000",
.root_source_file = b.path("src/boards/adafruit_feather_rp2350.zig"),
},
}),
.metro_rp2350 = chip_rp2350_arm.derive(.{
.board = .{
.name = "Adafruit Metro RP2350",
Expand Down
12 changes: 12 additions & 0 deletions port/raspberrypi/rp2xxx/src/boards/adafruit_feather_rp2350.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pub const xosc_freq = 12_000_000;

const microzig = @import("microzig");
const hal = microzig.hal;
const pins = hal.pins;

pub const pin_config = pins.GlobalConfiguration{
.GPIO7 = .{
.name = "led",
.function = .SIO,
},
};
Loading
Loading