From 90075ce574eee6881db2fdde12afa66256d441e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Thor=C3=A9n?= <6556005+kallemooo@users.noreply.github.com> Date: Sat, 8 Aug 2020 14:19:10 +0200 Subject: [PATCH] Add basic support for ATmega168 --- Cargo.toml | 1 + Makefile | 2 +- README.md | 1 + patch/atmega168.yaml | 9 + src/devices/mod.rs | 19 + src/lib.rs | 5 + vendor/atmega168.atdf | 1163 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1199 insertions(+), 1 deletion(-) create mode 100644 patch/atmega168.yaml create mode 100644 vendor/atmega168.atdf diff --git a/Cargo.toml b/Cargo.toml index eb18bc9..ddb939e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ include = [ [features] atmega1280 = [] +atmega168 = [] atmega2560 = [] atmega8 = [] atmega328p = [] diff --git a/Makefile b/Makefile index fc64ddf..cfc34c4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: deps chips -CHIPS := atmega1280 atmega2560 atmega8 atmega328p atmega32u4 atmega64 attiny85 attiny88 +CHIPS := atmega1280 atmega168 atmega2560 atmega8 atmega328p atmega32u4 atmega64 attiny85 attiny88 RUSTUP_TOOLCHAIN ?= nightly diff --git a/README.md b/README.md index 7d6cba7..8b810d2 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` +* `atmega168` * `atmega2560` * `atmega8` * `atmega328p` diff --git a/patch/atmega168.yaml b/patch/atmega168.yaml new file mode 100644 index 0000000..5dca314 --- /dev/null +++ b/patch/atmega168.yaml @@ -0,0 +1,9 @@ +_include: + - "common/ac.yaml" + - "common/adc.yaml" + - "common/spi.yaml" + - "common/twi.yaml" + - "common/usart.yaml" + - "common/wdt.yaml" + + - "timer/atmega328p.yaml" diff --git a/src/devices/mod.rs b/src/devices/mod.rs index 4408629..c69e0d2 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -22,6 +22,25 @@ impl atmega1280::Peripherals { } } +/// [ATmega168](https://www.microchip.com/wwwproducts/en/ATmega168) +#[cfg(feature = "atmega168")] +pub mod atmega168; + +#[cfg(feature = "atmega168")] +impl atmega168::Peripherals { + /// Returns all the peripherals *once* + #[inline] + pub fn take() -> Option { + crate::interrupt::free(|_| { + if unsafe { DEVICE_PERIPHERALS } { + None + } else { + Some(unsafe { atmega168::Peripherals::steal() }) + } + }) + } +} + /// [ATmega2560](https://www.microchip.com/wwwproducts/en/ATmega2560) #[cfg(feature = "atmega2560")] pub mod atmega2560; diff --git a/src/lib.rs b/src/lib.rs index e28a825..7eecb24 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 = "atmega168", doc = "**atmega168**,")] #![cfg_attr(feature = "atmega2560", doc = "**atmega2560**,")] #![cfg_attr(feature = "atmega8", doc = "**atmega8**,")] #![cfg_attr(feature = "atmega328p", doc = "**atmega328p**,")] @@ -12,6 +13,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` +//! * `atmega168` //! * `atmega2560` //! * `atmega8` //! * `atmega328p` @@ -69,6 +71,8 @@ mod devices; #[cfg(feature = "atmega1280")] pub use crate::devices::atmega1280; +#[cfg(feature = "atmega168")] +pub use crate::devices::atmega168; #[cfg(feature = "atmega2560")] pub use crate::devices::atmega2560; #[cfg(feature = "atmega328p")] @@ -86,6 +90,7 @@ pub use crate::devices::attiny88; #[cfg(not(any( feature = "atmega1280", + feature = "atmega168", feature = "atmega2560", feature = "atmega8", feature = "atmega328p", diff --git a/vendor/atmega168.atdf b/vendor/atmega168.atdf new file mode 100644 index 0000000..52afd6e --- /dev/null +++ b/vendor/atmega168.atdf @@ -0,0 +1,1163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.49.0