1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
pub use avr_hal_generic::eeprom::{EepromOps, OutOfBoundsError};

pub type Eeprom = avr_hal_generic::eeprom::Eeprom<crate::Atmega, crate::pac::EEPROM>;

///////////////////////////////////////////////////////////
#[cfg(feature = "atmega48p")]
avr_hal_generic::impl_eeprom_atmega! {
    hal: crate::Atmega,
    peripheral: crate::pac::EEPROM,
    capacity: 256,
    addr_width: u8,
    set_address: |peripheral, address| {
        peripheral.eearl.write(|w| w.bits(address));
    },
}

#[cfg(any(feature = "atmega168", feature = "atmega164pa"))]
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 = "atmega328pb",
    feature = "atmega328p",
    feature = "atmega32u4"
))]
avr_hal_generic::impl_eeprom_atmega! {
    hal: crate::Atmega,
    peripheral: crate::pac::EEPROM,
    capacity: 1024,
    addr_width: u16,
    set_address: |peripheral, address| {
        peripheral.eear.write(|w| w.bits(address));
    },
}

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

#[cfg(any(feature = "atmega8"))]
avr_hal_generic::impl_eeprom_atmega_old! {
    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 = "atmega32a"))]
avr_hal_generic::impl_eeprom_atmega_old! {
    hal: crate::Atmega,
    peripheral: crate::pac::EEPROM,
    capacity: 1024,
    addr_width: u16,
    set_address: |peripheral, address| {
        peripheral.eear.write(|w| w.bits(address));
    },
}

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