Skip to content
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

Add support for attiny13a #100

Merged
merged 1 commit into from
Jun 23, 2022
Merged
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ atmega48p = ["device-selected"]
atmega32u4 = ["device-selected"]
atmega64 = ["device-selected"]
atmega644 = ["device-selected"]
attiny13a = ["device-selected"]
attiny167 = ["device-selected"]
attiny202 = ["device-selected"]
attiny2313 = ["device-selected"]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
all: deps chips

CHIPS := at90usb1286 atmega1280 atmega1284p atmega128rfa1 atmega168 atmega2560 atmega8 atmega8u2 atmega328p atmega328pb atmega32u4 atmega4809 atmega48p atmega64 atmega644 attiny202 attiny2313 attiny2313a attiny84 attiny85 attiny88 attiny816 attiny841 attiny861 attiny167 attiny1614
CHIPS := at90usb1286 atmega1280 atmega1284p atmega128rfa1 atmega168 atmega2560 atmega8 atmega8u2 atmega328p atmega328pb atmega32u4 atmega4809 atmega48p atmega64 atmega644 attiny13a attiny202 attiny2313 attiny2313a attiny84 attiny85 attiny88 attiny816 attiny841 attiny861 attiny167 attiny1614

RUSTUP_TOOLCHAIN ?= nightly

Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ Via the feature you can select which chip you want the register specifications f

| ATmega | ATmega USB | ATmega 0,1 Series | AT90 | ATtiny |
|:---------------:|:------------:|:-----------------:|:-------------:|:-------------:|
| `atmega8` | `atmega8u2` | `atmega4809` | `at90usb1286` | `attiny167` |
| `atmega48p` | `atmega32u4` | | | `attiny202` |
| `atmega64` | | | | `attiny84` |
| `atmega644` | | | | `attiny85` |
| `atmega168` | | | | `attiny88` |
| `atmega328p` | | | | `attiny816` |
| `atmega328pb` | | | | `attiny841` |
| `atmega1280` | | | | `attiny861` |
| `atmega1284p` | | | | `attiny1614` |
| `atmega128rfa1` | | | | `attiny2313` |
| `atmega2560` | | | | `attiny2313a` |
| `atmega8` | `atmega8u2` | `atmega4809` | `at90usb1286` | `attiny13a` |
| `atmega48p` | `atmega32u4` | | | `attiny167` |
| `atmega64` | | | | `attiny202` |
| `atmega644` | | | | `attiny84` |
| `atmega168` | | | | `attiny85` |
| `atmega328p` | | | | `attiny88` |
| `atmega328pb` | | | | `attiny816` |
| `atmega1280` | | | | `attiny841` |
| `atmega1284p` | | | | `attiny861` |
| `atmega128rfa1` | | | | `attiny1614`|
| `atmega2560` | | | | `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.
Expand Down
80 changes: 80 additions & 0 deletions patch/attiny13a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
_svd: ../svd/attiny13a.svd

_include:
- "common/ac.yaml"
- "common/eeprom.yaml"
- "common/wdt.yaml"

- "common/tiny/exint.yaml"

- "timer/attiny13a.yaml"

AC:
_modify:
DIDR0:
description: "Digital Input Disable Register 0"
ADC:
_modify:
ADCSRA:
description: "ADC Control and Status Register A"
ADCSRA:
ADPS:
_replace_enum:
PRESCALER_2: [1, "Prescaler Value 2"]
PRESCALER_4: [2, "Prescaler Value 4"]
PRESCALER_8: [3, "Prescaler Value 8"]
PRESCALER_16: [4, "Prescaler Value 16"]
PRESCALER_32: [5, "Prescaler Value 32"]
PRESCALER_64: [6, "Prescaler Value 64"]
PRESCALER_128: [7, "Prescaler Value 128"]
ADCSRB:
ADTS:
_replace_enum:
FREE: [0, "Free Running mode"]
AC: [1, "Analog Comparator"]
INT0: [2, "External Interrupt Request 0"]
TC0_CMA: [3, "Timer/Counter0 Compare Match A"]
TC0_OVF: [4, "Timer/Counter0 Overflow"]
TC0_CMB: [5, "Timer/Counter0 Compare Match B"]
PCIR: [6, "Pin Change Interrupt Request"]
ADMUX:
_modify:
MUX:
_write_constraint: enum
MUX:
_replace_enum:
ADC0: [0, "Single-ended Input ADC0"]
ADC1: [1, "Single-ended Input ADC1"]
ADC2: [2, "Single-ended Input ADC2"]
ADC3: [3, "Single-ended Input ADC3"]
REFS0:
_replace_enum:
VCC: [0, "Vcc used as Voltage Reference"]
INTERNAL: [1, "Internal Voltage Reference of 1.1V "]
CPU:
CLKPR:
CLKPS:
_replace_enum:
PRESCALER_1: [0, "Prescaler Value 1"]
PRESCALER_2: [1, "Prescaler Value 2"]
PRESCALER_4: [2, "Prescaler Value 4"]
PRESCALER_8: [3, "Prescaler Value 8"]
PRESCALER_16: [4, "Prescaler Value 16"]
PRESCALER_32: [5, "Prescaler Value 32"]
PRESCALER_64: [6, "Prescaler Value 64"]
PRESCALER_128: [7, "Prescaler Value 128"]
PRESCALER_256: [8, "Prescaler Value 256"]
MCUCR:
_delete:
ISC?:
_add:
BODS:
description: "BOD Sleep (available on some devices)"
bitOffset: 7
bitWidth: 1
access: read-write
BODSE:
description: "BOD Sleep Enable (available on some devices)"
bitOffset: 2
bitWidth: 1
access: read-write
10 changes: 10 additions & 0 deletions patch/timer/attiny13a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This intermediate file is needed because peripheral-level includes are not
# supported in top-level files.

_modify:
TC0:
description: "Timer/Counter0, 8-bit, PWM"

TC0:
_include:
- "dev/8bit-tiny8n-tc0.yaml"
19 changes: 19 additions & 0 deletions src/devices/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,25 @@ impl atmega644::Peripherals {
}
}

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

#[cfg(feature = "attiny13a")]
impl attiny13a::Peripherals {
/// Returns all the peripherals *once*
#[inline]
pub fn take() -> Option<Self> {
crate::interrupt::free(|_| {
if unsafe { DEVICE_PERIPHERALS } {
None
} else {
Some(unsafe { attiny13a::Peripherals::steal() })
}
})
}
}

/// [ATtiny167](https://www.microchip.com/wwwproducts/en/ATtiny167)
#[cfg(feature = "attiny167")]
pub mod attiny167;
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#![cfg_attr(feature = "atmega48p", doc = "**atmega48p**,")]
#![cfg_attr(feature = "atmega64", doc = "**atmega64**,")]
#![cfg_attr(feature = "atmega644", doc = "**atmega644**,")]
#![cfg_attr(feature = "attiny13a", doc = "**attiny13a**,")]
#![cfg_attr(feature = "attiny167", doc = "**attiny167**,")]
#![cfg_attr(feature = "attiny1614", doc = "**attiny1614**,")]
#![cfg_attr(feature = "attiny202", doc = "**attiny202**,")]
Expand Down Expand Up @@ -44,6 +45,7 @@
//! * `atmega48p`
//! * `atmega64`
//! * `atmega644`
//! * `attiny13a`
//! * `attiny167`
//! * `attiny1614`
//! * `attiny202`
Expand Down Expand Up @@ -121,6 +123,7 @@ compile_error!(
* atmega644
* atmega8
* atmega8u2
* attiny13a
* attiny167
* attiny1614
* attiny202
Expand Down Expand Up @@ -168,6 +171,8 @@ pub use crate::devices::atmega644;
pub use crate::devices::atmega8;
#[cfg(feature = "atmega8u2")]
pub use crate::devices::atmega8u2;
#[cfg(feature = "attiny13a")]
pub use crate::devices::attiny13a;
#[cfg(feature = "attiny1614")]
pub use crate::devices::attiny1614;
#[cfg(feature = "attiny167")]
Expand Down
Loading