Skip to content

Commit

Permalink
Add basic support for ATmega64
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rahix committed Jun 16, 2020
1 parent 78a9588 commit 2906134
Show file tree
Hide file tree
Showing 7 changed files with 1,331 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ atmega1280 = []
atmega8 = []
atmega328p = []
atmega32u4 = []
atmega64 = []
attiny85 = []
rt = ["avr-device-macros"]

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 := atmega1280 atmega8 atmega328p atmega32u4 attiny85
CHIPS := atmega1280 atmega8 atmega328p atmega32u4 atmega64 attiny85

PATCHES := $(foreach chip, $(CHIPS), $(wildcard patch/$(chip).yaml))
DEPS := $(foreach patch, $(PATCHES), $(patsubst patch/%.yaml, .deps/%.d, $(patch)))
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Via the feature you can select which chip you want the register specifications f
* `atmega8`
* `atmega328p`
* `atmega32u4`
* `atmega64`
* `attiny85`

## Internals
Expand Down
4 changes: 4 additions & 0 deletions patch/atmega64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_include:
- "common/ac.yaml"
- "common/spi.yaml"
- "common/usart.yaml"
19 changes: 19 additions & 0 deletions src/devices/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,25 @@ impl atmega8::Peripherals {
}
}

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

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

/// [ATtiny85](https://www.microchip.com/wwwproducts/en/ATtiny85)
#[cfg(feature = "attiny85")]
pub mod attiny85;
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![cfg_attr(feature = "atmega8", doc = "**atmega8**,")]
#![cfg_attr(feature = "atmega328p", doc = "**atmega328p**,")]
#![cfg_attr(feature = "atmega32u4", doc = "**atmega32u4**,")]
#![cfg_attr(feature = "atmega64", doc = "**atmega64**,")]
#![cfg_attr(feature = "attiny85", doc = "**attiny85**,")]
//! and a few things which apply to AVR microcontrollers generally.
//!
Expand All @@ -12,6 +13,7 @@
//! * `atmega8`
//! * `atmega328p`
//! * `atmega32u4`
//! * `atmega64`
//! * `attiny85`
#![no_std]
#![feature(asm)]
Expand All @@ -37,6 +39,8 @@ pub use crate::devices::atmega328p;
pub use crate::devices::atmega32u4;
#[cfg(feature = "atmega8")]
pub use crate::devices::atmega8;
#[cfg(feature = "atmega64")]
pub use crate::devices::atmega64;
#[cfg(feature = "attiny85")]
pub use crate::devices::attiny85;

Expand All @@ -45,6 +49,7 @@ pub use crate::devices::attiny85;
feature = "atmega8",
feature = "atmega328p",
feature = "atmega32u4",
feature = "atmega64",
feature = "attiny85",
)))]
compile_error!("You need to select at least one chip as a feature!");
1,300 changes: 1,300 additions & 0 deletions vendor/atmega64.atdf

Large diffs are not rendered by default.

0 comments on commit 2906134

Please sign in to comment.