Skip to content

Commit 0fdbc49

Browse files
attiny-hal: Add ATtiny84 support
1 parent 9f2f241 commit 0fdbc49

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

mcu/attiny-hal/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2018"
77
[features]
88
rt = ["avr-device/rt"]
99
device-selected = []
10+
attiny84 = ["avr-device/attiny84", "device-selected"]
1011
attiny85 = ["avr-device/attiny85", "device-selected"]
1112
attiny88 = ["avr-device/attiny88", "device-selected"]
1213

mcu/attiny-hal/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ compile_error!(
2828
"
2929
);
3030

31+
#[cfg(feature = "attiny84")]
32+
pub use avr_device::attiny84 as pac;
33+
3134
/// Reexport of `attiny85` from `avr-device`
3235
#[cfg(feature = "attiny85")]
3336
pub use avr_device::attiny85 as pac;
@@ -53,6 +56,13 @@ pub use port::Pins;
5356

5457
pub struct Attiny;
5558

59+
#[cfg(feature = "attiny84")]
60+
#[macro_export]
61+
macro_rules! pins {
62+
($p:expr) => {
63+
$crate::Pins::new($p.PORTA, $p.PORTB)
64+
};
65+
}
5666
#[cfg(feature = "attiny85")]
5767
#[macro_export]
5868
macro_rules! pins {

mcu/attiny-hal/src/port.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
#[cfg(feature = "attiny84")]
2+
avr_hal_generic::impl_port_traditional! {
3+
enum Ports {
4+
PORTA: (crate::pac::PORTA, porta, pina, ddra),
5+
PORTB: (crate::pac::PORTB, portb, pinb, ddrb),
6+
}
7+
8+
pub struct Pins {
9+
pa0: PA0 = (crate::pac::PORTA, PORTA, 0, porta, pina, ddra),
10+
pa1: PA1 = (crate::pac::PORTA, PORTA, 1, porta, pina, ddra),
11+
pa2: PA2 = (crate::pac::PORTA, PORTA, 2, porta, pina, ddra),
12+
pa3: PA3 = (crate::pac::PORTA, PORTA, 3, porta, pina, ddra),
13+
pa4: PA4 = (crate::pac::PORTA, PORTA, 4, porta, pina, ddra),
14+
pa5: PA5 = (crate::pac::PORTA, PORTA, 5, porta, pina, ddra),
15+
pa6: PA6 = (crate::pac::PORTA, PORTA, 6, porta, pina, ddra),
16+
pa7: PA7 = (crate::pac::PORTA, PORTA, 7, porta, pina, ddra),
17+
pb0: PB0 = (crate::pac::PORTB, PORTB, 0, portb, pinb, ddrb),
18+
pb1: PB1 = (crate::pac::PORTB, PORTB, 1, portb, pinb, ddrb),
19+
pb2: PB2 = (crate::pac::PORTB, PORTB, 2, portb, pinb, ddrb),
20+
pb3: PB3 = (crate::pac::PORTB, PORTB, 3, portb, pinb, ddrb),
21+
}
22+
}
23+
124
#[cfg(feature = "attiny85")]
225
avr_hal_generic::impl_port_traditional! {
326
enum Ports {

0 commit comments

Comments
 (0)