1#![no_std]
2
3#![cfg_attr(feature = "atmega48p", doc = "**ATmega48P**.")]
9#![cfg_attr(feature = "atmega16", doc = "**ATmega16**.")]
10#![cfg_attr(feature = "atmega164pa", doc = "**ATmega164PA**.")]
11#![cfg_attr(feature = "atmega168", doc = "**ATmega168**.")]
12#![cfg_attr(feature = "atmega328p", doc = "**ATmega328P**.")]
13#![cfg_attr(feature = "atmega328pb", doc = "**ATmega328PB**.")]
14#![cfg_attr(feature = "atmega32a", doc = "**ATmega32a**.")]
15#![cfg_attr(feature = "atmega32u4", doc = "**ATmega32U4**.")]
16#![cfg_attr(feature = "atmega2560", doc = "**ATmega2560**.")]
17#![cfg_attr(feature = "atmega128a", doc = "**ATmega128A**.")]
18#![cfg_attr(feature = "atmega1280", doc = "**ATmega1280**.")]
19#![cfg_attr(feature = "atmega1284p", doc = "**ATmega1284P**.")]
20#![cfg_attr(feature = "atmega8", doc = "**ATmega8**.")]
21#![cfg_attr(feature = "atmega88p", doc = "**ATmega88P**.")]
22#[cfg(all(
30 not(feature = "device-selected"),
31 not(feature = "disable-device-selection-error")
32))]
33compile_error!(
34 "This crate requires you to specify your target chip as a feature.
35
36 Please select one of the following
37
38 * atmega48p
39 * atmega16
40 * atmega164pa
41 * atmega168
42 * atmega328p
43 * atmega328pb
44 * atmega32u4
45 * atmega128a
46 * atmega1280
47 * atmega2560
48 * atmega1284p
49 * atmega8
50 * atmega88p
51 "
52);
53
54#[cfg(feature = "atmega1280")]
57pub use avr_device::atmega1280 as pac;
58#[cfg(feature = "atmega1284p")]
61pub use avr_device::atmega1284p as pac;
62#[cfg(feature = "atmega128a")]
65pub use avr_device::atmega128a as pac;
66#[cfg(feature = "atmega16")]
69pub use avr_device::atmega16 as pac;
70#[cfg(feature = "atmega164pa")]
73pub use avr_device::atmega164pa as pac;
74#[cfg(feature = "atmega168")]
77pub use avr_device::atmega168 as pac;
78#[cfg(feature = "atmega2560")]
81pub use avr_device::atmega2560 as pac;
82#[cfg(feature = "atmega328p")]
85pub use avr_device::atmega328p as pac;
86#[cfg(feature = "atmega328pb")]
89pub use avr_device::atmega328pb as pac;
90#[cfg(feature = "atmega32a")]
93pub use avr_device::atmega32a as pac;
94#[cfg(feature = "atmega32u4")]
97pub use avr_device::atmega32u4 as pac;
98#[cfg(feature = "atmega48p")]
101pub use avr_device::atmega48p as pac;
102#[cfg(feature = "atmega8")]
105pub use avr_device::atmega8 as pac;
106#[cfg(feature = "atmega88p")]
109pub use avr_device::atmega88p as pac;
110
111#[cfg(feature = "rt")]
113pub use avr_device::entry;
114
115pub use avr_device;
120
121#[cfg(feature = "device-selected")]
122pub use pac::Peripherals;
123
124pub use avr_hal_generic::clock;
125pub use avr_hal_generic::delay;
126pub use avr_hal_generic::prelude;
127
128#[cfg(feature = "device-selected")]
129pub mod adc;
130#[cfg(feature = "device-selected")]
131pub use adc::Adc;
132
133#[cfg(feature = "device-selected")]
134pub mod i2c;
135#[cfg(feature = "device-selected")]
136pub use i2c::I2c;
137
138#[cfg(feature = "device-selected")]
139pub mod spi;
140#[cfg(feature = "device-selected")]
141pub use spi::Spi;
142
143#[cfg(feature = "device-selected")]
144pub mod port;
145#[cfg(feature = "device-selected")]
146pub use port::Pins;
147
148#[cfg(feature = "device-selected")]
149pub mod simple_pwm;
150
151#[cfg(feature = "device-selected")]
152pub mod usart;
153#[cfg(feature = "device-selected")]
154pub use usart::Usart;
155
156#[cfg(feature = "device-selected")]
157pub mod wdt;
158#[cfg(feature = "device-selected")]
159pub use wdt::Wdt;
160
161#[cfg(feature = "device-selected")]
162pub mod eeprom;
163#[cfg(feature = "device-selected")]
164pub use eeprom::Eeprom;
165
166pub struct Atmega;
167
168#[cfg(any(
169 feature = "atmega48p",
170 feature = "atmega88p",
171 feature = "atmega168",
172 feature = "atmega328p"
173))]
174#[macro_export]
175macro_rules! pins {
176 ($p:expr) => {
177 $crate::Pins::new($p.PORTB, $p.PORTC, $p.PORTD)
178 };
179}
180#[cfg(any(feature = "atmega16", feature = "atmega164pa"))]
181#[macro_export]
182macro_rules! pins {
183 ($p:expr) => {
184 $crate::Pins::new($p.PORTA, $p.PORTB, $p.PORTC, $p.PORTD)
185 };
186}
187#[cfg(feature = "atmega328pb")]
188#[macro_export]
189macro_rules! pins {
190 ($p:expr) => {
191 $crate::Pins::new($p.PORTB, $p.PORTC, $p.PORTD, $p.PORTE)
192 };
193}
194#[cfg(feature = "atmega32u4")]
195#[macro_export]
196macro_rules! pins {
197 ($p:expr) => {
198 $crate::Pins::new($p.PORTB, $p.PORTC, $p.PORTD, $p.PORTE, $p.PORTF)
199 };
200}
201
202#[cfg(any(feature = "atmega128a"))]
203#[macro_export]
204macro_rules! pins {
205 ($p:expr) => {
206 $crate::Pins::new(
207 $p.PORTA, $p.PORTB, $p.PORTC, $p.PORTD, $p.PORTE, $p.PORTF, $p.PORTG,
208 )
209 };
210}
211
212#[cfg(any(feature = "atmega1280", feature = "atmega2560"))]
213#[macro_export]
214macro_rules! pins {
215 ($p:expr) => {
216 $crate::Pins::new(
217 $p.PORTA, $p.PORTB, $p.PORTC, $p.PORTD, $p.PORTE, $p.PORTF, $p.PORTG, $p.PORTH,
218 $p.PORTJ, $p.PORTK, $p.PORTL,
219 )
220 };
221}
222
223#[cfg(any(feature = "atmega1284p", feature = "atmega32a"))]
224#[macro_export]
225macro_rules! pins {
226 ($p:expr) => {
227 $crate::Pins::new($p.PORTA, $p.PORTB, $p.PORTC, $p.PORTD)
228 };
229}
230
231#[cfg(any(feature = "atmega8"))]
232#[macro_export]
233macro_rules! pins {
234 ($p:expr) => {
235 $crate::Pins::new($p.PORTB, $p.PORTC, $p.PORTD)
236 };
237}