API referencestd/embedded

std/embedded/board/digispark

Public declarations, types, methods, and source contracts for std/embedded/board/digispark.

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/board/digispark"

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
attiny85 std/embedded/chip/attiny85 digispark.dodo
hal std/embedded/hal digispark.dodo

NAME

Constant · Source

pub const NAME: &str = "Digispark"

LED_PIN

Constant · Source

pub const LED_PIN: u32 = 1

CPU_HZ

Constant · Source

The clock micronucleus tunes the internal oscillator to.

pub const CPU_HZ: u32 = 16_500_000

P0

Constant · Source

pub const P0: u32 = 0

P1

Constant · Source

pub const P1: u32 = 1

P2

Constant · Source

pub const P2: u32 = 2

P3

Constant · Source

pub const P3: u32 = 3

P4

Constant · Source

pub const P4: u32 = 4

P5

Constant · Source

pub const P5: u32 = 5

I2C_SDA_PIN

Constant · Source

The usual bus pins, fixed by the chip’s USI: I2C on P0 (SDA) and P2 (SCL); SPI on P2 (clock), P1 (data out) and P0 (data in), with P3 as chip select. The serial port can be on any pin; P2 is free of USB and of the LED, and needs no receive pin, as the port only transmits:

i2c := b.pins.i2c(I2C_SDA_PIN, I2C_SCL_PIN, hal.I2C_STANDARD_HZ)! port := b.pins.uart(UART_TX_PIN, none, 9600)!

The LED shares P1 with SPI’s data out: release it first, b.pins.release(b.led), by taking the board apart with let.

pub const I2C_SDA_PIN: u32 = 0

I2C_SCL_PIN

Constant · Source

pub const I2C_SCL_PIN: u32 = 2

SPI_RX_PIN

Constant · Source

pub const SPI_RX_PIN: u32 = 0

SPI_SELECT_PIN

Constant · Source

pub const SPI_SELECT_PIN: u32 = 3

SPI_CLOCK_PIN

Constant · Source

pub const SPI_CLOCK_PIN: u32 = 2

SPI_TX_PIN

Constant · Source

pub const SPI_TX_PIN: u32 = 1

UART_TX_PIN

Constant · Source

pub const UART_TX_PIN: u32 = 2

UART_RX_PIN

Constant · Source

The port cannot receive; Pins.uart takes none for its receive pin.

pub const UART_RX_PIN: u32 = 5

Board

Struct · Source

pub struct Board {
    // The user LED, an output pin that is on when high.
    pub led: attiny85.Pin
    // The remaining pins, and the serial port, I2C, SPI, PWM and analog
    // inputs on them; P1 is already taken by `led`.
    pub pins: attiny85.Pins
    // Microseconds since take(), and delays: delay_us, delay_ms, now_us.
    pub timer: attiny85.Timer
    // The watchdog, stopped until `start(timeout_ms)`.
    pub watchdog: attiny85.Watchdog
    // The 512-byte EEPROM, for data that survives power cycles and
    // flashing: read(offset, buffer) and update(offset, bytes).
    pub eeprom: attiny85.Eeprom
}

take

Function · Source

Start the chip’s time base and claim the LED. A second call returns hal.Error.Busy.

pub fn take() -> Board!hal.Error

report_panic

Function · Source

Write a failed check’s message to the serial port, if one is open, as the default panic hook does before it halts. For a panic hook of your own:

extern “C” fn dodo_board_panic(check: *const u8, file: *const u8, line: u32, column: u32) { unsafe { board.report_panic(check, file, line, column) } board.restart() }

SAFETY: check and file must be the hook’s strings, which are in program memory, and the caller must halt or reset afterwards, as this takes over the serial port.

pub unsafe fn report_panic(check: *const u8, file: *const u8, line: u32, column: u32)

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

reboot_to_bootloader

Function · Source

Start the bootloader, as if the board had been plugged in: dodo run can flash it for the next five seconds, after which the program starts again. Does not return.

pub fn reboot_to_bootloader()

restart

Function · Source

Restart the program, through the bootloader and its five seconds. Does not return.

pub fn restart()

Search every guide, reference page, and API declaration.