1#![no_std]
23//! `attiny-hal`
4//! =============
5//! Common HAL (hardware abstraction layer) for ATtiny* microcontrollers.
6//!
7//! **Note**: This version of the documentation was built for
8#![cfg_attr(feature = "attiny85", doc = "**ATtiny85**.")]
9#![cfg_attr(feature = "attiny88", doc = "**ATtiny88**.")]
10#![cfg_attr(feature = "attiny167", doc = "**ATtiny167**.")]
11#![cfg_attr(feature = "attiny2313", doc = "**ATtiny2313**.")]
12//! This means that only items which are available for this MCU are visible. If you are using
13//! a different chip, try building the documentation locally with:
14//!
15//! ```text
16//! cargo doc --features <your-mcu> --open
17//! ```
1819#[cfg(all(
20 not(feature = "device-selected"),
21 not(feature = "disable-device-selection-error")
22))]
23compile_error!(
24"This crate requires you to specify your target chip as a feature.
2526 Please select one of the following
2728 * attiny85
29 * attiny88
30 * attiny167
31 * attiny2313
32 "
33);
3435/// Reexport of `attiny167` from `avr-device`
36///
37#[cfg(feature = "attiny167")]
38pub use avr_device::attiny167 as pac;
39/// Reexport of `attiny2313` from `avr-device`
40///
41#[cfg(feature = "attiny2313")]
42pub use avr_device::attiny2313 as pac;
43/// Reexport of `attiny84` from `avr-device`
44///
45#[cfg(feature = "attiny84")]
46pub use avr_device::attiny84 as pac;
47/// Reexport of `attiny85` from `avr-device`
48///
49#[cfg(feature = "attiny85")]
50pub use avr_device::attiny85 as pac;
51/// Reexport of `attiny88` from `avr-device`
52///
53#[cfg(feature = "attiny88")]
54pub use avr_device::attiny88 as pac;
5556/// See [`avr_device::entry`](https://docs.rs/avr-device/latest/avr_device/attr.entry.html).
57#[cfg(feature = "rt")]
58pub use avr_device::entry;
5960#[cfg(feature = "device-selected")]
61pub use pac::Peripherals;
6263pub use avr_hal_generic::clock;
64pub use avr_hal_generic::delay;
65pub use avr_hal_generic::prelude;
6667// ATtiny2313 does not have ADC and will not compile with this module
68#[cfg(all(feature = "device-selected", not(feature = "attiny2313")))]
69pub mod adc;
70#[cfg(all(feature = "device-selected", not(feature = "attiny2313")))]
71pub use adc::Adc;
7273#[cfg(feature = "device-selected")]
74pub mod port;
75#[cfg(feature = "device-selected")]
76pub use port::Pins;
7778#[cfg(feature = "device-selected")]
79pub mod simple_pwm;
8081#[cfg(feature = "device-selected")]
82pub mod wdt;
83#[cfg(feature = "device-selected")]
84pub use wdt::Wdt;
8586#[cfg(feature = "device-selected")]
87pub mod eeprom;
88#[cfg(feature = "device-selected")]
89pub use eeprom::Eeprom;
9091#[cfg(feature = "device-selected")]
92pub mod spi;
93#[cfg(feature = "device-selected")]
94pub use spi::Spi;
9596pub struct Attiny;
9798#[cfg(feature = "attiny84")]
99#[macro_export]
100macro_rules! pins {
101 ($p:expr) => {
102$crate::Pins::new($p.PORTA, $p.PORTB)
103 };
104}
105#[cfg(feature = "attiny85")]
106#[macro_export]
107macro_rules! pins {
108 ($p:expr) => {
109$crate::Pins::new($p.PORTB)
110 };
111}
112#[cfg(feature = "attiny88")]
113#[macro_export]
114macro_rules! pins {
115 ($p:expr) => {
116$crate::Pins::new($p.PORTA, $p.PORTB, $p.PORTC, $p.PORTD)
117 };
118}
119#[cfg(feature = "attiny167")]
120#[macro_export]
121macro_rules! pins {
122 ($p:expr) => {
123$crate::Pins::new($p.PORTA, $p.PORTB)
124 };
125}
126#[cfg(feature = "attiny2313")]
127#[macro_export]
128macro_rules! pins {
129 ($p:expr) => {
130$crate::Pins::new($p.PORTA, $p.PORTB, $p.PORTD)
131 };
132}