Skip to content

Add Attiny417/817/1617/3217 support #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ attiny404 = ["device-selected"]
attiny412 = ["device-selected"]
attiny414 = ["device-selected"]
attiny416 = ["device-selected"]
attiny417 = ["device-selected"]
attiny44a = ["device-selected"]
attiny461a = ["device-selected"]
attiny804 = ["device-selected"]
attiny816 = ["device-selected"]
attiny817 = ["device-selected"]
attiny828 = ["device-selected"]
attiny84 = ["device-selected"]
attiny841 = ["device-selected"]
Expand All @@ -86,7 +88,9 @@ attiny88 = ["device-selected"]
attiny1604 = ["device-selected"]
attiny1606 = ["device-selected"]
attiny1614 = ["device-selected"]
attiny1617 = ["device-selected"]
attiny1626 = ["device-selected"]
attiny3217 = ["device-selected"]
avr64du32 = ["device-selected"]
avr64du28 = ["device-selected"]
avr128db28 = ["device-selected"]
Expand Down
5 changes: 5 additions & 0 deletions patch/attiny1617.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_svd: ../svd/attiny1617.svd

_include:
- common/attiny-xmega/common.yaml
- common/attiny-xmega/1-series.yaml
5 changes: 5 additions & 0 deletions patch/attiny3217.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_svd: ../svd/attiny3217.svd

_include:
- common/attiny-xmega/common.yaml
- common/attiny-xmega/1-series.yaml
5 changes: 5 additions & 0 deletions patch/attiny417.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_svd: ../svd/attiny417.svd

_include:
- common/attiny-xmega/common.yaml
- common/attiny-xmega/1-series.yaml
5 changes: 5 additions & 0 deletions patch/attiny817.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_svd: ../svd/attiny817.svd

_include:
- common/attiny-xmega/common.yaml
- common/attiny-xmega/1-series.yaml
13 changes: 12 additions & 1 deletion patch/common/attiny-xmega/0-series.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Nothing needed beyond common config
# This is probably good for at least ATtiny202/204/402/404/406, but may not be valid for ATtiny80* and ATtiny160*

{}
EVSYS:
# make ASYNCCHx, SYNCCHx, ASYNCUSERx and SYNCUSERx a rust slice
_modify:
"ASYNCUSER*":
description: "Users of asynchronous channels"
"SYNCUSER*":
description: "Users of synchronous channels"
_array:
"ASYNCCH*": {}
"SYNCCH*": {}
"ASYNCUSER*": {}
"SYNCUSER*": {}
22 changes: 20 additions & 2 deletions patch/common/attiny-xmega/1-series.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
# Nothing needed beyond common config
# This is probably good for at least ATtiny212/214/412/414/416, but may not be valid for ATtiny81* and ATtiny161*

{}
TCD*:
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"]

EVSYS:
# make ASYNCCHx, SYNCCHx, ASYNCUSERx and SYNCUSERx a rust slice
_modify:
"ASYNCUSER*":
description: "Users of asynchronous channels"
"SYNCUSER*":
description: "Users of synchronous channels"
_array:
"ASYNCCH*": {}
"SYNCCH*": {}
"ASYNCUSER*": {}
"SYNCUSER*": {}
102 changes: 102 additions & 0 deletions patch/common/attiny-xmega/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ PORT[A-Z]:
IN:
name: INPUT

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": {}

SPI*:
CTRLA:
PRESC:
Expand All @@ -74,3 +85,94 @@ SPI*:
[2, "Peripheral clock / 64 if CLK2X == 0 else Peripheral clock / 32"]
CLK_PER_128_64:
[3, "Peripheral clock / 128 if CLK2X == 0 else Peripheral clock / 64"]

DORD:
# Make it an enum
_replace_enum:
MsbFirst: [0, "Most significant byte first"]
LsbFirst: [1, "Least significant byte first"]

"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

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"]

CCL:
_cluster:
"LUT%s":
description: "CCL LUT configuration cluster"
"LUT?CTRLA": {}
"LUT?CTRLB": {}
"LUT?CTRLC": {}
"TRUTH?": {}

# turn all SEQCTRL-registers into slices
_array:
"SEQCTRL?": {}

TCB*:
_add:
# FIXME: no idea how to add a write constraint with range [0x0, 0xFF] to
# added registers to prevent bits() from being marked as unsafe
CCMPL:
description: Lower Compare or Capture in 8-bit PWM mode
addressOffset: 0x0C
access: read-write
size: 8
CCMPH:
description: Upper Compare or Capture in 8-bit PWM mode
addressOffset: 0x0D
access: read-write
size: 8

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"]
24 changes: 24 additions & 0 deletions src/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ pub mod attiny1626 {
include!(concat!(env!("OUT_DIR"), "/pac/attiny1626.rs"));
}

/// [ATtiny1617](https://www.microchip.com/wwwproducts/en/ATtiny1617)
#[cfg(feature = "attiny1617")]
pub mod attiny1617 {
include!(concat!(env!("OUT_DIR"), "/pac/attiny1617.rs"));
}

/// [ATtiny3217](https://www.microchip.com/wwwproducts/en/ATtiny3217)
#[cfg(feature = "attiny3217")]
pub mod attiny3217 {
include!(concat!(env!("OUT_DIR"), "/pac/attiny3217.rs"));
}

/// [ATtiny202](https://www.microchip.com/wwwproducts/en/ATtiny202)
#[cfg(feature = "attiny202")]
pub mod attiny202 {
Expand Down Expand Up @@ -291,6 +303,12 @@ pub mod attiny416 {
include!(concat!(env!("OUT_DIR"), "/pac/attiny416.rs"));
}

/// [ATtiny417](https://www.microchip.com/wwwproducts/en/ATtiny417)
#[cfg(feature = "attiny417")]
pub mod attiny417 {
include!(concat!(env!("OUT_DIR"), "/pac/attiny417.rs"));
}

/// [ATtiny44a](https://www.microchip.com/en-us/product/ATtiny44a)
#[cfg(feature = "attiny44a")]
pub mod attiny44a {
Expand All @@ -315,6 +333,12 @@ pub mod attiny816 {
include!(concat!(env!("OUT_DIR"), "/pac/attiny816.rs"));
}

/// [ATtiny817](https://www.microchip.com/wwwproducts/en/ATtiny817)
#[cfg(feature = "attiny817")]
pub mod attiny817 {
include!(concat!(env!("OUT_DIR"), "/pac/attiny817.rs"));
}

/// [ATtiny828](https://www.microchip.com/wwwproducts/en/ATtiny828)
#[cfg(feature = "attiny828")]
pub mod attiny828 {
Expand Down
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
#![cfg_attr(feature = "attiny1604", doc = "**attiny1604**,")]
#![cfg_attr(feature = "attiny1606", doc = "**attiny1606**,")]
#![cfg_attr(feature = "attiny1614", doc = "**attiny1614**,")]
#![cfg_attr(feature = "attiny1617", doc = "**attiny1617**,")]
#![cfg_attr(feature = "attiny1626", doc = "**attiny1626**,")]
#![cfg_attr(feature = "attiny3217", doc = "**attiny3217**,")]
#![cfg_attr(feature = "attiny202", doc = "**attiny202**,")]
#![cfg_attr(feature = "attiny204", doc = "**attiny204**,")]
#![cfg_attr(feature = "attiny212", doc = "**attiny212**,")]
Expand All @@ -47,10 +49,12 @@
#![cfg_attr(feature = "attiny412", doc = "**attiny412**,")]
#![cfg_attr(feature = "attiny414", doc = "**attiny414**,")]
#![cfg_attr(feature = "attiny416", doc = "**attiny416**,")]
#![cfg_attr(feature = "attiny417", doc = "**attiny417**,")]
#![cfg_attr(feature = "attiny44a", doc = "**attiny44a**,")]
#![cfg_attr(feature = "attiny461a", doc = "**attiny461a**,")]
#![cfg_attr(feature = "attiny804", doc = "**attiny804**,")]
#![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**,")]
Expand Down Expand Up @@ -103,7 +107,9 @@
//! `attiny167`,
//! `attiny1604`,
//! `attiny1614`,
//! `attiny1617`,
//! `attiny1626`,
//! `attiny3217`,
//! `attiny202`,
//! `attiny204`,
//! `attiny212`,
Expand All @@ -117,10 +123,12 @@
//! `attiny412`,
//! `attiny414`,
//! `attiny416`,
//! `attiny417`,
//! `attiny44a`,
//! `attiny461a`,
//! `attiny804`,
//! `attiny816`,
//! `attiny817`,
//! `attiny828`,
//! `attiny84`,
//! `attiny841`,
Expand Down Expand Up @@ -286,7 +294,9 @@ compile_error!(
* attiny1604
* attiny1606
* attiny1614
* attiny1617
* attiny1626
* attiny3217
* attiny202
* attiny204
* attiny212
Expand All @@ -300,10 +310,12 @@ compile_error!(
* attiny412
* attiny414
* attiny416
* attiny417
* attiny44a
* attiny461a
* attiny804
* attiny816
* attiny817
* attiny828
* attiny84
* attiny841
Expand Down Expand Up @@ -389,8 +401,12 @@ pub use crate::devices::attiny1604;
pub use crate::devices::attiny1606;
#[cfg(feature = "attiny1614")]
pub use crate::devices::attiny1614;
#[cfg(feature = "attiny1617")]
pub use crate::devices::attiny1617;
#[cfg(feature = "attiny1626")]
pub use crate::devices::attiny1626;
#[cfg(feature = "attiny3217")]
pub use crate::devices::attiny3217;
#[cfg(feature = "attiny167")]
pub use crate::devices::attiny167;
#[cfg(feature = "attiny202")]
Expand Down Expand Up @@ -419,6 +435,8 @@ pub use crate::devices::attiny412;
pub use crate::devices::attiny414;
#[cfg(feature = "attiny416")]
pub use crate::devices::attiny416;
#[cfg(feature = "attiny417")]
pub use crate::devices::attiny417;
#[cfg(feature = "attiny44a")]
pub use crate::devices::attiny44a;
#[cfg(feature = "attiny461a")]
Expand All @@ -427,6 +445,8 @@ pub use crate::devices::attiny461a;
pub use crate::devices::attiny804;
#[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")]
Expand Down
Loading