API referencestd/embedded

std/embedded/chip/rp_capture

Public declarations, types, methods, and source contracts for std/embedded/chip/rp_capture.

On this page

Library guide · API index and notation

This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.

import "std/embedded/chip/rp_capture"

Names used in signatures

Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.

Alias Package Source file
hal std/embedded/hal rp_capture.dodo
rp_pio std/embedded/chip/rp_pio rp_capture.dodo

RISING

Constant · Source

The edges to report: rising, falling, or both.

pub const RISING: u32 = 1

FALLING

Constant · Source

pub const FALLING: u32 = 2

BOTH

Constant · Source

pub const BOTH: u32 = 3

program_words

Function · Source

The capture program’s instructions, in the order shown above, with jump targets relative to its first instruction.

pub fn program_words() -> [32]u16

program

Function · Source

The capture program: its instructions, wrap, a joined RX FIFO, and a left-shifting ISR.

pub fn program() -> rp_pio.Program

divider

Function · Source

The state machine divider, in 256ths, for ticks of tick_hz from a PIO clocked at clock_hz: clock_hz / (4 * tick_hz), which must be a whole number of 256ths from 1 to 65535 255/256. At 125 MHz, for example, 31.25 MHz, 10 MHz, or 1 MHz. InvalidInput otherwise.

pub fn divider(clock_hz: u32, tick_hz: u32) -> u32!hal.Error

word_rising

Function · Source

Whether a pushed word records a rising edge (the level after it is 1).

pub fn word_rising(word: u32) -> bool

word_count

Function · Source

The count of a pushed word, modulo 2^31: the steps since the start, as X counted down from all ones.

pub fn word_count(word: u32) -> u64

extend

Function · Source

The full count of an edge whose count modulo 2^31 is count, given that it happened at most latest ticks after the start: the largest such count up to latest. A count beyond latest, which only an estimate off by more than its slack gives, is taken as is.

pub fn extend(count: u64, latest: u64) -> u64

EdgeCapture

Struct · Source

A capture channel on a PIO state machine; see the package comment. Implements hal.InputCapture.

pub struct EdgeCapture: hal.InputCapture {
    // Private implementation fields omitted.
}

EdgeCapture.new

Function · Source

Capture edges (RISING, FALLING, or BOTH) on GPIO pin with a free state machine of pio, clocked at clock_hz, in ticks of tick_hz (see divider). The program takes 14 of the block’s 32 instruction slots. The pin must be readable: claimed for the block or as an input. InvalidInput for a pin outside the block’s GPIO window (Pio.set_gpio_base), other edges, or a rate divider refuses; Busy if the block has no free state machine or room for the program. SAFETY: timer must be the base address of the chip’s running microsecond timer, whose TIMERAWH and TIMERAWL are at 0x24 and 0x28, and clock_hz the PIO’s clock, from the same crystal.

pub unsafe fn new(pio: &mut rp_pio.Pio, pin: u32, edges: u32, clock_hz: u32, tick_hz: u32, timer: usize) -> EdgeCapture!hal.Error

Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.

EdgeCapture.tick_hz

Function · Source

pub fn tick_hz(&self) -> u32

EdgeCapture.poll_event

Function · Source

The earliest edge not yet reported, as hal.InputCapture.poll_event: its tick count since the capture started. Overrun if the FIFO was full when an edge came, so that edge was lost; the edges still in the FIFO follow.

pub fn poll_event(&mut self, ticks: &mut u64) -> bool!hal.Error

EdgeCapture.rising

Function · Source

Whether the edge poll_event last reported rose.

pub fn rising(&self) -> bool

EdgeCapture.start_us

Function · Source

The microsecond timer’s time when the capture started, tick 0: an edge at ticks came at start_us() + hal.ticks_to_us(ticks, tick_hz).

pub fn start_us(&self) -> u64

EdgeCapture.pin

Function · Source

pub fn pin(&self) -> u32

EdgeCapture.edges

Function · Source

pub fn edges(&self) -> u32

EdgeCapture.machine_index

Function · Source

The state machine, 0 to 3, within its block.

pub fn machine_index(&self) -> u32

EdgeCapture.irq

Function · Source

The block’s interrupt line 0, which listen raises: its number for cortex_m.enable, and its vector name, PIOn_IRQ_0, for @interrupt.

pub fn irq(&self) -> u32

EdgeCapture.listen

Function · Source

Raise the block’s interrupt line 0 while an edge waits in the FIFO, including edges edges leaves out, which poll_event then drops.

pub fn listen(&mut self)

EdgeCapture.ignore

Function · Source

pub fn ignore(&mut self)

EdgeCapture.is_listening

Function · Source

pub fn is_listening(&self) -> bool

EdgeCapture.release

Function · Source

Stop the state machine and give it and the program back to pio, the block it came from.

pub fn release(self, pio: &mut rp_pio.Pio)

Search every guide, reference page, and API declaration.