From ed20a8b8a2eea64b1025ea3bf023ab8771c8e331 Mon Sep 17 00:00:00 2001 From: Tronje Krabbe Date: Fri, 3 Jun 2022 11:32:07 +0200 Subject: [PATCH] Add support for ATmega164pa Adds the ATDF file provided from Microchip, and makes changes analog to 290613454fbdc5e4ac98e53deccaf74dafc88963. This has been tested on real hardware. Signed-off-by: Tronje Krabbe Signed-off-by: Oskar Munz --- Cargo.toml | 1 + Makefile | 2 +- README.md | 2 +- patch/atmega164pa.yaml | 7 + src/devices/mod.rs | 19 + src/lib.rs | 5 + vendor/atmega164pa.atdf | 1408 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 1442 insertions(+), 2 deletions(-) create mode 100644 patch/atmega164pa.yaml create mode 100644 vendor/atmega164pa.atdf diff --git a/Cargo.toml b/Cargo.toml index b9d0f0df8fc852df913f08940b78de56b763eaed..b9155e4a18b957abe8c5cd20f62a9de62e676c24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ at90usb1286 = ["device-selected"] atmega1280 = ["device-selected"] atmega1284p = ["device-selected"] atmega128rfa1 = ["device-selected"] +atmega164pa = ["device-selected"] atmega168 = ["device-selected"] atmega2560 = ["device-selected"] atmega8 = ["device-selected"] diff --git a/Makefile b/Makefile index f964a2ca926c9743310514c19d1445b2c3425070..08479bd462bede4d57dc76d1b8cfc1f181eb13b3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: deps chips -CHIPS := at90usb1286 atmega1280 atmega1284p atmega128rfa1 atmega168 atmega2560 atmega8 atmega8u2 atmega328p atmega328pb atmega32u4 atmega4809 atmega48p atmega64 atmega644 attiny13a attiny202 attiny2313 attiny2313a attiny84 attiny85 attiny88 attiny816 attiny841 attiny861 attiny167 attiny1614 +CHIPS := at90usb1286 atmega1280 atmega1284p atmega128rfa1 atmega164pa atmega168 atmega2560 atmega8 atmega8u2 atmega328p atmega328pb atmega32u4 atmega4809 atmega48p atmega64 atmega644 attiny13a attiny202 attiny2313 attiny2313a attiny84 attiny85 attiny88 attiny816 attiny841 attiny861 attiny167 attiny1614 RUSTUP_TOOLCHAIN ?= nightly diff --git a/README.md b/README.md index 64fc036a7a1e8a9098714a6641e09d27fe0c6db8..9ba4b324d3a2133860d8f7f0fb39932dd478a240 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Via the feature you can select which chip you want the register specifications f | `atmega1284p` | | | | `attiny861` | | `atmega128rfa1` | | | | `attiny1614`| | `atmega2560` | | | | `attiny2313`| -| | | | | `attiny2313a`| +| `atmega164pa` | | | | `attiny2313a`| ## Build Instructions The version on `crates.io` is pre-built. The following is only necessary when trying to build this crate from source. diff --git a/patch/atmega164pa.yaml b/patch/atmega164pa.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2f565e8fe4dc3dd65dca7df39e78bca8c9f018d0 --- /dev/null +++ b/patch/atmega164pa.yaml @@ -0,0 +1,7 @@ +_svd: ../svd/atmega164pa.svd + +_include: + - "common/adc.yaml" + - "common/twi.yaml" + - "common/usart.yaml" + - "common/wdt.yaml" diff --git a/src/devices/mod.rs b/src/devices/mod.rs index 646d9b0846687b635bb17a3008e1cbb7b774af37..2f9c352dd1567da01e6e890ee358e61d3c5476e2 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -79,6 +79,25 @@ impl atmega128rfa1::Peripherals { } } +/// [ATmega164PA](https://www.microchip.com/en-us/product/ATmega164PA) +#[cfg(feature = "atmega164pa")] +pub mod atmega164pa; + +#[cfg(feature = "atmega164pa")] +impl atmega164pa::Peripherals { + /// Returns all the peripherals *once* + #[inline] + pub fn take() -> Option { + crate::interrupt::free(|_| { + if unsafe { DEVICE_PERIPHERALS } { + None + } else { + Some(unsafe { atmega164pa::Peripherals::steal() }) + } + }) + } +} + /// [ATmega168](https://www.microchip.com/wwwproducts/en/ATmega168) #[cfg(feature = "atmega168")] pub mod atmega168; diff --git a/src/lib.rs b/src/lib.rs index 7aaf85dcb0e41047e5baea19d4a0a97f063fde24..64d472a1caa9878cdb539e650eb0ef758f211ca1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ #![cfg_attr(feature = "atmega1280", doc = "**atmega1280**,")] #![cfg_attr(feature = "atmega1284p", doc = "**atmega1284p**,")] #![cfg_attr(feature = "atmega128rfa1", doc = "**atmega128rfa1**,")] +#![cfg_attr(feature = "atmega164pa", doc = "**atmega164pa**,")] #![cfg_attr(feature = "atmega168", doc = "**atmega168**,")] #![cfg_attr(feature = "atmega2560", doc = "**atmega2560**,")] #![cfg_attr(feature = "atmega8", doc = "**atmega8**,")] @@ -38,6 +39,7 @@ //! * `atmega1280` //! * `atmega1284p` //! * `atmega128rfa1` +//! * `atmega164pa` //! * `atmega168` //! * `atmega2560` //! * `atmega8` @@ -116,6 +118,7 @@ compile_error!( * atmega1280 * atmega1284p * atmega128rfa1 + * atmega164pa * atmega168 * atmega2560 * atmega328p @@ -153,6 +156,8 @@ pub use crate::devices::atmega1280; pub use crate::devices::atmega1284p; #[cfg(feature = "atmega128rfa1")] pub use crate::devices::atmega128rfa1; +#[cfg(feature = "atmega164pa")] +pub use crate::devices::atmega164pa; #[cfg(feature = "atmega168")] pub use crate::devices::atmega168; #[cfg(feature = "atmega2560")] diff --git a/vendor/atmega164pa.atdf b/vendor/atmega164pa.atdf new file mode 100644 index 0000000000000000000000000000000000000000..deab72f589405815218198f8f8627cd79f112f96 --- /dev/null +++ b/vendor/atmega164pa.atdf @@ -0,0 +1,1408 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +