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 @@ -62,8 +62,10 @@ attiny404 = ["device-selected"]
attiny412 = ["device-selected"]
attiny414 = ["device-selected"]
attiny416 = ["device-selected"]
attiny417 = ["device-selected"]
attiny44a = ["device-selected"]
attiny816 = ["device-selected"]
attiny817 = ["device-selected"]
attiny828 = ["device-selected"]
attiny84 = ["device-selected"]
attiny841 = ["device-selected"]
Expand All @@ -72,6 +74,8 @@ attiny85 = ["device-selected"]
attiny861 = ["device-selected"]
attiny88 = ["device-selected"]
attiny1614 = ["device-selected"]
attiny1617 = ["device-selected"]
attiny3217 = ["device-selected"]
avr64du32 = ["device-selected"]
avr64du28 = ["device-selected"]
rt = ["avr-device-macros"]
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
all: deps chips

CHIPS := at90usb1286 atmega1280 atmega1284p atmega128a atmega128rfa1 atmega16 atmega164pa atmega168 atmega16u2 atmega2560 atmega8 atmega8u2 atmega324pa atmega328p atmega328pb atmega32a atmega32u2 atmega32u4 atmega3208 atmega3209 atmega4808 atmega4809 atmega48p atmega64 atmega644 atmega88p attiny13a attiny202 attiny212 attiny214 attiny2313 attiny2313a attiny26 attiny402 attiny404 attiny412 attiny414 attiny416 attiny44a attiny84 attiny85 attiny88 attiny816 attiny828 attiny841 attiny84a attiny861 attiny167 attiny1614 avr64du32 avr64du28

CHIPS := at90usb1286 atmega1280 atmega1284p atmega128a atmega128rfa1 atmega16 atmega164pa atmega168 atmega16u2 atmega2560 atmega8 atmega8u2 atmega324pa atmega328p atmega328pb atmega32a atmega32u2 atmega32u4 atmega3208 atmega3209 atmega4808 atmega4809 atmega48p atmega64 atmega644 atmega88p attiny13a attiny202 attiny212 attiny214 attiny2313 attiny2313a attiny26 attiny402 attiny404 attiny412 attiny414 attiny416 attiny417 attiny44a attiny84 attiny85 attiny88 attiny816 attiny817 attiny828 attiny841 attiny84a attiny861 attiny167 attiny1614 attiny1617 attiny3217 avr64du32 avr64du28
RUSTUP_TOOLCHAIN ?= nightly

PATCHES := $(foreach chip, $(CHIPS), $(wildcard patch/$(chip).yaml))
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ Via the feature you can select which chip you want the register specifications f
| `atmega324pa` | | | | `attiny412` |
| `atmega328p` | | | | `attiny414` |
| `atmega328pb` | | | | `attiny416` |
| `atmega32a` | | | | `attiny44a` |
| `atmega1280` | | | | `attiny84` |
| `atmega1284p` | | | | `attiny85` |
| `atmega128a` | | | | `attiny88` |
| `atmega128rfa1` | | | | `attiny816` |
| `atmega2560` | | | | `attiny828` |
| `atmega164pa` | | | | `attiny841` |
| `atmega32a` | | | | `attiny417` |
| `atmega1280` | | | | `attiny44a` |
| `atmega1284p` | | | | `attiny84` |
| `atmega128a` | | | | `attiny85` |
| `atmega128rfa1` | | | | `attiny88` |
| `atmega2560` | | | | `attiny816` |
| `atmega164pa` | | | | `attiny817` |
| | | | | `attiny828` |
| | | | | `attiny841` |
| | | | | `attiny84a` |
| | | | | `attiny861` |
| | | | | `attiny1614` |
| | | | | `attiny1617` |
| | | | | `attiny3217` |
| | | | | `attiny2313` |
| | | | | `attiny2313a` |

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
9 changes: 7 additions & 2 deletions patch/common/attiny-xmega/1-series.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# 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"]
115 changes: 115 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,107 @@ 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?": {}

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

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"]
16 changes: 16 additions & 0 deletions src/devices/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ pub mod attiny167;
#[cfg(feature = "attiny1614")]
pub mod attiny1614;

/// [ATtiny1617](https://www.microchip.com/wwwproducts/en/ATtiny1617)
#[cfg(feature = "attiny1617")]
pub mod attiny1617;

/// [ATtiny3217](https://www.microchip.com/wwwproducts/en/ATtiny3217)
#[cfg(feature = "attiny3217")]
pub mod attiny3217;

/// [ATtiny202](https://www.microchip.com/wwwproducts/en/ATtiny202)
#[cfg(feature = "attiny202")]
pub mod attiny202;
Expand Down Expand Up @@ -163,6 +171,10 @@ pub mod attiny414;
#[cfg(feature = "attiny416")]
pub mod attiny416;

/// [ATtiny417](https://www.microchip.com/wwwproducts/en/ATtiny417)
#[cfg(feature = "attiny417")]
pub mod attiny417;

/// [ATtiny44a](https://www.microchip.com/en-us/product/ATtiny44a)
#[cfg(feature = "attiny44a")]
pub mod attiny44a;
Expand All @@ -171,6 +183,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;
Expand Down
21 changes: 20 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! This crate contains register definitions for

#![cfg_attr(feature = "at90usb1286", doc = "**at90usb1286**,")]
#![cfg_attr(feature = "atmega1280", doc = "**atmega1280**,")]
#![cfg_attr(feature = "atmega1284p", doc = "**atmega1284p**,")]
Expand Down Expand Up @@ -29,6 +28,8 @@
#![cfg_attr(feature = "attiny13a", doc = "**attiny13a**,")]
#![cfg_attr(feature = "attiny167", doc = "**attiny167**,")]
#![cfg_attr(feature = "attiny1614", doc = "**attiny1614**,")]
#![cfg_attr(feature = "attiny1617", doc = "**attiny1617**,")]
#![cfg_attr(feature = "attiny3217", doc = "**attiny3217**,")]
#![cfg_attr(feature = "attiny202", doc = "**attiny202**,")]
#![cfg_attr(feature = "attiny212", doc = "**attiny212**,")]
#![cfg_attr(feature = "attiny214", doc = "**attiny214**,")]
Expand All @@ -40,8 +41,10 @@
#![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 = "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 @@ -88,6 +91,8 @@
//! `attiny13a`,
//! `attiny167`,
//! `attiny1614`,
//! `attiny1617`,
//! `attiny3217`,
//! `attiny202`,
//! `attiny212`,
//! `attiny214`,
Expand All @@ -99,8 +104,10 @@
//! `attiny412`,
//! `attiny414`,
//! `attiny416`,
//! `attiny417`,
//! `attiny44a`,
//! `attiny816`,
//! `attiny817`,
//! `attiny828`,
//! `attiny84`,
//! `attiny841`,
Expand Down Expand Up @@ -261,6 +268,8 @@ compile_error!(
* attiny13a
* attiny167
* attiny1614
* attiny1617
* attiny3217
* attiny202
* attiny212
* attiny214
Expand All @@ -271,8 +280,10 @@ compile_error!(
* attiny412
* attiny414
* attiny416
* attiny417
* attiny44a
* attiny816
* attiny817
* attiny828
* attiny84
* attiny841
Expand Down Expand Up @@ -344,6 +355,10 @@ pub use crate::devices::atmega8u2;
pub use crate::devices::attiny13a;
#[cfg(feature = "attiny1614")]
pub use crate::devices::attiny1614;
#[cfg(feature = "attiny1617")]
pub use crate::devices::attiny1617;
#[cfg(feature = "attiny3217")]
pub use crate::devices::attiny3217;
#[cfg(feature = "attiny167")]
pub use crate::devices::attiny167;
#[cfg(feature = "attiny202")]
Expand All @@ -368,10 +383,14 @@ 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 = "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
Loading