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/arduino_uno"
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 |
|---|---|---|
atmega328p |
std/embedded/chip/atmega328p |
arduino_uno.dodo |
hal |
std/embedded/hal |
arduino_uno.dodo |
NAME
Constant · Source
pub const NAME: &str = "Arduino Uno"
LED_PIN
Constant · Source
pub const LED_PIN: u32 = 13
CPU_HZ
Constant · Source
pub const CPU_HZ: u32 = 16_000_000
USB_BAUD
Constant · Source
The serial port’s speed through the USB cable.
pub const USB_BAUD: u32 = 115_200
D0
Constant · Source
pub const D0: u32 = 0
D1
Constant · Source
pub const D1: u32 = 1
D2
Constant · Source
pub const D2: u32 = 2
D3
Constant · Source
pub const D3: u32 = 3
D4
Constant · Source
pub const D4: u32 = 4
D5
Constant · Source
pub const D5: u32 = 5
D6
Constant · Source
pub const D6: u32 = 6
D7
Constant · Source
pub const D7: u32 = 7
D8
Constant · Source
pub const D8: u32 = 8
D9
Constant · Source
pub const D9: u32 = 9
D10
Constant · Source
pub const D10: u32 = 10
D11
Constant · Source
pub const D11: u32 = 11
D12
Constant · Source
pub const D12: u32 = 12
D13
Constant · Source
pub const D13: u32 = 13
A0
Constant · Source
pub const A0: u32 = 14
A1
Constant · Source
pub const A1: u32 = 15
A2
Constant · Source
pub const A2: u32 = 16
A3
Constant · Source
pub const A3: u32 = 17
A4
Constant · Source
pub const A4: u32 = 18
A5
Constant · Source
pub const A5: u32 = 19
I2C_SDA_PIN
Constant · Source
The usual bus pins, fixed by the chip: I2C on A4 (SDA) and A5 (SCL), also on the header next to AREF; SPI on D13 (clock), D11 (data out), D12 (data in), with D10 as chip select; and the serial port on D1 (TX) and D0 (RX), which the USB cable shares:
i2c := b.pins.i2c(I2C_SDA_PIN, I2C_SCL_PIN, hal.I2C_FAST_HZ)!
The LED shares D13 with the SPI clock: release it first,
b.pins.release(b.led), by taking the board apart withlet.
pub const I2C_SDA_PIN: u32 = 18
I2C_SCL_PIN
Constant · Source
pub const I2C_SCL_PIN: u32 = 19
SPI_RX_PIN
Constant · Source
pub const SPI_RX_PIN: u32 = 12
SPI_SELECT_PIN
Constant · Source
pub const SPI_SELECT_PIN: u32 = 10
SPI_CLOCK_PIN
Constant · Source
pub const SPI_CLOCK_PIN: u32 = 13
SPI_TX_PIN
Constant · Source
pub const SPI_TX_PIN: u32 = 11
UART_TX_PIN
Constant · Source
pub const UART_TX_PIN: u32 = 1
UART_RX_PIN
Constant · Source
pub const UART_RX_PIN: u32 = 0
Board
Struct · Source
pub struct Board {
// The user LED, an output pin that is on when high.
pub led: atmega328p.Pin
// The remaining pins, and the serial port, I2C, SPI, PWM and analog
// inputs on them; D13 is already taken by `led`.
pub pins: atmega328p.Pins
// Microseconds since take(), and delays: delay_us, delay_ms, now_us.
pub timer: atmega328p.Timer
// The watchdog, stopped until `start(timeout_ms)`.
pub watchdog: atmega328p.Watchdog
// The 1 KiB EEPROM, for data that survives power cycles and flashing:
// read(offset, buffer) and update(offset, bytes).
pub eeprom: atmega328p.Eeprom
// The USB connector's serial port.
pub usb: Usb
}
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
Usb
Struct · Source
The USB connector, as
b.usb.
pub struct Usb {
}
Usb.serial
Function · Source
The serial port to the computer, at USB_BAUD: the chip’s serial port on D0 and D1, which the board’s USB interface carries. “\n” goes out as “\r\n”, as terminals expect. Busy if the port, or D0 or D1, is taken.
pub fn serial(&mut self) -> atmega328p.Serial!hal.Error
Usb.serial_at
Function · Source
serialat another baud rate, such as 9600 or 57600.
pub fn serial_at(&mut self, baud: u32) -> atmega328p.Serial!hal.Error
Usb.release_serial
Function · Source
Give back the port.
pub fn release_serial(&mut self, port: atmega328p.Serial)
report_panic
Function · Source
Write a failed check’s message to the serial port, if it 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:
checkandfilemust 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.
restart
Function · Source
Restart the board through the watchdog; the bootloader starts the program again at once. Does not return.
pub fn restart()