atmega_hal/
lib.rs
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
115#[cfg(feature = "device-selected")]
116pub use pac::Peripherals;
117
118pub use avr_hal_generic::clock;
119pub use avr_hal_generic::delay;
120pub use avr_hal_generic::prelude;
121
122#[cfg(feature = "device-selected")]
123pub mod adc;
124#[cfg(feature = "device-selected")]
125pub use adc::Adc;
126
127#[cfg(feature = "device-selected")]
128pub mod i2c;
129#[cfg(feature = "device-selected")]
130pub use i2c::I2c;
131
132#[cfg(feature = "device-selected")]
133pub mod spi;
134#[cfg(feature = "device-selected")]
135pub use spi::Spi;
136
137#[cfg(feature = "device-selected")]
138pub mod port;
139#[cfg(feature = "device-selected")]
140pub use port::Pins;
141
142#[cfg(feature = "device-selected")]
143pub mod simple_pwm;
144
145#[cfg(feature = "device-selected")]
146pub mod usart;
147#[cfg(feature = "device-selected")]
148pub use usart::Usart;
149
150#[cfg(feature = "device-selected")]
151pub mod wdt;
152#[cfg(feature = "device-selected")]
153pub use wdt::Wdt;
154
155#[cfg(feature = "device-selected")]
156pub mod eeprom;
157#[cfg(feature = "device-selected")]
158pub use eeprom::Eeprom;
159
160pub struct Atmega;
161
162#[cfg(any(
163 feature = "atmega48p",
164 feature = "atmega88p",
165 feature = "atmega168",
166 feature = "atmega328p"
167))]
168#[macro_export]
169macro_rules! pins {
170 ($p:expr) => {
171 $crate::Pins::new($p.PORTB, $p.PORTC, $p.PORTD)
172 };
173}
174#[cfg(any(feature = "atmega16", feature = "atmega164pa"))]
175#[macro_export]
176macro_rules! pins {
177 ($p:expr) => {
178 $crate::Pins::new($p.PORTA, $p.PORTB, $p.PORTC, $p.PORTD)
179 };
180}
181#[cfg(feature = "atmega328pb")]
182#[macro_export]
183macro_rules! pins {
184 ($p:expr) => {
185 $crate::Pins::new($p.PORTB, $p.PORTC, $p.PORTD, $p.PORTE)
186 };
187}
188#[cfg(feature = "atmega32u4")]
189#[macro_export]
190macro_rules! pins {
191 ($p:expr) => {
192 $crate::Pins::new($p.PORTB, $p.PORTC, $p.PORTD, $p.PORTE, $p.PORTF)
193 };
194}
195
196#[cfg(any(feature = "atmega128a"))]
197#[macro_export]
198macro_rules! pins {
199 ($p:expr) => {
200 $crate::Pins::new(
201 $p.PORTA, $p.PORTB, $p.PORTC, $p.PORTD, $p.PORTE, $p.PORTF, $p.PORTG,
202 )
203 };
204}
205
206#[cfg(any(feature = "atmega1280", feature = "atmega2560"))]
207#[macro_export]
208macro_rules! pins {
209 ($p:expr) => {
210 $crate::Pins::new(
211 $p.PORTA, $p.PORTB, $p.PORTC, $p.PORTD, $p.PORTE, $p.PORTF, $p.PORTG, $p.PORTH,
212 $p.PORTJ, $p.PORTK, $p.PORTL,
213 )
214 };
215}
216
217#[cfg(any(feature = "atmega1284p", feature = "atmega32a"))]
218#[macro_export]
219macro_rules! pins {
220 ($p:expr) => {
221 $crate::Pins::new($p.PORTA, $p.PORTB, $p.PORTC, $p.PORTD)
222 };
223}
224
225#[cfg(any(feature = "atmega8"))]
226#[macro_export]
227macro_rules! pins {
228 ($p:expr) => {
229 $crate::Pins::new($p.PORTB, $p.PORTC, $p.PORTD)
230 };
231}