Skip to content

Commit 2906134

Browse files
committed
Add basic support for ATmega64
Pull in the ATDF file from Microchip and add all the necessary plumbing around the code-base to make it compile. Not tested against real hardware and no device-specific patches are included yet. Signed-off-by: Rahix <rahix@rahix.de>
1 parent 78a9588 commit 2906134

File tree

7 files changed

+1331
-1
lines changed

7 files changed

+1331
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ atmega1280 = []
1010
atmega8 = []
1111
atmega328p = []
1212
atmega32u4 = []
13+
atmega64 = []
1314
attiny85 = []
1415
rt = ["avr-device-macros"]
1516

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
all: deps chips
22

3-
CHIPS := atmega1280 atmega8 atmega328p atmega32u4 attiny85
3+
CHIPS := atmega1280 atmega8 atmega328p atmega32u4 atmega64 attiny85
44

55
PATCHES := $(foreach chip, $(CHIPS), $(wildcard patch/$(chip).yaml))
66
DEPS := $(foreach patch, $(PATCHES), $(patsubst patch/%.yaml, .deps/%.d, $(patch)))

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Via the feature you can select which chip you want the register specifications f
3535
* `atmega8`
3636
* `atmega328p`
3737
* `atmega32u4`
38+
* `atmega64`
3839
* `attiny85`
3940

4041
## Internals

patch/atmega64.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
_include:
2+
- "common/ac.yaml"
3+
- "common/spi.yaml"
4+
- "common/usart.yaml"

src/devices/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,25 @@ impl atmega8::Peripherals {
7979
}
8080
}
8181

82+
/// [ATmega64](https://www.microchip.com/wwwproducts/en/ATmega64)
83+
#[cfg(feature = "atmega64")]
84+
pub mod atmega64;
85+
86+
#[cfg(feature = "atmega64")]
87+
impl atmega64::Peripherals {
88+
/// Returns all the peripherals *once*
89+
#[inline]
90+
pub fn take() -> Option<Self> {
91+
crate::interrupt::free(|_| {
92+
if unsafe { DEVICE_PERIPHERALS } {
93+
None
94+
} else {
95+
Some(unsafe { atmega64::Peripherals::steal() })
96+
}
97+
})
98+
}
99+
}
100+
82101
/// [ATtiny85](https://www.microchip.com/wwwproducts/en/ATtiny85)
83102
#[cfg(feature = "attiny85")]
84103
pub mod attiny85;

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![cfg_attr(feature = "atmega8", doc = "**atmega8**,")]
44
#![cfg_attr(feature = "atmega328p", doc = "**atmega328p**,")]
55
#![cfg_attr(feature = "atmega32u4", doc = "**atmega32u4**,")]
6+
#![cfg_attr(feature = "atmega64", doc = "**atmega64**,")]
67
#![cfg_attr(feature = "attiny85", doc = "**attiny85**,")]
78
//! and a few things which apply to AVR microcontrollers generally.
89
//!
@@ -12,6 +13,7 @@
1213
//! * `atmega8`
1314
//! * `atmega328p`
1415
//! * `atmega32u4`
16+
//! * `atmega64`
1517
//! * `attiny85`
1618
#![no_std]
1719
#![feature(asm)]
@@ -37,6 +39,8 @@ pub use crate::devices::atmega328p;
3739
pub use crate::devices::atmega32u4;
3840
#[cfg(feature = "atmega8")]
3941
pub use crate::devices::atmega8;
42+
#[cfg(feature = "atmega64")]
43+
pub use crate::devices::atmega64;
4044
#[cfg(feature = "attiny85")]
4145
pub use crate::devices::attiny85;
4246

@@ -45,6 +49,7 @@ pub use crate::devices::attiny85;
4549
feature = "atmega8",
4650
feature = "atmega328p",
4751
feature = "atmega32u4",
52+
feature = "atmega64",
4853
feature = "attiny85",
4954
)))]
5055
compile_error!("You need to select at least one chip as a feature!");

vendor/atmega64.atdf

Lines changed: 1300 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)