diff --git a/Cargo.toml b/Cargo.toml index ebac426..39f456a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,6 +53,7 @@ attiny402 = ["device-selected"] attiny404 = ["device-selected"] attiny44a = ["device-selected"] attiny816 = ["device-selected"] +attiny817 = ["device-selected"] attiny828 = ["device-selected"] attiny84 = ["device-selected"] attiny841 = ["device-selected"] diff --git a/Makefile b/Makefile index 5c76340..b6ca814 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ all: deps chips -CHIPS := at90usb1286 atmega1280 atmega1284p atmega128a atmega128rfa1 atmega164pa atmega168 atmega2560 atmega8 atmega8u2 atmega324pa atmega328p atmega328pb atmega32a atmega32u4 atmega4808 atmega4809 atmega48p atmega64 atmega644 atmega88p attiny13a attiny202 attiny2313 attiny2313a attiny402 attiny404 attiny44a attiny84 attiny85 attiny88 attiny816 attiny828 attiny841 attiny861 attiny167 attiny1614 - +CHIPS := at90usb1286 atmega1280 atmega1284p atmega128a atmega128rfa1 atmega164pa atmega168 atmega2560 atmega8 atmega8u2 atmega324pa atmega328p atmega328pb atmega32a atmega32u4 atmega4808 atmega4809 atmega48p atmega64 atmega644 atmega88p attiny13a attiny202 attiny2313 attiny2313a attiny402 attiny404 attiny44a attiny84 attiny85 attiny88 attiny816 attiny817 attiny828 attiny841 attiny861 attiny167 attiny1614 RUSTUP_TOOLCHAIN ?= nightly PATCHES := $(foreach chip, $(CHIPS), $(wildcard patch/$(chip).yaml)) @@ -35,7 +34,7 @@ svd/%.svd.patched: svd/%.svd .deps/%.d src/devices/%/mod.full.rs: svd/%.svd.patched @mkdir -p $(@D) @echo -e "\tSVD2RUST\t$*" - @cd $(@D); svd2rust --generic_mod --make_mod --target none -i $(realpath $<) + @cd $(@D); svd2rust --generic_mod --make_mod --target avr -i $(realpath $<) @mv $(@D)/mod.rs $@ @mv $(@D)/generic.rs $(@D)/../../generic.rs diff --git a/README.md b/README.md index 6d73e49..aa6bd26 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,13 @@ Via the feature you can select which chip you want the register specifications f | `atmega328p` | | | | `attiny85` | | `atmega328pb` | | | | `attiny88` | | `atmega32a` | | | | `attiny816` | -| `atmega1280` | | | | `attiny828` | -| `atmega1284p` | | | | `attiny841` | -| `atmega128a` | | | | `attiny861` | -| `atmega128rfa1` | | | | `attiny1614` | -| `atmega2560` | | | | `attiny2313` | -| `atmega164pa` | | | | `attiny2313a` | +| `atmega1280` | | | | `attiny817` | +| `atmega1284p` | | | | `attiny828` | +| `atmega128a` | | | | `attiny841` | +| `atmega128rfa1` | | | | `attiny861` | +| `atmega2560` | | | | `attiny1614` | +| `atmega164pa` | | | | `attiny2313` | +| | | | | `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/attiny817.yaml b/patch/attiny817.yaml new file mode 100644 index 0000000..0cd9e5a --- /dev/null +++ b/patch/attiny817.yaml @@ -0,0 +1,107 @@ +_svd: ../svd/attiny817.svd + +CRCSCAN: + CTRLB: + SRC: + _replace_enum: + FLASH: [0, "CRC on entire flash"] + BOOTAPP: [1, "CRC on boot and appl section of flash"] + BOOT: [2, "CRC on boot section of flash"] + MODE: + _replace_enum: + PRIORITY: [0, "Priority to flash"] + +NVMCTRL: + CTRLA: + CMD: + _replace_enum: + NONE: [0, "No command"] + WP: [1, "Write page"] + ER: [2, "Erase page"] + ERWP: [3, "Erase and write page"] + PBC: [4, "Page buffer clear"] + CHER: [5, "Chip erase"] + EEER: [6, "EEPROM erase"] + WFU: [7, "Write fuse (PDI only)"] + +SLPCTRL: + CTRLA: + SMODE: + _replace_enum: + IDLE: [0, "Idle mode"] + STANDBY: [1, "Standby Mode"] + PDOWN: [2, "Power-down Mode"] + +TCD0: + EVCTRL?: + CFG: + _replace_enum: + NEITHER: [0, "Neither Filter nor Asynchronous Event is enabled"] + FILTERON: [1, "Input Capture Noise Cancellation Filter enabled"] + ASYNCON: [2, "Asynchronous Event output qualification enabled"] + +"PORT?": + DIR: + "P*": + # Make all Pins use the same enum + _replace_enum: + Input: [0, "Input"] + Output: [1, "Output"] + + # make PINxCTRL a rust slice + _array: + "PIN?CTRL": {} + +"USART?": + STATUS: + _modify: + # The RXSIF bit is actually writable to clear the flag + RXSIF: + access: read-write + # The WFB bit is write-only + WFB: + access: write-only + +"SPI?": + CTRLA: + DORD: + # Make it an enum + _replace_enum: + MsbFirst: [0, "Most significant byte first"] + LsbFirst: [1, "Least significant byte first"] + +CCL: + _cluster: + "LUT%s": + description: "CCL LUT configuration cluster" + "LUT?CTRLA": {} + "LUT?CTRLB": {} + "LUT?CTRLC": {} + "TRUTH?": {} + + # turn all SEQCTRL-registers into slices + _array: + "SEQCTRL?": {} + +CPUINT: + CTRLA: + IVSEL: + _replace_enum: + AFTERBOOT: [0, "Interrupt vectors are placed after the BOOT section of the Flash"] + INBOOT: [1, "Interrupt vectors are placed at the start of the BOOT section of the Flash"] + CVT: + _replace_enum: + NORMAL: [0, "Compact Vector Table function is disabled"] + COMPACT: [1, "Compact Vector Table function is enabled"] + LVL0RR: + _replace_enum: + FIXED: [0, "Priority is fixed for priority level 0 interrupt requests: The lowest interrupt vector address has the highest priority."] + ROUNDROBIN: [1, "The round robin priority scheme is enabled for priority level 0 interrupt requests"] + +EVSYS: + # make ASYNCCHx, SYNCCHx, ASYNCUSERx and SYNCUSERx a rust slice + _array: + "ASYNCCH*": {} + "SYNCCH*": {} + "ASYNCUSER*": {} + "SYNCUSER*": {} diff --git a/src/ccp.rs b/src/ccp.rs new file mode 100644 index 0000000..74c638c --- /dev/null +++ b/src/ccp.rs @@ -0,0 +1,41 @@ +//! Configuration change protected (CCP) register definitions + +pub use crate::generic::ProtectedWritable; + +#[cfg(feature = "attiny817")] +pub mod attiny817 { + use crate::generic::{UnlockRegister, Protected}; + + // Mark the CPU.CCP register with the UnlockRegister trait so that it can be used to unlock the below defined registers + impl UnlockRegister for crate::attiny817::cpu::ccp::CCP_SPEC { const PTR: *mut u8 = 0x34 as *mut u8; } + + // Configuration change protected registers in NVMCTRL + impl Protected for crate::attiny817::nvmctrl::ctrla::CTRLA_SPEC { const MAGIC: u8 = 0x9D; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + impl Protected for crate::attiny817::nvmctrl::ctrlb::CTRLB_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + + // Configuration change protected registers in CLKCTRL + impl Protected for crate::attiny817::clkctrl::mclkctrlb::MCLKCTRLB_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + impl Protected for crate::attiny817::clkctrl::mclklock::MCLKLOCK_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + impl Protected for crate::attiny817::clkctrl::xosc32kctrla::XOSC32KCTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + impl Protected for crate::attiny817::clkctrl::mclkctrla::MCLKCTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + impl Protected for crate::attiny817::clkctrl::osc20mctrla::OSC20MCTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + impl Protected for crate::attiny817::clkctrl::osc20mcaliba::OSC20MCALIBA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + impl Protected for crate::attiny817::clkctrl::osc20mcalibb::OSC20MCALIBB_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + impl Protected for crate::attiny817::clkctrl::osc32kctrla::OSC32KCTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + + // Configuration change protected registers in RSTCTRL + impl Protected for crate::attiny817::rstctrl::swrr::SWRR_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + + // Configuration change protected registers in CPUINT + impl Protected for crate::attiny817::cpuint::ctrla::CTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + + // Configuration change protected registers in BOD + impl Protected for crate::attiny817::bod::ctrla::CTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + + // Configuration change protected registers in WDT + impl Protected for crate::attiny817::wdt::ctrla::CTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + impl Protected for crate::attiny817::wdt::status::STATUS_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } + + // Configuration change protected registers in TCD0 + impl Protected for crate::attiny817::tcd0::faultctrl::FAULTCTRL_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; } +} diff --git a/src/devices/mod.rs b/src/devices/mod.rs index 0de1a15..4738ae3 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -123,6 +123,10 @@ pub mod attiny44a; #[cfg(feature = "attiny816")] pub mod attiny816; +/// [ATtiny817](https://www.microchip.com/wwwproducts/en/ATtiny817) +#[cfg(feature = "attiny817")] +pub mod attiny817; + /// [ATtiny828](https://www.microchip.com/wwwproducts/en/ATtiny828) #[cfg(feature = "attiny828")] pub mod attiny828; diff --git a/src/lib.rs b/src/lib.rs index 1666db8..2f52dc9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ //! This crate contains register definitions for +#![feature(asm_const)] #![cfg_attr(feature = "at90usb1286", doc = "**at90usb1286**,")] #![cfg_attr(feature = "atmega1280", doc = "**atmega1280**,")] @@ -30,6 +31,7 @@ #![cfg_attr(feature = "attiny404", doc = "**attiny404**,")] #![cfg_attr(feature = "attiny44a", doc = "**attiny44a**,")] #![cfg_attr(feature = "attiny816", doc = "**attiny816**,")] +#![cfg_attr(feature = "attiny817", doc = "**attiny817**,")] #![cfg_attr(feature = "attiny828", doc = "**attiny828**,")] #![cfg_attr(feature = "attiny84", doc = "**attiny84**,")] #![cfg_attr(feature = "attiny841", doc = "**attiny841**,")] @@ -74,6 +76,7 @@ //! `attiny404`, //! `attiny44a`, //! `attiny816`, +//! `attiny817`, //! `attiny828`, //! `attiny84`, //! `attiny841`, @@ -231,6 +234,7 @@ compile_error!( * attiny402 * attiny44a * attiny816 + * attiny817 * attiny828 * attiny84 * attiny841 @@ -303,6 +307,8 @@ pub use crate::devices::attiny404; pub use crate::devices::attiny44a; #[cfg(feature = "attiny816")] pub use crate::devices::attiny816; +#[cfg(feature = "attiny817")] +pub use crate::devices::attiny817; #[cfg(feature = "attiny828")] pub use crate::devices::attiny828; #[cfg(feature = "attiny84")] @@ -315,3 +321,9 @@ pub use crate::devices::attiny85; pub use crate::devices::attiny861; #[cfg(feature = "attiny88")] pub use crate::devices::attiny88; + +#[allow(non_camel_case_types, unused_attributes, unreachable_patterns)] +pub mod ccp; + +#[cfg(feature = "attiny817")] +pub use crate::ccp::attiny817 as attiny817_ccp; diff --git a/vendor/attiny817.atdf b/vendor/attiny817.atdf new file mode 100644 index 0000000..bc69de7 --- /dev/null +++ b/vendor/attiny817.atdf @@ -0,0 +1,5730 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +