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
4 changes: 2 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const example_dep_names: []const []const u8 = &.{
"examples/gigadevice/gd32",
"examples/stmicro/stm32",
//"examples/espressif/esp",
"examples/raspberrypi/rp2040",
"examples/raspberrypi/rp2xxx",
};

const ports = .{
Expand All @@ -22,7 +22,7 @@ const ports = .{
.{ "port/gigadevice/gd32", @import("port/gigadevice/gd32") },
.{ "port/stmicro/stm32", @import("port/stmicro/stm32") },
.{ "port/espressif/esp", @import("port/espressif/esp") },
.{ "port/raspberrypi/rp2040", @import("port/raspberrypi/rp2040") },
.{ "port/raspberrypi/rp2xxx", @import("port/raspberrypi/rp2xxx") },
};

pub fn build(b: *Build) void {
Expand Down
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
.@"port/gigadevice/gd32" = .{ .path = "port/gigadevice/gd32" },
.@"port/stmicro/stm32" = .{ .path = "port/stmicro/stm32" },
.@"port/espressif/esp" = .{ .path = "port/espressif/esp" },
.@"port/raspberrypi/rp2040" = .{ .path = "port/raspberrypi/rp2040" },
.@"port/raspberrypi/rp2xxx" = .{ .path = "port/raspberrypi/rp2xxx" },

// examples so that we can build them all in one go
.@"examples/nordic/nrf5x" = .{ .path = "examples/nordic/nrf5x" },
Expand All @@ -26,7 +26,7 @@
.@"examples/gigadevice/gd32" = .{ .path = "examples/gigadevice/gd32" },
.@"examples/stmicro/stm32" = .{ .path = "examples/stmicro/stm32" },
.@"examples/espressif/esp" = .{ .path = "examples/espressif/esp" },
.@"examples/raspberrypi/rp2040" = .{ .path = "examples/raspberrypi/rp2040" },
.@"examples/raspberrypi/rp2xxx" = .{ .path = "examples/raspberrypi/rp2xxx" },

// used for creating package tarballs
.boxzer = .{
Expand Down
22 changes: 11 additions & 11 deletions core/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ pub const cpus = struct {
},
};

pub const cortex_m33 = MicroZig.Cpu{
.name = "ARM Cortex-M33",
.root_source_file = .{ .cwd_relative = build_root ++ "/src/cpus/cortex_m.zig" },
.target = std.Target.Query{
.cpu_arch = .thumb,
.cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m33 },
.os_tag = .freestanding,
.abi = .eabi,
},
};

pub const cortex_m4 = MicroZig.Cpu{
.name = "ARM Cortex-M4",
.root_source_file = .{ .cwd_relative = build_root ++ "/src/cpus/cortex_m.zig" },
Expand Down Expand Up @@ -94,17 +105,6 @@ pub const cpus = struct {
},
};

pub const cortex_m33 = MicroZig.Cpu{
.name = "ARM Cortex-M7",
.root_source_file = .{ .cwd_relative = build_root ++ "/src/cpus/cortex_m.zig" },
.target = std.zig.CrossTarget{
.cpu_arch = .thumb,
.cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m33 },
.os_tag = .freestanding,
.abi = .eabihf,
},
};

pub const riscv32_imac = MicroZig.Cpu{
.name = "RISC-V 32-bit",
.root_source_file = .{ .cwd_relative = build_root ++ "/src/cpus/riscv32.zig" },
Expand Down
2 changes: 2 additions & 0 deletions core/src/cpus/cortex_m.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Core = enum {
@"ARM Cortex-M0",
@"ARM Cortex-M0+",
@"ARM Cortex-M3",
@"ARM Cortex-M33",
@"ARM Cortex-M4",
};

Expand All @@ -26,6 +27,7 @@ const core: type = blk: {
.@"ARM Cortex-M0" => @import("cortex_m/m0"),
.@"ARM Cortex-M0+" => @import("cortex_m/m0plus.zig"),
.@"ARM Cortex-M3" => @import("cortex_m/m3.zig"),
.@"ARM Cortex-M33" => @import("cortex_m/m33.zig"),
.@"ARM Cortex-M4" => @import("cortex_m/m4.zig"),
};
};
Expand Down
3 changes: 3 additions & 0 deletions core/src/cpus/cortex_m/m33.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub const SystemControlBlock = @compileError("TODO");
pub const NestedVectorInterruptController = @compileError("TODO");
pub const MemoryProtectionUnit = @compileError("TODO");
50 changes: 0 additions & 50 deletions examples/raspberrypi/rp2040/README.md

This file was deleted.

65 changes: 0 additions & 65 deletions examples/raspberrypi/rp2040/build.zig

This file was deleted.

113 changes: 0 additions & 113 deletions examples/raspberrypi/rp2040/src/custom_clock_config.zig

This file was deleted.

67 changes: 67 additions & 0 deletions examples/raspberrypi/rp2xxx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Examples for the BSP `raspberrypi-rp2xxx`

## Demos

Demos are divided into two categories:
- Those that can be compiled for/run on both RP2040 (Pico 1) and RP2350 (Pico 2) with no code changes
- Those that are ONLY for a specific chip, RP2040 or RP2350 due to a unique feature present on one but not the other

Currently many demos are marked as "RP2040 only" simply because HAL functionality hasn't been ported to the RP2350 given it's a very new chip. Most
examples will eventually be able to run on either chip with no changes due to their peripherals being extremely similar. All demos that run on the the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board can also be run on the [RP2040-Plus](https://www.waveshare.com/rp2040-plus.htm) without modification.


### Chip Agnostic
- [blinky](src/blinky.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) or [Pico2](https://www.raspberrypi.com/products/raspberry-pi-pico-2/) boards
Blinks the LED on the board.
- [changing system clocks](src/rp2040_only/changing_system_clocks.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) or [Pico2](https://www.raspberrypi.com/products/raspberry-pi-pico-2/) boards
Shows an example of changing SYS and REF clock frequencies.
- [custom clock config](src/rp2040_only/custom_clock_config.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) or [Pico2](https://www.raspberrypi.com/products/raspberry-pi-pico-2/) boards
Shows an example of a fully custom clock configuration.
- [gpio clock output](src/gpio_clock_output.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) or [Pico2](https://www.raspberrypi.com/products/raspberry-pi-pico-2/) boards
Routes the SYS clock divided by 1000 out to GPIO25.

### RP2040 Only

- [adc](src/rp2040_only/adc.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
This example takes periodic samples of the temperature sensor and prints it to the UART using the stdlib logging facility.
- [blinky core1](src/rp2040_only/blinky_core1.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
Blinks the LED on the board using the second CPU.
- [flash program](src/rp2040_only/flash_program.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
Writes and reads data into the flash.
- [i2c bus scan](src/rp2040_only/i2c_bus_scan.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
Prints all I²C devices on UART0 (Pin 0,1) attached to I²C on SCL=GPIO4, SDA=GPIO5.
- [pwm](src/rp2040_only/pwm.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
Slowly blinks the LED on the Pico with a smooth blinking using PWM.
- [random](src/rp2040_only/random.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
Showcases how to use the internal random generator.
- [spi host](src/rp2040_only/spi_host.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
Showcases how to use the SPI host controller.
- [squarewave](src/rp2040_only/squarewave.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
Showcases how to use the PIO to emit a basic square wave.
- [uart](src/rp2040_only/uart.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
Showcases how to use the UART together with `std.log`.
- [usb device](src/rp2040_only/usb_cdc.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
A really basic example for a raw USB device. You can use the Python 3 script [`scripts/usb_device_loopback.py`](scripts/usb_device_loopback.py) to test the USB device.
- [usb hid](src/rp2040_only/usb_hid.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
A really basic example how to implement a USB HID device. You can use the Python 3 script [`scripts/hid_test.py`](scripts/hid_test.py) to test the HID device.
- [ws2812](src/rp2040_only/ws2812.zig) on the [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) board
Showcases how to control one WS2812 LED attached to GPIO23.
- [tiles](src/rp2040_only/tiles.zig) on the [RP2040-Matrix](https://www.waveshare.com/rp2040-matrix.htm) board
Showcases how to control the LED matrix on the development board to do a simple color flipper effect.

### RP2350 Only
None for now! But an HSTX or other new feature example could go here in the future.

## Flashing

You can flash all examples using either your file browser by dragging the example `.uf2` file from `zig-out/firmware/` to the directory.

Or you can use [`picotool`](https://github.com/raspberrypi/picotool) to flash a uf2 file:
```sh-session
[user@host] raspberrypi-rp2040/ $ picotool load -x zig-out/firmware/${file}.uf2
Loading into Flash: [==============================] 100%

The device was rebooted to start the application.
[user@host] raspberrypi-rp2040/ $
```

Loading