API referencestd/embedded

std/embedded/chip/rp_timer

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

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_timer"

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_timer.dodo
ptr core/ptr rp_timer.dodo

RP2040_INTR

Constant · Source

INTR on each chip; INTE, INTF, and INTS follow it, 4 bytes apart.

pub const RP2040_INTR: usize = 0x34

RP2350_INTR

Constant · Source

pub const RP2350_INTR: usize = 0x3C

ALARM_COUNT

Constant · Source

The alarms of one block.

pub const ALARM_COUNT: u32 = 4

MAX_AHEAD

Constant · Source

The furthest ahead an alarm reaches: below 2^31 ticks, so a target written now is still ahead of the counter’s low 32 bits when the write lands, rather than just behind them, which would fire only after the low 32 bits wrap.

pub const MAX_AHEAD: u64 = 0x7FFF_FFFF

Block

Interface · Source

A peripheral’s 32-bit registers at offsets from one base address, as hal.Registers, but read through &self, so the alarm’s counter and flags are read by &self methods as hal.Counter and hal.Compare want. The timer’s registers change nothing when read.

pub interface Block {
    fn read(&self, offset: usize) -> u32
    fn write(&mut self, offset: usize, value: u32)
}

Mmio

Struct · Source

A block of registers on the chip. Every access is one volatile 32-bit load or store. Move-only: owning it is the permission to use the registers its driver uses.

pub struct Mmio: Block {
    // Private implementation fields omitted.
}

Mmio.at

Function · Source

SAFETY: base must be the 4-aligned base address of a peripheral on this chip whose registers have no side effects when read, every offset its driver uses must be a valid 32-bit register of it, and no other handle or code may access those registers in a conflicting way while this handle exists.

pub unsafe fn at(base: usize) -> Mmio

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

Mmio.base

Function · Source

pub fn base(&self) -> usize

Mmio.read

Function · Source

pub fn read(&self, offset: usize) -> u32

Mmio.write

Function · Source

pub fn write(&mut self, offset: usize, value: u32)

read_count

Function · Source

The 64-bit count of the timer at block, read high, low, high again until the high word holds still.

pub fn read_count<B: Block>(block: &B) -> u64

Alarm

Struct · Source

One alarm of a timer block, counting ticks at the block’s rate. Implements hal.TickCounter, hal.Compare, and hal.PeriodicTimer.

pub struct Alarm<B: Block>: hal.TickCounter + hal.Compare + hal.PeriodicTimer {
    // Private implementation fields omitted.
}

Alarm.new

Function · Source

Alarm number, 0 to 3, of the timer at block, whose INTR is at intr (RP2040_INTR or RP2350_INTR) and which counts at tick_hz. It starts disarmed and periodic mode off; its flags are left as they are. SAFETY: block must be a running timer block of the chip at intr, counting at tick_hz, and this alarm the only user of ALARMn and of bit number of ARMED, INTR, INTE, and INTF.

pub unsafe fn new(block: B, intr: usize, number: u32, tick_hz: u32) -> Alarm<B>

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

Alarm.number

Function · Source

0 to 3.

pub fn number(&self) -> u32

Alarm.tick_hz

Function · Source

pub fn tick_hz(&self) -> u32

Alarm.now

Function · Source

The counter’s low 32 bits, which alarm targets compare with.

pub fn now(&self) -> u32

Alarm.now_ticks

Function · Source

The whole 64-bit count.

pub fn now_ticks(&self) -> u64

Alarm.schedule_at

Function · Source

Fire when the counter’s low 32 bits equal time, replacing any earlier target and periodic mode. A time that has just passed fires only after the low 32 bits wrap.

pub fn schedule_at(&mut self, time: u32)

Alarm.schedule_in

Function · Source

Fire ticks from now: at least 1, and below 2^31 so the target is still ahead when the write lands.

pub fn schedule_in(&mut self, ticks: u32)

Alarm.schedule_at_ticks

Function · Source

Fire when now_ticks() reaches ticks, replacing any earlier target and periodic mode, and clearing an earlier firing; hal.Compare. A count already reached fires at once, raising the interrupt if the alarm listens. InvalidInput for a count more than MAX_AHEAD ahead.

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

Alarm.cancel

Function · Source

Disarm, and end periodic mode: a target no longer fires. An earlier firing stays reported until clear.

pub fn cancel(&mut self)

Alarm.is_armed

Function · Source

True from scheduling until it fires or is cancelled.

pub fn is_armed(&self) -> bool

Alarm.fired

Function · Source

True once it has fired, until clear.

pub fn fired(&self) -> bool

Alarm.clear

Function · Source

Acknowledge a firing. An interrupt handler has to, or the interrupt stays raised and the handler runs again at once.

pub fn clear(&mut self)

Alarm.listen

Function · Source

Raise the alarm’s interrupt when it fires.

pub fn listen(&mut self)

Alarm.ignore

Function · Source

Stop raising the interrupt; fired still reports.

pub fn ignore(&mut self)

Alarm.is_listening

Function · Source

pub fn is_listening(&self) -> bool

Alarm.start

Function · Source

Fire every period_ticks ticks, the first time one period from now; hal.PeriodicTimer. Replaces any target and clears an earlier firing. InvalidInput for 0 or more than MAX_AHEAD ticks.

pub fn start(&mut self, period_ticks: u64) -> void!hal.Error

Alarm.poll_periods

Function · Source

How many periods ended since start or the last call, 0 while none has, or when periodic mode is off. Clears the firing and arms the alarm for the next period still ahead, so call it from the alarm’s interrupt handler, or poll it.

pub fn poll_periods(&mut self) -> u32

Alarm.is_periodic

Function · Source

Whether periodic mode is on, since start and until cancel or a schedule.

pub fn is_periodic(&self) -> bool

Alarm.period_ticks

Function · Source

The period start set.

pub fn period_ticks(&self) -> u64

Alarm.next_ticks

Function · Source

In periodic mode, the count the next period ends at.

pub fn next_ticks(&self) -> u64

Alarm.release

Function · Source

Cancel, stop the interrupt, clear the firing, and return the block.

pub fn release(self) -> B

Search every guide, reference page, and API declaration.