From 290613454fbdc5e4ac98e53deccaf74dafc88963 Mon Sep 17 00:00:00 2001 From: Rahix Date: Tue, 16 Jun 2020 20:31:39 +0200 Subject: [PATCH] Add basic support for ATmega64 Pull in the ATDF file from Microchip and add all the necessary plumbing around the code-base to make it compile. Not tested against real hardware and no device-specific patches are included yet. Signed-off-by: Rahix --- Cargo.toml | 1 + Makefile | 2 +- README.md | 1 + patch/atmega64.yaml | 4 + src/devices/mod.rs | 19 + src/lib.rs | 5 + vendor/atmega64.atdf | 1300 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1331 insertions(+), 1 deletion(-) create mode 100644 patch/atmega64.yaml create mode 100644 vendor/atmega64.atdf diff --git a/Cargo.toml b/Cargo.toml index f2df584..00b1ca8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ atmega1280 = [] atmega8 = [] atmega328p = [] atmega32u4 = [] +atmega64 = [] attiny85 = [] rt = ["avr-device-macros"] diff --git a/Makefile b/Makefile index 3f91e3a..01dd363 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: deps chips -CHIPS := atmega1280 atmega8 atmega328p atmega32u4 attiny85 +CHIPS := atmega1280 atmega8 atmega328p atmega32u4 atmega64 attiny85 PATCHES := $(foreach chip, $(CHIPS), $(wildcard patch/$(chip).yaml)) DEPS := $(foreach patch, $(PATCHES), $(patsubst patch/%.yaml, .deps/%.d, $(patch))) diff --git a/README.md b/README.md index cfc24fe..6cecdef 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Via the feature you can select which chip you want the register specifications f * `atmega8` * `atmega328p` * `atmega32u4` +* `atmega64` * `attiny85` ## Internals diff --git a/patch/atmega64.yaml b/patch/atmega64.yaml new file mode 100644 index 0000000..97a1d94 --- /dev/null +++ b/patch/atmega64.yaml @@ -0,0 +1,4 @@ +_include: + - "common/ac.yaml" + - "common/spi.yaml" + - "common/usart.yaml" diff --git a/src/devices/mod.rs b/src/devices/mod.rs index a586932..2192f44 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -79,6 +79,25 @@ impl atmega8::Peripherals { } } +/// [ATmega64](https://www.microchip.com/wwwproducts/en/ATmega64) +#[cfg(feature = "atmega64")] +pub mod atmega64; + +#[cfg(feature = "atmega64")] +impl atmega64::Peripherals { + /// Returns all the peripherals *once* + #[inline] + pub fn take() -> Option { + crate::interrupt::free(|_| { + if unsafe { DEVICE_PERIPHERALS } { + None + } else { + Some(unsafe { atmega64::Peripherals::steal() }) + } + }) + } +} + /// [ATtiny85](https://www.microchip.com/wwwproducts/en/ATtiny85) #[cfg(feature = "attiny85")] pub mod attiny85; diff --git a/src/lib.rs b/src/lib.rs index 24edaea..608c097 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ #![cfg_attr(feature = "atmega8", doc = "**atmega8**,")] #![cfg_attr(feature = "atmega328p", doc = "**atmega328p**,")] #![cfg_attr(feature = "atmega32u4", doc = "**atmega32u4**,")] +#![cfg_attr(feature = "atmega64", doc = "**atmega64**,")] #![cfg_attr(feature = "attiny85", doc = "**attiny85**,")] //! and a few things which apply to AVR microcontrollers generally. //! @@ -12,6 +13,7 @@ //! * `atmega8` //! * `atmega328p` //! * `atmega32u4` +//! * `atmega64` //! * `attiny85` #![no_std] #![feature(asm)] @@ -37,6 +39,8 @@ pub use crate::devices::atmega328p; pub use crate::devices::atmega32u4; #[cfg(feature = "atmega8")] pub use crate::devices::atmega8; +#[cfg(feature = "atmega64")] +pub use crate::devices::atmega64; #[cfg(feature = "attiny85")] pub use crate::devices::attiny85; @@ -45,6 +49,7 @@ pub use crate::devices::attiny85; feature = "atmega8", feature = "atmega328p", feature = "atmega32u4", + feature = "atmega64", feature = "attiny85", )))] compile_error!("You need to select at least one chip as a feature!"); diff --git a/vendor/atmega64.atdf b/vendor/atmega64.atdf new file mode 100644 index 0000000..4adcd93 --- /dev/null +++ b/vendor/atmega64.atdf @@ -0,0 +1,1300 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.49.0