From 405f89d7b1aaf200bec9a46c7aa5eaf9b7e93f6c Mon Sep 17 00:00:00 2001 From: Erhune Date: Sat, 12 Mar 2022 01:11:31 +0900 Subject: [PATCH] Add support for ATmega1284p --- Cargo.toml | 1 + Makefile | 2 +- README.md | 8 +- patch/atmega1284p.yaml | 33 + patch/timer/atmega1284p.yaml | 18 + src/devices/mod.rs | 19 + src/lib.rs | 5 + vendor/atmega1284p.atdf | 1405 ++++++++++++++++++++++++++++++++++ 8 files changed, 1486 insertions(+), 5 deletions(-) create mode 100644 patch/atmega1284p.yaml create mode 100644 patch/timer/atmega1284p.yaml create mode 100644 vendor/atmega1284p.atdf diff --git a/Cargo.toml b/Cargo.toml index a728961cd40422f4007b9bb6bb7764e455fe1838..32b862260a2120fca7e7d6e1d319fd92527dbd6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ all-features = true device-selected = [] at90usb1286 = ["device-selected"] atmega1280 = ["device-selected"] +atmega1284p = ["device-selected"] atmega128rfa1 = ["device-selected"] atmega168 = ["device-selected"] atmega2560 = ["device-selected"] diff --git a/Makefile b/Makefile index 79a04b220767a7149e82410c5de606643d7e69da..b2f7a460775213a97a589ba92db15bc4bab28489 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: deps chips -CHIPS := at90usb1286 atmega1280 atmega128rfa1 atmega168 atmega2560 atmega8 atmega8u2 atmega328p atmega328pb atmega32u4 atmega4809 atmega48p atmega64 atmega644 attiny202 attiny2313 attiny2313a attiny84 attiny85 attiny88 attiny816 attiny841 attiny861 attiny167 attiny1614 +CHIPS := at90usb1286 atmega1280 atmega1284p atmega128rfa1 atmega168 atmega2560 atmega8 atmega8u2 atmega328p atmega328pb atmega32u4 atmega4809 atmega48p atmega64 atmega644 attiny202 attiny2313 attiny2313a attiny84 attiny85 attiny88 attiny816 attiny841 attiny861 attiny167 attiny1614 RUSTUP_TOOLCHAIN ?= nightly diff --git a/README.md b/README.md index 956d929fc3f8cb3657a8765afc53fc25d097d8df..2b0673f2e46858c8127bcb1e51e7ece7a1e4860e 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,10 @@ Via the feature you can select which chip you want the register specifications f | `atmega168` | | | | `attiny88` | | `atmega328p` | | | | `attiny816` | | `atmega328pb` | | | | `attiny841` | -| `atmega1280` | | | | `attiny861` | -| `atmega128rfa1` | | | | `attiny1614` | -| `atmega2560` | | | | `attiny2313` | -| | | | | `attiny2313a` | +| `atmega1280` | | | | `attiny861` | +| `atmega1284p` | | | | `attiny1614` | +| `atmega128rfa1` | | | | `attiny2313` | +| `atmega2560` | | | | `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/atmega1284p.yaml b/patch/atmega1284p.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fea3f1f7561253652b5783c0268a7ad1210a8b25 --- /dev/null +++ b/patch/atmega1284p.yaml @@ -0,0 +1,33 @@ +_svd: ../svd/atmega1284p.svd + +_include: + - "common/ac.yaml" + - "common/adc.yaml" + - "common/spi.yaml" + - "common/twi.yaml" + - "common/usart.yaml" + - "common/wdt.yaml" + + - "timer/atmega1284p.yaml" + +EXINT: + EIMSK: + _split: + INT: + name: INT%s + description: External Interrupt %s Request Enable + EIFR: + _split: + INTF: + name: INTF%s + description: External Interrupt Flags %s + PCICR: + _split: + PCIE: + name: PCIE%s + description: Pin Change Interrupt Enable %s + PCIFR: + _split: + PCIF: + name: PCIF%s + description: Pin Change Interrupt Flag %s diff --git a/patch/timer/atmega1284p.yaml b/patch/timer/atmega1284p.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b336d4fe019d9d90cc0ab994bee5b190a9b0f95a --- /dev/null +++ b/patch/timer/atmega1284p.yaml @@ -0,0 +1,18 @@ +# 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" + +TC2: + _include: + - "dev/8bit-async.yaml" + +TC3: + _include: + - "dev/16bit.yaml" diff --git a/src/devices/mod.rs b/src/devices/mod.rs index d812ea71798f2722dabfb6b13c951b07172bca00..ad5ad1749f2971f3cbf05bb5e98d53178385015e 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -41,6 +41,25 @@ impl atmega1280::Peripherals { } } +/// [ATmega1284P](https://www.microchip.com/en-us/product/ATmega1284P) +#[cfg(feature = "atmega1284p")] +pub mod atmega1284p; + +#[cfg(feature = "atmega1284p")] +impl atmega1284p::Peripherals { + /// Returns all the peripherals *once* + #[inline] + pub fn take() -> Option { + crate::interrupt::free(|_| { + if unsafe { DEVICE_PERIPHERALS } { + None + } else { + Some(unsafe { atmega1284p::Peripherals::steal() }) + } + }) + } +} + /// [ATmega128RFA1](https://www.microchip.com/en-us/product/ATmega128RFA1) #[cfg(feature = "atmega128rfa1")] pub mod atmega128rfa1; diff --git a/src/lib.rs b/src/lib.rs index f024878006515a5e5a99db721e5e9cea7553664e..f6fc9dee9c87d8ac5600876584510b23a568d720 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ //! This crate contains register definitions for #![cfg_attr(feature = "at90usb1286", doc = "**at90usb1286**,")] #![cfg_attr(feature = "atmega1280", doc = "**atmega1280**,")] +#![cfg_attr(feature = "atmega1284p", doc = "**atmega1284p**,")] #![cfg_attr(feature = "atmega128rfa1", doc = "**atmega128rfa1**,")] #![cfg_attr(feature = "atmega168", doc = "**atmega168**,")] #![cfg_attr(feature = "atmega2560", doc = "**atmega2560**,")] @@ -30,6 +31,7 @@ //! The following chips are available (using feature flags of the same name): //! * `at90usb1286` //! * `atmega1280` +//! * `atmega1284p` //! * `atmega128rfa1` //! * `atmega168` //! * `atmega2560` @@ -105,6 +107,7 @@ compile_error!( Please select one of the following: * atmega1280 + * atmega1284p * atmega128rfa1 * atmega168 * atmega2560 @@ -138,6 +141,8 @@ mod devices; pub use crate::devices::at90usb1286; #[cfg(feature = "atmega1280")] pub use crate::devices::atmega1280; +#[cfg(feature = "atmega1284p")] +pub use crate::devices::atmega1284p; #[cfg(feature = "atmega128rfa1")] pub use crate::devices::atmega128rfa1; #[cfg(feature = "atmega168")] diff --git a/vendor/atmega1284p.atdf b/vendor/atmega1284p.atdf new file mode 100644 index 0000000000000000000000000000000000000000..c9fc1d52fc9e919b666ba767368f0e731425fe76 --- /dev/null +++ b/vendor/atmega1284p.atdf @@ -0,0 +1,1405 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file