attiny_hal/
port.rs

1//! Port
2//!
3//! # Example
4//!
5//! For full source code, please refer to the ATmega port example:
6//! [`atmega2560-blink.rs`](https://github.com/Rahix/avr-hal/blob/main/examples/atmega2560/src/bin/atmega2560-blink.rs)
7//!
8//! ```
9//! let dp = attiny_hal::Peripherals::take().unwrap();
10//! let pins = attiny_hal::pins!(dp);
11//!
12//! let mut led = pins.pb2.into_output();
13//!
14//! loop {
15//!     led.toggle();
16//!     delay_ms(1000);
17//! }
18//! ```
19
20pub use avr_hal_generic::port::{mode, PinMode, PinOps};
21
22#[cfg(feature = "attiny2313")]
23avr_hal_generic::impl_port_traditional! {
24    enum Ports {
25        A: crate::pac::PORTA = [0, 1, 2],
26        B: crate::pac::PORTB = [0, 1, 2, 3, 4, 5, 6, 7],
27        D: crate::pac::PORTD = [0, 1, 2, 3, 4, 5, 6],
28    }
29}
30
31#[cfg(feature = "attiny167")]
32avr_hal_generic::impl_port_traditional! {
33    enum Ports {
34        A: crate::pac::PORTA = [0, 1, 2, 3, 4, 5, 6, 7],
35        B: crate::pac::PORTB = [0, 1, 2, 3, 4, 5, 6, 7],
36    }
37}
38
39#[cfg(feature = "attiny84")]
40avr_hal_generic::impl_port_traditional! {
41    enum Ports {
42        A: crate::pac::PORTA = [0, 1, 2, 3, 4, 5, 6, 7],
43        B: crate::pac::PORTB = [0, 1, 2, 3],
44    }
45}
46
47#[cfg(feature = "attiny85")]
48avr_hal_generic::impl_port_traditional! {
49    enum Ports {
50        B: crate::pac::PORTB = [0, 1, 2, 3, 4, 5],
51    }
52}
53
54#[cfg(feature = "attiny88")]
55avr_hal_generic::impl_port_traditional! {
56    enum Ports {
57        A: crate::pac::PORTA = [0, 1, 2, 3],
58        B: crate::pac::PORTB = [0, 1, 2, 3, 4, 5, 6, 7],
59        C: crate::pac::PORTC = [0, 1, 2, 3, 4, 5, 6, 7],
60        D: crate::pac::PORTD = [0, 1, 2, 3, 4, 5, 6, 7],
61    }
62}