Crate arduino_hal

Source
Expand description

§arduino-hal

Common HAL (hardware abstraction layer) for Arduino boards.

Note: This version of the documentation was built for Arduino Uno. This means that only items which are available for this board are visible. If you are using a different board, try building the documentation locally with

cargo doc --open

in your project (where arduino-hal is included with the feature-flag for your board).

§Usage

For setting up a new project, the avr-hal-template is the recommended baseline. Applications should be built ontop of the following skeleton:

#![no_std]
#![no_main]

use panic_halt as _;

#[arduino_hal::entry]
fn main() -> ! {
    let dp = arduino_hal::Peripherals::take().unwrap();
    let pins = arduino_hal::pins!(dp);

    loop { }
}

For examples, please check the avr-hal examples: https://github.com/Rahix/avr-hal/tree/main/examples

Re-exports§

pub use atmega_hal as hal;
pub use atmega_hal::pac;
pub use hal::Peripherals;
pub use port::Pins;
pub use adc::Adc;
pub use i2c::I2c;
pub use spi::Spi;
pub use usart::Usart;
pub use eeprom::Eeprom;

Modules§

adc
Analog to Digital converter.
clock
MCU core clock support.
eeprom
i2c
I2C bus controller.
port
GPIO & Pin control.
prelude
simple_pwm
spi
SPI controller.
usart

Macros§

default_serial
Convenience macro to instantiate the Usart driver for this board.
pins
Convenience macro to instantiate the Pins struct for this board.

Functions§

delay_ms
Delay execution for a number of milliseconds.
delay_ns
Delay execution for a number of nanoseconds.
delay_us
Delay execution for a number of microseconds.

Type Aliases§

DefaultClock
Default clock speed for this board.
Delay
Delay type for embedded-hal compatibility.

Attribute Macros§

entryrt
Attribute to declare the entry point of the program