Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atmega-hal ATtiny88 support #158

Merged
merged 4 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
name: attiny85
spec: attiny85
crate: attiny-hal
- type: mcu
name: attiny88
spec: attiny88
crate: attiny-hal
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
1 change: 1 addition & 0 deletions mcu/attiny-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2018"
rt = ["avr-device/rt"]
device-selected = []
attiny85 = ["avr-device/attiny85", "device-selected"]
attiny88 = ["avr-device/attiny88", "device-selected"]

# Allow certain downstream crates to overwrite the device selection error by themselves.
disable-device-selection-error = []
Expand Down
12 changes: 12 additions & 0 deletions mcu/attiny-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ compile_error!(
Please select one of the following

* attiny85
* attiny88
"
);

/// Reexport of `attiny85` from `avr-device`
#[cfg(feature = "attiny85")]
pub use avr_device::attiny85 as pac;

/// Reexport of `attiny88` from `avr-device`
#[cfg(feature = "attiny88")]
pub use avr_device::attiny88 as pac;

/// See [`avr_device::entry`](https://docs.rs/avr-device/latest/avr_device/attr.entry.html).
#[cfg(feature = "rt")]
pub use avr_device::entry;
Expand All @@ -41,3 +46,10 @@ macro_rules! pins {
$crate::Pins::new($p.PORTB)
};
}
#[cfg(feature = "attiny88")]
#[macro_export]
macro_rules! pins {
($p:expr) => {
$crate::Pins::new($p.PORTA, $p.PORTB, $p.PORTC, $p.PORTD)
};
}
41 changes: 41 additions & 0 deletions mcu/attiny-hal/src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,44 @@ avr_hal_generic::impl_port_traditional! {
pb5: PB5 = (crate::pac::PORTB, PORTB, 5, portb, pinb, ddrb),
}
}

#[cfg(feature = "attiny88")]
avr_hal_generic::impl_port_traditional! {
enum Ports {
PORTA: (crate::pac::PORTA, porta, pina, ddra),
PORTB: (crate::pac::PORTB, portb, pinb, ddrb),
PORTC: (crate::pac::PORTC, portc, pinc, ddrc),
PORTD: (crate::pac::PORTD, portd, pind, ddrd),
}

pub struct Pins {
pa0: PA0 = (crate::pac::PORTA, PORTA, 0, porta, pina, ddra),
pa1: PA1 = (crate::pac::PORTA, PORTA, 1, porta, pina, ddra),
pa2: PA2 = (crate::pac::PORTA, PORTA, 2, porta, pina, ddra),
pa3: PA3 = (crate::pac::PORTA, PORTA, 3, porta, pina, ddra),
pb0: PB0 = (crate::pac::PORTB, PORTB, 0, portb, pinb, ddrb),
pb1: PB1 = (crate::pac::PORTB, PORTB, 1, portb, pinb, ddrb),
pb2: PB2 = (crate::pac::PORTB, PORTB, 2, portb, pinb, ddrb),
pb3: PB3 = (crate::pac::PORTB, PORTB, 3, portb, pinb, ddrb),
pb4: PB4 = (crate::pac::PORTB, PORTB, 4, portb, pinb, ddrb),
pb5: PB5 = (crate::pac::PORTB, PORTB, 5, portb, pinb, ddrb),
pb6: PB6 = (crate::pac::PORTB, PORTB, 6, portb, pinb, ddrb),
pb7: PB7 = (crate::pac::PORTB, PORTB, 7, portb, pinb, ddrb),
pc0: PC0 = (crate::pac::PORTC, PORTC, 0, portc, pinc, ddrc),
pc1: PC1 = (crate::pac::PORTC, PORTC, 1, portc, pinc, ddrc),
pc2: PC2 = (crate::pac::PORTC, PORTC, 2, portc, pinc, ddrc),
pc3: PC3 = (crate::pac::PORTC, PORTC, 3, portc, pinc, ddrc),
pc4: PC4 = (crate::pac::PORTC, PORTC, 4, portc, pinc, ddrc),
pc5: PC5 = (crate::pac::PORTC, PORTC, 5, portc, pinc, ddrc),
pc6: PC6 = (crate::pac::PORTC, PORTC, 6, portc, pinc, ddrc),
pc7: PC7 = (crate::pac::PORTC, PORTC, 7, portc, pinc, ddrc),
pd0: PD0 = (crate::pac::PORTD, PORTD, 0, portd, pind, ddrd),
pd1: PD1 = (crate::pac::PORTD, PORTD, 1, portd, pind, ddrd),
pd2: PD2 = (crate::pac::PORTD, PORTD, 2, portd, pind, ddrd),
pd3: PD3 = (crate::pac::PORTD, PORTD, 3, portd, pind, ddrd),
pd4: PD4 = (crate::pac::PORTD, PORTD, 4, portd, pind, ddrd),
pd5: PD5 = (crate::pac::PORTD, PORTD, 5, portd, pind, ddrd),
pd6: PD6 = (crate::pac::PORTD, PORTD, 6, portd, pind, ddrd),
pd7: PD7 = (crate::pac::PORTD, PORTD, 7, portd, pind, ddrd),
}
}