Skip to content

Commit

Permalink
atmega-hal: Add suport for ATmega88P
Browse files Browse the repository at this point in the history
  • Loading branch information
blueberry-fan authored Jan 7, 2025
1 parent 4bf713c commit d02ab21
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ jobs:
name: atmega48p
spec: atmega48p
crate: atmega-hal
- type: mcu
name: atmega88p
spec: atmega88p
crate: atmega-hal
- type: mcu
name: atmega1284p
spec: atmega1284p
Expand Down
25 changes: 25 additions & 0 deletions avr-specs/avr-atmega88p.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"arch": "avr",
"atomic-cas": false,
"cpu": "atmega88p",
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
"eh-frame-header": false,
"exe-suffix": ".elf",
"late-link-args": {
"gcc": [
"-lgcc"
]
},
"linker": "avr-gcc",
"llvm-target": "avr-unknown-unknown",
"max-atomic-width": 8,
"no-default-libraries": false,
"pre-link-args": {
"gcc": [
"-mmcu=atmega88p"
]
},
"relocation-model": "static",
"target-c-int-width": "16",
"target-pointer-width": "16"
}
1 change: 1 addition & 0 deletions mcu/atmega-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ atmega128a = ["avr-device/atmega128a", "device-selected"]
atmega1280 = ["avr-device/atmega1280", "device-selected"]
atmega1284p = ["avr-device/atmega1284p", "device-selected"]
atmega8 = ["avr-device/atmega8", "device-selected"]
atmega88p = ["avr-device/atmega88p", "device-selected"]

critical-section-impl = ["avr-device/critical-section-impl"]

Expand Down
6 changes: 6 additions & 0 deletions mcu/atmega-hal/src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub mod channel {
feature = "atmega128a",
feature = "atmega1284p",
feature = "atmega8",
feature = "atmega88p"
),
feature = "enable-extra-adc",
))]
Expand All @@ -118,6 +119,7 @@ pub mod channel {
feature = "atmega128a",
feature = "atmega1284p",
feature = "atmega8",
feature = "atmega88p"
),
feature = "enable-extra-adc",
))]
Expand All @@ -135,6 +137,7 @@ pub mod channel {
feature = "atmega1284p",
feature = "atmega8",
feature = "atmega164pa",
feature = "atmega88p"
))]
pub struct Vbg;
#[cfg(any(
Expand All @@ -150,13 +153,15 @@ pub mod channel {
feature = "atmega1284p",
feature = "atmega8",
feature = "atmega164pa",
feature = "atmega88p"
))]
pub struct Gnd;
#[cfg(any(
feature = "atmega328p",
feature = "atmega328pb",
feature = "atmega32u4",
feature = "atmega48p",
feature = "atmega88p"
))]
pub struct Temperature;
}
Expand All @@ -166,6 +171,7 @@ pub mod channel {
feature = "atmega328p",
feature = "atmega328pb",
feature = "atmega48p",
feature = "atmega88p"
))]
avr_hal_generic::impl_adc! {
hal: crate::Atmega,
Expand Down
11 changes: 11 additions & 0 deletions mcu/atmega-hal/src/eeprom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ avr_hal_generic::impl_eeprom_atmega! {
},
}

#[cfg(feature = "atmega88p")]
avr_hal_generic::impl_eeprom_atmega! {
hal: crate::Atmega,
peripheral: crate::pac::EEPROM,
capacity: 512,
addr_width: u16,
set_address: |peripheral, address| {
peripheral.eear.write(|w| w.bits(address));
},
}

#[cfg(any(feature = "atmega168", feature = "atmega164pa"))]
avr_hal_generic::impl_eeprom_atmega! {
hal: crate::Atmega,
Expand Down
6 changes: 4 additions & 2 deletions mcu/atmega-hal/src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ avr_hal_generic::impl_i2c_twi! {
feature = "atmega328p",
feature = "atmega168",
feature = "atmega48p",
feature = "atmega8"
feature = "atmega8",
feature = "atmega88p"
))]
pub type I2c<CLOCK> = avr_hal_generic::i2c::I2c<
crate::Atmega,
Expand All @@ -82,7 +83,8 @@ pub type I2c<CLOCK> = avr_hal_generic::i2c::I2c<
feature = "atmega328p",
feature = "atmega168",
feature = "atmega48p",
feature = "atmega8"
feature = "atmega8",
feature = "atmega88p"
))]
avr_hal_generic::impl_i2c_twi! {
hal: crate::Atmega,
Expand Down
13 changes: 12 additions & 1 deletion mcu/atmega-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#![cfg_attr(feature = "atmega1280", doc = "**ATmega1280**.")]
#![cfg_attr(feature = "atmega1284p", doc = "**ATmega1284P**.")]
#![cfg_attr(feature = "atmega8", doc = "**ATmega8**.")]
#![cfg_attr(feature = "atmega88p", doc = "**ATmega88P**.")]
//! This means that only items which are available for this MCU are visible. If you are using
//! a different chip, try building the documentation locally with:
//!
Expand Down Expand Up @@ -44,6 +45,7 @@ compile_error!(
* atmega2560
* atmega1284p
* atmega8
* atmega88p
"
);

Expand Down Expand Up @@ -95,6 +97,10 @@ pub use avr_device::atmega48p as pac;
///
#[cfg(feature = "atmega8")]
pub use avr_device::atmega8 as pac;
/// Reexport of `atmega88p` from `avr-device`
///
#[cfg(feature = "atmega88p")]
pub use avr_device::atmega88p as pac;

/// See [`avr_device::entry`](https://docs.rs/avr-device/latest/avr_device/attr.entry.html).
#[cfg(feature = "rt")]
Expand Down Expand Up @@ -147,7 +153,12 @@ pub use eeprom::Eeprom;

pub struct Atmega;

#[cfg(any(feature = "atmega48p", feature = "atmega168", feature = "atmega328p"))]
#[cfg(any(
feature = "atmega48p",
feature = "atmega88p",
feature = "atmega168",
feature = "atmega328p"
))]
#[macro_export]
macro_rules! pins {
($p:expr) => {
Expand Down
7 changes: 6 additions & 1 deletion mcu/atmega-hal/src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
pub use avr_hal_generic::port::{mode, PinMode, PinOps};

#[cfg(any(feature = "atmega48p", feature = "atmega168", feature = "atmega328p"))]
#[cfg(any(
feature = "atmega48p",
feature = "atmega88p",
feature = "atmega168",
feature = "atmega328p"
))]
avr_hal_generic::impl_port_traditional! {
enum Ports {
B: crate::pac::PORTB = [0, 1, 2, 3, 4, 5, 6, 7],
Expand Down
3 changes: 3 additions & 0 deletions mcu/atmega-hal/src/simple_pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::port::*;

#[cfg(any(
feature = "atmega48p",
feature = "atmega88p",
feature = "atmega168",
feature = "atmega328p",
feature = "atmega328pb"
Expand Down Expand Up @@ -58,6 +59,7 @@ avr_hal_generic::impl_simple_pwm! {

#[cfg(any(
feature = "atmega48p",
feature = "atmega88p",
feature = "atmega168",
feature = "atmega328p",
feature = "atmega328pb"
Expand Down Expand Up @@ -115,6 +117,7 @@ avr_hal_generic::impl_simple_pwm! {

#[cfg(any(
feature = "atmega48p",
feature = "atmega88p",
feature = "atmega168",
feature = "atmega328p",
feature = "atmega328pb"
Expand Down
6 changes: 4 additions & 2 deletions mcu/atmega-hal/src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ avr_hal_generic::impl_spi! {
feature = "atmega168",
feature = "atmega328p",
feature = "atmega48p",
feature = "atmega8"
feature = "atmega8",
feature = "atmega88p"
))]
pub type Spi = avr_hal_generic::spi::Spi<
crate::Atmega,
Expand All @@ -79,7 +80,8 @@ pub type Spi = avr_hal_generic::spi::Spi<
feature = "atmega168",
feature = "atmega328p",
feature = "atmega48p",
feature = "atmega8"
feature = "atmega8",
feature = "atmega88p"
))]
avr_hal_generic::impl_spi! {
hal: crate::Atmega,
Expand Down
2 changes: 2 additions & 0 deletions mcu/atmega-hal/src/usart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub type UsartReader<USART, RX, TX, CLOCK> =
avr_hal_generic::usart::UsartReader<crate::Atmega, USART, RX, TX, CLOCK>;

#[cfg(any(
feature = "atmega88p",
feature = "atmega168",
feature = "atmega328p",
feature = "atmega328pb",
Expand All @@ -54,6 +55,7 @@ pub type Usart0<CLOCK> = Usart<
CLOCK,
>;
#[cfg(any(
feature = "atmega88p",
feature = "atmega168",
feature = "atmega328p",
feature = "atmega328pb",
Expand Down

0 comments on commit d02ab21

Please sign in to comment.