From b5cc61bc33b523247a4962576264092dc52cd7a2 Mon Sep 17 00:00:00 2001 From: Andrea Nall Date: Fri, 9 Jul 2021 14:05:50 -0500 Subject: [PATCH] Add ATtiny202 support All of the svd patches are in patch/common/attiny-0-series.yaml which should work for all of the 0-series (but may only work for ATtiny20* and ATtiny40*, but not 80* or 160* given how the datasheet is split) --- Cargo.toml | 1 + Makefile | 2 +- README.md | 1 + patch/attiny202.yaml | 4 + patch/common/attiny-0-series.yaml | 57 + src/devices/mod.rs | 19 + src/lib.rs | 5 + vendor/attiny202.atdf | 2032 +++++++++++++++++++++++++++++ 8 files changed, 2120 insertions(+), 1 deletion(-) create mode 100644 patch/attiny202.yaml create mode 100644 patch/common/attiny-0-series.yaml create mode 100644 vendor/attiny202.atdf diff --git a/Cargo.toml b/Cargo.toml index 7c63963..1743d43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ atmega48p = ["device-selected"] atmega32u4 = ["device-selected"] atmega64 = ["device-selected"] atmega644 = ["device-selected"] +attiny202 = ["device-selected"] attiny84 = ["device-selected"] attiny841 = ["device-selected"] attiny85 = ["device-selected"] diff --git a/Makefile b/Makefile index ef55b54..680e452 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: deps chips -CHIPS := at90usb1286 atmega1280 atmega168 atmega2560 atmega8 atmega8u2 atmega328p atmega328pb atmega32u4 atmega4809 atmega48p atmega64 atmega644 attiny84 attiny85 attiny88 attiny841 attiny861 +CHIPS := at90usb1286 atmega1280 atmega168 atmega2560 atmega8 atmega8u2 atmega328p atmega328pb atmega32u4 atmega4809 atmega48p atmega64 atmega644 attiny202 attiny84 attiny85 attiny88 attiny841 attiny861 RUSTUP_TOOLCHAIN ?= nightly diff --git a/README.md b/README.md index 5f93ad4..a08469b 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Via the feature you can select which chip you want the register specifications f * `atmega48p` * `atmega64` * `atmega644` +* `attiny202` * `attiny84` * `attiny841` * `attiny85` diff --git a/patch/attiny202.yaml b/patch/attiny202.yaml new file mode 100644 index 0000000..b11e37c --- /dev/null +++ b/patch/attiny202.yaml @@ -0,0 +1,4 @@ +_svd: ../svd/attiny202.svd + +_include: + - common/attiny-0-series.yaml diff --git a/patch/common/attiny-0-series.yaml b/patch/common/attiny-0-series.yaml new file mode 100644 index 0000000..fba4db8 --- /dev/null +++ b/patch/common/attiny-0-series.yaml @@ -0,0 +1,57 @@ +# This is probably good for at least ATtiny202/204/402/404/406, but may not be valid for ATtiny80* and ATtiny160* + +TCB0: + CTRLB: + _modify: + # 'async' is reserved + ASYNC: + name: "TCB_ASYNC" + +# Split this in 2 for ease of use +TWI0: + SADDR: + _add: + # FIXME: Make this so we don't need 'unsafe' + ADDR: + description: "Client Address" + bitRange: "[7:1]" + access: read-write + GCE: + description: "General Call Recognition Enable Bit" + bitRange: "[0:0]" + access: read-write + +USERROW: + _modify: + "USERROW*": + description: "User Row Bytes" + _array: + "USERROW*": {} + +GPIO: + _modify: + "GPIO*": + description: "General Purpose IO Registers" + _array: + "GPIO*": {} + +SIGROW: + _modify: + "DEVICEID*": + description: "Device IO Bytes" + "SERNUM*": + description: "Serial Number Bytes" + "TEMPSENSE0": + description: "Temperature Sensor Calibration: Gain/Slope" + "TEMPSENSE1": + description: "Temperature Sensor Calibration: Offset" + _array: + "DEVICEID*" : {} + "SERNUM*" : {} + +# All FUSEs are read-only from the CPU (can only be modified with UPDI) +FUSE: + _modify: + "*": + access: read-only + diff --git a/src/devices/mod.rs b/src/devices/mod.rs index fd18ec8..a055eaa 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -250,6 +250,25 @@ impl atmega644::Peripherals { } } +/// [ATtiny202](https://www.microchip.com/wwwproducts/en/ATtiny202) +#[cfg(feature = "attiny202")] +pub mod attiny202; + +#[cfg(feature = "attiny202")] +impl attiny202::Peripherals { + /// Returns all the peripherals *once* + #[inline] + pub fn take() -> Option { + crate::interrupt::free(|_| { + if unsafe { DEVICE_PERIPHERALS } { + None + } else { + Some(unsafe { attiny202::Peripherals::steal() }) + } + }) + } +} + /// [ATtiny84](https://www.microchip.com/wwwproducts/en/ATtiny84) #[cfg(feature = "attiny84")] pub mod attiny84; diff --git a/src/lib.rs b/src/lib.rs index 1ebe90c..f695e81 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,7 @@ #![cfg_attr(feature = "atmega48p", doc = "**atmega48p**,")] #![cfg_attr(feature = "atmega64", doc = "**atmega64**,")] #![cfg_attr(feature = "atmega644", doc = "**atmega644**,")] +#![cfg_attr(feature = "attiny202", doc = "**attiny202**,")] #![cfg_attr(feature = "attiny84", doc = "**attiny84**,")] #![cfg_attr(feature = "attiny841", doc = "**attiny841**,")] #![cfg_attr(feature = "attiny85", doc = "**attiny85**,")] @@ -34,6 +35,7 @@ //! * `atmega48p` //! * `atmega64` //! * `atmega644` +//! * `attiny202` //! * `attiny84` //! * `attiny841` //! * `attiny85` @@ -102,6 +104,7 @@ compile_error!( * atmega644 * atmega8 * atmega8u2 + * attiny202 * attiny84 * attiny841 * attiny85 @@ -139,6 +142,8 @@ pub use crate::devices::atmega644; pub use crate::devices::atmega8; #[cfg(feature = "atmega8u2")] pub use crate::devices::atmega8u2; +#[cfg(feature = "attiny202")] +pub use crate::devices::attiny202; #[cfg(feature = "attiny84")] pub use crate::devices::attiny84; #[cfg(feature = "attiny841")] diff --git a/vendor/attiny202.atdf b/vendor/attiny202.atdf new file mode 100644 index 0000000..a728555 --- /dev/null +++ b/vendor/attiny202.atdf @@ -0,0 +1,2032 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.49.0