Skip to content

Commit 0a61ba4

Browse files
committed
More Attiny817 support
1 parent eba39bd commit 0a61ba4

File tree

4 files changed

+147
-1
lines changed

4 files changed

+147
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ svd/%.svd.patched: svd/%.svd .deps/%.d
3434
src/devices/%/mod.full.rs: svd/%.svd.patched
3535
@mkdir -p $(@D)
3636
@echo -e "\tSVD2RUST\t$*"
37-
@cd $(@D); svd2rust --generic_mod --make_mod --target none -i $(realpath $<)
37+
@cd $(@D); svd2rust --generic_mod --make_mod --target avr -i $(realpath $<)
3838
@mv $(@D)/mod.rs $@
3939
@mv $(@D)/generic.rs $(@D)/../../generic.rs
4040

patch/attiny817.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,99 @@
11
_svd: ../svd/attiny817.svd
2+
3+
CRCSCAN:
4+
CTRLB:
5+
SRC:
6+
_replace_enum:
7+
FLASH: [0, "CRC on entire flash"]
8+
BOOTAPP: [1, "CRC on boot and appl section of flash"]
9+
BOOT: [2, "CRC on boot section of flash"]
10+
MODE:
11+
_replace_enum:
12+
PRIORITY: [0, "Priority to flash"]
13+
14+
NVMCTRL:
15+
CTRLA:
16+
CMD:
17+
_replace_enum:
18+
NONE: [0, "No command"]
19+
WP: [1, "Write page"]
20+
ER: [2, "Erase page"]
21+
ERWP: [3, "Erase and write page"]
22+
PBC: [4, "Page buffer clear"]
23+
CHER: [5, "Chip erase"]
24+
EEER: [6, "EEPROM erase"]
25+
WFU: [7, "Write fuse (PDI only)"]
26+
27+
SLPCTRL:
28+
CTRLA:
29+
SMODE:
30+
_replace_enum:
31+
IDLE: [0, "Idle mode"]
32+
STANDBY: [1, "Standby Mode"]
33+
PDOWN: [2, "Power-down Mode"]
34+
35+
TCD0:
36+
EVCTRL?:
37+
CFG:
38+
_replace_enum:
39+
NEITHER: [0, "Neither Filter nor Asynchronous Event is enabled"]
40+
FILTERON: [1, "Input Capture Noise Cancellation Filter enabled"]
41+
ASYNCON: [2, "Asynchronous Event output qualification enabled"]
42+
43+
"PORT?":
44+
DIR:
45+
"P*":
46+
# Make all Pins use the same enum
47+
_replace_enum:
48+
Input: [0, "Input"]
49+
Output: [1, "Output"]
50+
51+
# make PINxCTRL a rust slice
52+
_array:
53+
"PIN?CTRL": {}
54+
55+
"USART?":
56+
STATUS:
57+
_modify:
58+
# The RXSIF bit is actually writable to clear the flag
59+
RXSIF:
60+
access: read-write
61+
# The WFB bit is write-only
62+
WFB:
63+
access: write-only
64+
65+
"SPI?":
66+
CTRLA:
67+
DORD:
68+
# Make it an enum
69+
_replace_enum:
70+
MsbFirst: [0, "Most significant byte first"]
71+
LsbFirst: [1, "Least significant byte first"]
72+
73+
CCL:
74+
_cluster:
75+
"LUT%s":
76+
description: "CCL LUT configuration cluster"
77+
"LUT?CTRLA": {}
78+
"LUT?CTRLB": {}
79+
"LUT?CTRLC": {}
80+
"TRUTH?": {}
81+
82+
# turn all SEQCTRL-registers into slices
83+
_array:
84+
"SEQCTRL?": {}
85+
86+
CPUINT:
87+
CTRLA:
88+
IVSEL:
89+
_replace_enum:
90+
AFTERBOOT: [0, "Interrupt vectors are placed after the BOOT section of the Flash"]
91+
INBOOT: [1, "Interrupt vectors are placed at the start of the BOOT section of the Flash"]
92+
CVT:
93+
_replace_enum:
94+
NORMAL: [0, "Compact Vector Table function is disabled"]
95+
COMPACT: [1, "Compact Vector Table function is enabled"]
96+
LVL0RR:
97+
_replace_enum:
98+
FIXED: [0, "Priority is fixed for priority level 0 interrupt requests: The lowest interrupt vector address has the highest priority."]
99+
ROUNDROBIN: [1, "The round robin priority scheme is enabled for priority level 0 interrupt requests"]

src/ccp.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//! Configuration change protected (CCP) register definitions
2+
3+
pub use crate::generic::ProtectedWritable;
4+
5+
#[cfg(feature = "attiny817")]
6+
pub mod attiny817 {
7+
use crate::generic::{UnlockRegister, Protected};
8+
9+
// Mark the CPU.CCP register with the UnlockRegister trait so that it can be used to unlock the below defined registers
10+
impl UnlockRegister for crate::attiny817::cpu::ccp::CCP_SPEC { const PTR: *mut u8 = 0x34 as *mut u8; }
11+
12+
// Configuration change protected registers in NVMCTRL
13+
impl Protected for crate::attiny817::nvmctrl::ctrla::CTRLA_SPEC { const MAGIC: u8 = 0x9D; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
14+
impl Protected for crate::attiny817::nvmctrl::ctrlb::CTRLB_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
15+
16+
// Configuration change protected registers in CLKCTRL
17+
impl Protected for crate::attiny817::clkctrl::mclkctrlb::MCLKCTRLB_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
18+
impl Protected for crate::attiny817::clkctrl::mclklock::MCLKLOCK_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
19+
impl Protected for crate::attiny817::clkctrl::xosc32kctrla::XOSC32KCTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
20+
impl Protected for crate::attiny817::clkctrl::mclkctrla::MCLKCTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
21+
impl Protected for crate::attiny817::clkctrl::osc20mctrla::OSC20MCTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
22+
impl Protected for crate::attiny817::clkctrl::osc20mcaliba::OSC20MCALIBA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
23+
impl Protected for crate::attiny817::clkctrl::osc20mcalibb::OSC20MCALIBB_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
24+
impl Protected for crate::attiny817::clkctrl::osc32kctrla::OSC32KCTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
25+
26+
// Configuration change protected registers in RSTCTRL
27+
impl Protected for crate::attiny817::rstctrl::swrr::SWRR_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
28+
29+
// Configuration change protected registers in CPUINT
30+
impl Protected for crate::attiny817::cpuint::ctrla::CTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
31+
32+
// Configuration change protected registers in BOD
33+
impl Protected for crate::attiny817::bod::ctrla::CTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
34+
35+
// Configuration change protected registers in WDT
36+
impl Protected for crate::attiny817::wdt::ctrla::CTRLA_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
37+
impl Protected for crate::attiny817::wdt::status::STATUS_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
38+
39+
// Configuration change protected registers in TCD0
40+
impl Protected for crate::attiny817::tcd0::faultctrl::FAULTCTRL_SPEC { const MAGIC: u8 = 0xD8; type CcpReg = crate::attiny817::cpu::ccp::CCP_SPEC; }
41+
}

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! This crate contains register definitions for
2+
#![feature(asm_const)]
23

34
#![cfg_attr(feature = "at90usb1286", doc = "**at90usb1286**,")]
45
#![cfg_attr(feature = "atmega1280", doc = "**atmega1280**,")]
@@ -320,3 +321,9 @@ pub use crate::devices::attiny85;
320321
pub use crate::devices::attiny861;
321322
#[cfg(feature = "attiny88")]
322323
pub use crate::devices::attiny88;
324+
325+
#[allow(non_camel_case_types, unused_attributes, unreachable_patterns)]
326+
pub mod ccp;
327+
328+
#[cfg(feature = "attiny817")]
329+
pub use crate::ccp::attiny817 as attiny817_ccp;

0 commit comments

Comments
 (0)