From 746dd40539bf251aa42ddb89c45fee2b136f0ad1 Mon Sep 17 00:00:00 2001 From: David Morrison Date: Sat, 6 Mar 2021 23:40:09 -0800 Subject: [PATCH] add atmega8u2 --- Cargo.toml | 1 + Makefile | 2 +- README.md | 1 + patch/atmega8u2.yaml | 16 + patch/timer/atmega8u2.yaml | 10 + src/devices/mod.rs | 19 + src/lib.rs | 5 + vendor/atmega8u2.atdf | 1063 ++++++++++++++++++++++++++++++++++++ 8 files changed, 1116 insertions(+), 1 deletion(-) create mode 100644 patch/atmega8u2.yaml create mode 100644 patch/timer/atmega8u2.yaml create mode 100644 vendor/atmega8u2.atdf diff --git a/Cargo.toml b/Cargo.toml index 0532d82..814a9df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ atmega1280 = ["device-selected"] atmega168 = ["device-selected"] atmega2560 = ["device-selected"] atmega8 = ["device-selected"] +atmega8u2 = ["device-selected"] atmega328p = ["device-selected"] atmega328pb = ["device-selected"] atmega4809 = ["device-selected"] diff --git a/Makefile b/Makefile index a216b06..ba3532a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: deps chips -CHIPS := atmega1280 atmega168 atmega2560 atmega8 atmega328p atmega328pb atmega32u4 atmega4809 atmega48p atmega64 atmega644 attiny84 attiny85 attiny88 attiny841 attiny861 +CHIPS := atmega1280 atmega168 atmega2560 atmega8 atmega8u2 atmega328p atmega328pb atmega32u4 atmega4809 atmega48p atmega64 atmega644 attiny84 attiny85 attiny88 attiny841 attiny861 RUSTUP_TOOLCHAIN ?= nightly diff --git a/README.md b/README.md index b61c2d2..ede01dd 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Via the feature you can select which chip you want the register specifications f * `atmega168` * `atmega2560` * `atmega8` +* `atmega8u2` * `atmega328p` * `atmega32u4` * `atmega4809` diff --git a/patch/atmega8u2.yaml b/patch/atmega8u2.yaml new file mode 100644 index 0000000..568fc78 --- /dev/null +++ b/patch/atmega8u2.yaml @@ -0,0 +1,16 @@ +_svd: ../svd/atmega8u2.svd + +_include: + - "common/ac.yaml" + - "common/eeprom.yaml" + - "common/port.yaml" + - "common/spi.yaml" + - "common/usart.yaml" + - "common/wdt.yaml" + - "timer/atmega8u2.yaml" + +PLL: + PLLCSR: + _modify: + PLOCK: + access: read-only diff --git a/patch/timer/atmega8u2.yaml b/patch/timer/atmega8u2.yaml new file mode 100644 index 0000000..95e4c60 --- /dev/null +++ b/patch/timer/atmega8u2.yaml @@ -0,0 +1,10 @@ +# This intermediate file is needed because peripheral-level includes are not +# supported in top-level files. + +TC0: + _include: + - "dev/8bit.yaml" + +TC1: + _include: + - "dev/16bit.yaml" diff --git a/src/devices/mod.rs b/src/devices/mod.rs index 8722d6c..6f34800 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -174,6 +174,25 @@ impl atmega8::Peripherals { } } +/// [ATmega8u2](https://www.microchip.com/wwwproducts/en/ATmega8u2) +#[cfg(feature = "atmega8u2")] +pub mod atmega8u2; + +#[cfg(feature = "atmega8u2")] +impl atmega8u2::Peripherals { + /// Returns all the peripherals *once* + #[inline] + pub fn take() -> Option { + crate::interrupt::free(|_| { + if unsafe { DEVICE_PERIPHERALS } { + None + } else { + Some(unsafe { atmega8u2::Peripherals::steal() }) + } + }) + } +} + /// [ATmega64](https://www.microchip.com/wwwproducts/en/ATmega64) #[cfg(feature = "atmega64")] pub mod atmega64; diff --git a/src/lib.rs b/src/lib.rs index d236f4c..0ecf323 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ #![cfg_attr(feature = "atmega168", doc = "**atmega168**,")] #![cfg_attr(feature = "atmega2560", doc = "**atmega2560**,")] #![cfg_attr(feature = "atmega8", doc = "**atmega8**,")] +#![cfg_attr(feature = "atmega8u2", doc = "**atmega8u2**,")] #![cfg_attr(feature = "atmega328p", doc = "**atmega328p**,")] #![cfg_attr(feature = "atmega328pb", doc = "**atmega328pb**,")] #![cfg_attr(feature = "atmega32u4", doc = "**atmega32u4**,")] @@ -23,6 +24,7 @@ //! * `atmega168` //! * `atmega2560` //! * `atmega8` +//! * `atmega8u2` //! * `atmega328p` //! * `atmega328pb` //! * `atmega32u4` @@ -97,6 +99,7 @@ compile_error!( * atmega64 * atmega644 * atmega8 + * atmega8u2 * attiny84 * attiny841 * attiny85 @@ -130,6 +133,8 @@ pub use crate::devices::atmega64; pub use crate::devices::atmega644; #[cfg(feature = "atmega8")] pub use crate::devices::atmega8; +#[cfg(feature = "atmega8u2")] +pub use crate::devices::atmega8u2; #[cfg(feature = "attiny84")] pub use crate::devices::attiny84; #[cfg(feature = "attiny841")] diff --git a/vendor/atmega8u2.atdf b/vendor/atmega8u2.atdf new file mode 100644 index 0000000..6873576 --- /dev/null +++ b/vendor/atmega8u2.atdf @@ -0,0 +1,1063 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +