Skip to content

Commit a1a99cd

Browse files
committed
devices: add basic support for ATtiny1626
Pull in the ATDF file from Microchip and add all the necessary plumbing around the code-base to make it compile. It hasn't been tested much yet and no device specific patches are included. So far, I've tested some accesses to the PORTx register on hardware. It seems to work expect for VPORTA.DIR. VPORTA.DIR is mapped to memory address 0. This address is commonly used as NULL pointer and it looks like rust isn't able to handle accesses to that address [1]. To check that, I've created a short example programm accessing VPORTA.DIR [2] and checking the resulting binary with avr-objdump [3]. The produced binary panics as soon as I'm trying to access VPORTA.DIR [4]. By changing the code to access a different register of VPORTA like OUT, the code produces a sane binary [5]. [1] https://users.rust-lang.org/t/reading-from-physical-address-0x0/117408/2 [2] ``` #![no_std] #![no_main] use panic_halt as _; pub extern "C" fn main() -> ! { let dp = unsafe { avr_device::attiny1626::Peripherals::steal() }; dp.vporta.dir().write(|w| w.set(1 << 7)); loop {} } ``` [3] `avr-objdump -D -m tinyavr2 target/avr-none/debug/test.elf` [4] ``` 000000a0 <main>: a0: 81 e0 ldi r24, 0x01 ; 1 a2: 80 93 00 38 sts 0x3800, r24 ; 0x803800 <DEVICE_PERIPHERALS> a6: 0e 94 59 00 call 0xb2 ; 0xb2 <_ZN4core9panicking14panic_nounwind17h63d81beb9bde1088E> ``` [5] ``` 000000a0 <main>: a0: 81 e0 ldi r24, 0x01 ; 1 a2: 80 93 00 38 sts 0x3800, r24 ; 0x803800 <DEVICE_PERIPHERALS> a6: 80 e8 ldi r24, 0x80 ; 128 a8: 81 b9 out 0x01, r24 ; 1 aa: ff cf rjmp .-2 ; 0xaa <.Luint32_t_name+0x3> ``` Signed-off-by: Corvin Köhne <[email protected]>
1 parent df379aa commit a1a99cd

File tree

5 files changed

+5626
-0
lines changed

5 files changed

+5626
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ attiny85 = ["device-selected"]
7676
attiny861 = ["device-selected"]
7777
attiny88 = ["device-selected"]
7878
attiny1614 = ["device-selected"]
79+
attiny1626 = ["device-selected"]
7980
avr64du32 = ["device-selected"]
8081
avr64du28 = ["device-selected"]
8182
rt = ["avr-device-macros"]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Via the feature you can select which chip you want the register specifications f
3434
| | | | | `attiny84a` |
3535
| | | | | `attiny861` |
3636
| | | | | `attiny1614` |
37+
| | | | | `attiny1626` |
3738
| | | | | `attiny2313` |
3839
| | | | | `attiny2313a` |
3940

src/devices.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ pub mod attiny1614 {
177177
include!(concat!(env!("OUT_DIR"), "/pac/attiny1614.rs"));
178178
}
179179

180+
/// [ATtiny1626](https://www.microchip.com/wwwproducts/en/ATtiny1626)
181+
#[cfg(feature = "attiny1626")]
182+
pub mod attiny1626 {
183+
include!(concat!(env!("OUT_DIR"), "/pac/attiny1626.rs"));
184+
}
185+
180186
/// [ATtiny202](https://www.microchip.com/wwwproducts/en/ATtiny202)
181187
#[cfg(feature = "attiny202")]
182188
pub mod attiny202 {

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#![cfg_attr(feature = "attiny13a", doc = "**attiny13a**,")]
3030
#![cfg_attr(feature = "attiny167", doc = "**attiny167**,")]
3131
#![cfg_attr(feature = "attiny1614", doc = "**attiny1614**,")]
32+
#![cfg_attr(feature = "attiny1626", doc = "**attiny1626**,")]
3233
#![cfg_attr(feature = "attiny202", doc = "**attiny202**,")]
3334
#![cfg_attr(feature = "attiny212", doc = "**attiny212**,")]
3435
#![cfg_attr(feature = "attiny214", doc = "**attiny214**,")]
@@ -88,6 +89,7 @@
8889
//! `attiny13a`,
8990
//! `attiny167`,
9091
//! `attiny1614`,
92+
//! `attiny1626`,
9193
//! `attiny202`,
9294
//! `attiny212`,
9395
//! `attiny214`,
@@ -262,6 +264,7 @@ compile_error!(
262264
* attiny13a
263265
* attiny167
264266
* attiny1614
267+
* attiny1626
265268
* attiny202
266269
* attiny212
267270
* attiny214
@@ -347,6 +350,8 @@ pub use crate::devices::atmega8u2;
347350
pub use crate::devices::attiny13a;
348351
#[cfg(feature = "attiny1614")]
349352
pub use crate::devices::attiny1614;
353+
#[cfg(feature = "attiny1626")]
354+
pub use crate::devices::attiny1626;
350355
#[cfg(feature = "attiny167")]
351356
pub use crate::devices::attiny167;
352357
#[cfg(feature = "attiny202")]

0 commit comments

Comments
 (0)