Skip to content
Merged
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
7 changes: 6 additions & 1 deletion board-support/raspberrypi-rp2040/src/hal/pio.zig
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub const ClkDivOptions = struct {
};

pub const ExecOptions = struct {
jmp_pin: u5 = 0,
wrap: u5 = 31,
wrap_target: u5 = 0,
side_pindir: bool = false,
Expand Down Expand Up @@ -132,6 +133,7 @@ pub const LoadAndStartProgramOptions = struct {
clkdiv: ClkDivOptions,
shift: ShiftOptions = .{},
pin_mappings: PinMappingOptions = .{},
exec: ExecOptions = .{},
};

pub const Pio = enum(u1) {
Expand Down Expand Up @@ -254,18 +256,19 @@ pub const Pio = enum(u1) {
pub fn sm_set_exec_options(self: Pio, sm: StateMachine, options: ExecOptions) void {
const sm_regs = self.get_sm_regs(sm);
sm_regs.execctrl.modify(.{
// NOTE: EXEC_STALLED is RO
.WRAP_BOTTOM = options.wrap_target,
.WRAP_TOP = options.wrap,
.SIDE_PINDIR = @intFromBool(options.side_pindir),
.SIDE_EN = @intFromBool(options.side_set_optional),
.JMP_PIN = options.jmp_pin,

// TODO: plug in rest of the options
// STATUS_N
// STATUS_SEL
// OUT_STICKY
// INLINE_OUT_EN
// OUT_EN_SEL
// JMP_PIN
// EXEC_STALLED
});
}
Expand Down Expand Up @@ -514,6 +517,8 @@ pub const Pio = enum(u1) {
side_set.optional
else
false,

.jmp_pin = options.exec.jmp_pin,
},
});
}
Expand Down