From 1e0eb40c3a8d82c6a3452a21e3cb3c6e56ce346f Mon Sep 17 00:00:00 2001 From: Andrew Dona-Couch Date: Fri, 31 Jul 2020 00:09:36 -0400 Subject: [PATCH] Add support for ATmega2560 --- Cargo.toml | 1 + Makefile | 2 +- README.md | 1 + patch/atmega2560.yaml | 7 + src/devices/mod.rs | 19 + src/lib.rs | 5 + vendor/atmega2560.atdf | 1859 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1893 insertions(+), 1 deletion(-) create mode 100644 patch/atmega2560.yaml create mode 100644 vendor/atmega2560.atdf diff --git a/Cargo.toml b/Cargo.toml index e7896f5..1ba30af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ include = [ [features] atmega1280 = [] +atmega2560 = [] atmega8 = [] atmega328p = [] atmega32u4 = [] diff --git a/Makefile b/Makefile index a8527fa..5cbec8c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: deps chips -CHIPS := atmega1280 atmega8 atmega328p atmega32u4 atmega64 attiny85 +CHIPS := atmega1280 atmega2560 atmega8 atmega328p atmega32u4 atmega64 attiny85 RUSTUP_TOOLCHAIN ?= nightly diff --git a/README.md b/README.md index dc44eb0..c2c7445 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ features = ["atmega32u4"] Via the feature you can select which chip you want the register specifications for. The following list is what is currently supported: * `atmega1280` +* `atmega2560` * `atmega8` * `atmega328p` * `atmega32u4` diff --git a/patch/atmega2560.yaml b/patch/atmega2560.yaml new file mode 100644 index 0000000..6a5afd8 --- /dev/null +++ b/patch/atmega2560.yaml @@ -0,0 +1,7 @@ +_include: + - "common/ac.yaml" + - "common/adc.yaml" + - "common/spi.yaml" + - "common/twi.yaml" + - "common/usart.yaml" + - "common/wdt.yaml" diff --git a/src/devices/mod.rs b/src/devices/mod.rs index 2192f44..41dd429 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -22,6 +22,25 @@ impl atmega1280::Peripherals { } } +/// [ATmega2560](https://www.microchip.com/wwwproducts/en/ATmega2560) +#[cfg(feature = "atmega2560")] +pub mod atmega2560; + +#[cfg(feature = "atmega2560")] +impl atmega2560::Peripherals { + /// Returns all the peripherals *once* + #[inline] + pub fn take() -> Option { + crate::interrupt::free(|_| { + if unsafe { DEVICE_PERIPHERALS } { + None + } else { + Some(unsafe { atmega2560::Peripherals::steal() }) + } + }) + } +} + /// [ATmega328P](https://www.microchip.com/wwwproducts/en/ATmega328P) #[cfg(feature = "atmega328p")] pub mod atmega328p; diff --git a/src/lib.rs b/src/lib.rs index faff945..c95ac64 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ //! This crate contains register definitions for #![cfg_attr(feature = "atmega1280", doc = "**atmega1280**,")] +#![cfg_attr(feature = "atmega2560", doc = "**atmega2560**,")] #![cfg_attr(feature = "atmega8", doc = "**atmega8**,")] #![cfg_attr(feature = "atmega328p", doc = "**atmega328p**,")] #![cfg_attr(feature = "atmega32u4", doc = "**atmega32u4**,")] @@ -10,6 +11,7 @@ //! Which chips the crate is built for depends on the feature flag used. //! The following chips are available (using feature flags of the same name): //! * `atmega1280` +//! * `atmega2560` //! * `atmega8` //! * `atmega328p` //! * `atmega32u4` @@ -64,6 +66,8 @@ mod devices; #[cfg(feature = "atmega1280")] pub use crate::devices::atmega1280; +#[cfg(feature = "atmega2560")] +pub use crate::devices::atmega2560; #[cfg(feature = "atmega328p")] pub use crate::devices::atmega328p; #[cfg(feature = "atmega32u4")] @@ -77,6 +81,7 @@ pub use crate::devices::attiny85; #[cfg(not(any( feature = "atmega1280", + feature = "atmega2560", feature = "atmega8", feature = "atmega328p", feature = "atmega32u4", diff --git a/vendor/atmega2560.atdf b/vendor/atmega2560.atdf new file mode 100644 index 0000000..806bf97 --- /dev/null +++ b/vendor/atmega2560.atdf @@ -0,0 +1,1859 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.49.0