Skip to content

Commit e334149

Browse files
authored
rp2xxx: Build usb examples on rp2350 feather (#909)
1 parent 88aaa5f commit e334149

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

examples/raspberrypi/rp2xxx/build.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ pub fn build(b: *std.Build) void {
4848
// Adafruit boards
4949
.{ .target = mb.ports.rp2xxx.boards.adafruit.feather_rp2350, .name = "adafruit_feather_rp2350_blinky", .file = "src/board_blinky.zig" },
5050
.{ .target = mb.ports.rp2xxx.boards.adafruit.feather_rp2350, .name = "adafruit_feather_rp2350_multicore", .file = "src/blinky_core1.zig" },
51+
.{ .target = mb.ports.rp2xxx.boards.adafruit.feather_rp2350, .name = "adafruit_feather_rp2350_usb-cdc", .file = "src/usb_cdc.zig" },
52+
.{ .target = mb.ports.rp2xxx.boards.adafruit.feather_rp2350, .name = "adafruit_feather_rp2350_usb-hid", .file = "src/usb_hid.zig" },
5153
.{ .target = mb.ports.rp2xxx.boards.adafruit.metro_rp2350, .name = "adafruit_metro_rp2350_blinky", .file = "src/board_blinky.zig" },
5254

5355
// WaveShare Boards:

examples/raspberrypi/rp2xxx/src/usb_cdc.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const microzig = @import("microzig");
33

44
const rp2xxx = microzig.hal;
55
const time = rp2xxx.time;
6-
const gpio = rp2xxx.gpio;
76
const usb = microzig.core.usb;
87
// Port-specific type which implements the DeviceInterface interface, used by the USB core to
98
// read from/write to the peripheral.
@@ -79,7 +78,7 @@ pub fn main() !void {
7978
// Ensure that the host as finished enumerating our USB device
8079
if (usb_controller.drivers()) |drivers| {
8180
new = time.get_time_since_boot().to_us();
82-
if (new - old > 500000) {
81+
if (new - old > 500_000) {
8382
old = new;
8483
pins.led.toggle();
8584
i += 1;

examples/raspberrypi/rp2xxx/src/usb_hid.zig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const microzig = @import("microzig");
33

44
const rp2xxx = microzig.hal;
55
const time = rp2xxx.time;
6-
const gpio = rp2xxx.gpio;
76
const usb = microzig.core.usb;
87
const USB_Device = rp2xxx.usb.Polled(.{});
98

@@ -171,17 +170,16 @@ pub fn main() !void {
171170

172171
if (usb_controller.drivers()) |drivers| {
173172
new = time.get_time_since_boot().to_us();
174-
const time_since_last = new - old;
175-
if (time_since_last < 2_000_000) {
173+
if (new - old > 2_000_000) {
174+
old = new;
175+
idx = 0;
176+
} else {
176177
idx += @intFromBool(if (idx & 1 == 0 and idx < 2 * message.len)
177178
drivers.keyboard.send_report(
178179
&.{ .modifiers = .none, .keys = .{message[@intCast(idx / 2)]} ++ .{.reserved} ** 5 },
179180
)
180181
else
181182
drivers.keyboard.send_report(&.empty));
182-
} else {
183-
old = new;
184-
idx = 0;
185183
}
186184

187185
if (drivers.keyboard.receive_report()) |report|

port/raspberrypi/rp2xxx/build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
171171
.adafruit = .{
172172
.feather_rp2350 = chip_rp2350_arm.derive(.{
173173
.board = .{
174-
.name = "Adafruit Faether RP2350",
174+
.name = "Adafruit Feather RP2350",
175175
.url = "https://www.adafruit.com/product/6000",
176176
.root_source_file = b.path("src/boards/adafruit_feather_rp2350.zig"),
177177
},

0 commit comments

Comments
 (0)