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 --openin 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;mcu-atmegapub use atmega_hal::pac;mcu-atmegapub use hal::Peripherals;board-selectedpub use port::Pins;board-selectedpub use adc::Adc;mcu-atmegapub use i2c::I2c;mcu-atmegapub use spi::Spi;mcu-atmegapub use usart::Usart;mcu-atmegapub use eeprom::Eeprom;board-selectedpub use avr_device;
Modules§
- adc
mcu-atmega - Analog to Digital converter.
- clock
board-selected - MCU core clock support.
- eeprom
board-selected - i2c
mcu-atmega - I2C bus controller.
- port
board-selected - GPIO & Pin control.
- prelude
mcu-atmega - simple_
pwm board-selected - spi
mcu-atmega - SPI controller.
- usart
mcu-atmega
Macros§
- default_
serial arduino-diecimilaorarduino-mega1280orarduino-mega2560orarduino-uno - Convenience macro to instantiate the
Usartdriver for this board. - pins
board-selected - Convenience macro to instantiate the
Pinsstruct for this board.
Functions§
- delay_
ms board-selected - Delay execution for a number of milliseconds.
- delay_
ns board-selected - Delay execution for a number of nanoseconds.
- delay_
us board-selected - Delay execution for a number of microseconds.
Type Aliases§
- Default
Clock board-selectedand (arduino-diecimilaorarduino-leonardoorarduino-mega1280orarduino-mega2560orarduino-microorarduino-nanoorarduino-unoornano168orsparkfun-promicroorsparkfun-promini-5vortrinket-pro) - Default clock speed for this board.
- Delay
board-selected - Delay type for
embedded-halcompatibility.
Attribute Macros§
- entry
rt - Attribute to declare the entry point of the program