avr_device/devices/attiny85/
mod.rs

1#![doc = "Peripheral access API for ATTINY85 microcontrollers (generated using svd2rust v0.28.0 ( ))\n\nYou can find an overview of the generated API [here].\n\nAPI features to be included in the [next]
2svd2rust release can be generated by cloning the svd2rust [repository], checking out the above commit, and running `cargo doc --open`.\n\n[here]: https://docs.rs/svd2rust/0.28.0/svd2rust/#peripheral-api\n[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n[repository]: https://github.com/rust-embedded/svd2rust"]
3use core::marker::PhantomData;
4use core::ops::Deref;
5#[doc = r"Number available in the NVIC for configuring priority"]
6pub const NVIC_PRIO_BITS: u8 = 4;
7#[doc(hidden)]
8pub mod interrupt;
9pub use self::interrupt::Interrupt;
10#[doc = "Analog Comparator"]
11pub struct AC {
12    _marker: PhantomData<*const ()>,
13}
14unsafe impl Send for AC {}
15impl AC {
16    #[doc = r"Pointer to the register block"]
17    pub const PTR: *const ac::RegisterBlock = 0x23 as *const _;
18    #[doc = r"Return the pointer to the register block"]
19    #[inline(always)]
20    pub const fn ptr() -> *const ac::RegisterBlock {
21        Self::PTR
22    }
23}
24impl Deref for AC {
25    type Target = ac::RegisterBlock;
26    #[inline(always)]
27    fn deref(&self) -> &Self::Target {
28        unsafe { &*Self::PTR }
29    }
30}
31impl core::fmt::Debug for AC {
32    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
33        f.debug_struct("AC").finish()
34    }
35}
36#[doc = "Analog Comparator"]
37pub mod ac;
38#[doc = "Analog-to-Digital Converter"]
39pub struct ADC {
40    _marker: PhantomData<*const ()>,
41}
42unsafe impl Send for ADC {}
43impl ADC {
44    #[doc = r"Pointer to the register block"]
45    pub const PTR: *const adc::RegisterBlock = 0x23 as *const _;
46    #[doc = r"Return the pointer to the register block"]
47    #[inline(always)]
48    pub const fn ptr() -> *const adc::RegisterBlock {
49        Self::PTR
50    }
51}
52impl Deref for ADC {
53    type Target = adc::RegisterBlock;
54    #[inline(always)]
55    fn deref(&self) -> &Self::Target {
56        unsafe { &*Self::PTR }
57    }
58}
59impl core::fmt::Debug for ADC {
60    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
61        f.debug_struct("ADC").finish()
62    }
63}
64#[doc = "Analog-to-Digital Converter"]
65pub mod adc;
66#[doc = "Bootloader"]
67pub struct BOOT_LOAD {
68    _marker: PhantomData<*const ()>,
69}
70unsafe impl Send for BOOT_LOAD {}
71impl BOOT_LOAD {
72    #[doc = r"Pointer to the register block"]
73    pub const PTR: *const boot_load::RegisterBlock = 0x57 as *const _;
74    #[doc = r"Return the pointer to the register block"]
75    #[inline(always)]
76    pub const fn ptr() -> *const boot_load::RegisterBlock {
77        Self::PTR
78    }
79}
80impl Deref for BOOT_LOAD {
81    type Target = boot_load::RegisterBlock;
82    #[inline(always)]
83    fn deref(&self) -> &Self::Target {
84        unsafe { &*Self::PTR }
85    }
86}
87impl core::fmt::Debug for BOOT_LOAD {
88    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
89        f.debug_struct("BOOT_LOAD").finish()
90    }
91}
92#[doc = "Bootloader"]
93pub mod boot_load;
94#[doc = "CPU Registers"]
95pub struct CPU {
96    _marker: PhantomData<*const ()>,
97}
98unsafe impl Send for CPU {}
99impl CPU {
100    #[doc = r"Pointer to the register block"]
101    pub const PTR: *const cpu::RegisterBlock = 0x31 as *const _;
102    #[doc = r"Return the pointer to the register block"]
103    #[inline(always)]
104    pub const fn ptr() -> *const cpu::RegisterBlock {
105        Self::PTR
106    }
107}
108impl Deref for CPU {
109    type Target = cpu::RegisterBlock;
110    #[inline(always)]
111    fn deref(&self) -> &Self::Target {
112        unsafe { &*Self::PTR }
113    }
114}
115impl core::fmt::Debug for CPU {
116    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
117        f.debug_struct("CPU").finish()
118    }
119}
120#[doc = "CPU Registers"]
121pub mod cpu;
122#[doc = "EEPROM"]
123pub struct EEPROM {
124    _marker: PhantomData<*const ()>,
125}
126unsafe impl Send for EEPROM {}
127impl EEPROM {
128    #[doc = r"Pointer to the register block"]
129    pub const PTR: *const eeprom::RegisterBlock = 0x3c as *const _;
130    #[doc = r"Return the pointer to the register block"]
131    #[inline(always)]
132    pub const fn ptr() -> *const eeprom::RegisterBlock {
133        Self::PTR
134    }
135}
136impl Deref for EEPROM {
137    type Target = eeprom::RegisterBlock;
138    #[inline(always)]
139    fn deref(&self) -> &Self::Target {
140        unsafe { &*Self::PTR }
141    }
142}
143impl core::fmt::Debug for EEPROM {
144    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
145        f.debug_struct("EEPROM").finish()
146    }
147}
148#[doc = "EEPROM"]
149pub mod eeprom;
150#[doc = "External Interrupts"]
151pub struct EXINT {
152    _marker: PhantomData<*const ()>,
153}
154unsafe impl Send for EXINT {}
155impl EXINT {
156    #[doc = r"Pointer to the register block"]
157    pub const PTR: *const exint::RegisterBlock = 0x35 as *const _;
158    #[doc = r"Return the pointer to the register block"]
159    #[inline(always)]
160    pub const fn ptr() -> *const exint::RegisterBlock {
161        Self::PTR
162    }
163}
164impl Deref for EXINT {
165    type Target = exint::RegisterBlock;
166    #[inline(always)]
167    fn deref(&self) -> &Self::Target {
168        unsafe { &*Self::PTR }
169    }
170}
171impl core::fmt::Debug for EXINT {
172    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
173        f.debug_struct("EXINT").finish()
174    }
175}
176#[doc = "External Interrupts"]
177pub mod exint;
178#[doc = "Fuses"]
179pub struct FUSE {
180    _marker: PhantomData<*const ()>,
181}
182unsafe impl Send for FUSE {}
183impl FUSE {
184    #[doc = r"Pointer to the register block"]
185    pub const PTR: *const fuse::RegisterBlock = 0 as *const _;
186    #[doc = r"Return the pointer to the register block"]
187    #[inline(always)]
188    pub const fn ptr() -> *const fuse::RegisterBlock {
189        Self::PTR
190    }
191}
192impl Deref for FUSE {
193    type Target = fuse::RegisterBlock;
194    #[inline(always)]
195    fn deref(&self) -> &Self::Target {
196        unsafe { &*Self::PTR }
197    }
198}
199impl core::fmt::Debug for FUSE {
200    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
201        f.debug_struct("FUSE").finish()
202    }
203}
204#[doc = "Fuses"]
205pub mod fuse;
206#[doc = "Lockbits"]
207pub struct LOCKBIT {
208    _marker: PhantomData<*const ()>,
209}
210unsafe impl Send for LOCKBIT {}
211impl LOCKBIT {
212    #[doc = r"Pointer to the register block"]
213    pub const PTR: *const lockbit::RegisterBlock = 0 as *const _;
214    #[doc = r"Return the pointer to the register block"]
215    #[inline(always)]
216    pub const fn ptr() -> *const lockbit::RegisterBlock {
217        Self::PTR
218    }
219}
220impl Deref for LOCKBIT {
221    type Target = lockbit::RegisterBlock;
222    #[inline(always)]
223    fn deref(&self) -> &Self::Target {
224        unsafe { &*Self::PTR }
225    }
226}
227impl core::fmt::Debug for LOCKBIT {
228    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
229        f.debug_struct("LOCKBIT").finish()
230    }
231}
232#[doc = "Lockbits"]
233pub mod lockbit;
234#[doc = "I/O Port"]
235pub struct PORTB {
236    _marker: PhantomData<*const ()>,
237}
238unsafe impl Send for PORTB {}
239impl PORTB {
240    #[doc = r"Pointer to the register block"]
241    pub const PTR: *const portb::RegisterBlock = 0x36 as *const _;
242    #[doc = r"Return the pointer to the register block"]
243    #[inline(always)]
244    pub const fn ptr() -> *const portb::RegisterBlock {
245        Self::PTR
246    }
247}
248impl Deref for PORTB {
249    type Target = portb::RegisterBlock;
250    #[inline(always)]
251    fn deref(&self) -> &Self::Target {
252        unsafe { &*Self::PTR }
253    }
254}
255impl core::fmt::Debug for PORTB {
256    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
257        f.debug_struct("PORTB").finish()
258    }
259}
260#[doc = "I/O Port"]
261pub mod portb;
262#[doc = "Timer/Counter0, 8-bit, PWM"]
263pub struct TC0 {
264    _marker: PhantomData<*const ()>,
265}
266unsafe impl Send for TC0 {}
267impl TC0 {
268    #[doc = r"Pointer to the register block"]
269    pub const PTR: *const tc0::RegisterBlock = 0x48 as *const _;
270    #[doc = r"Return the pointer to the register block"]
271    #[inline(always)]
272    pub const fn ptr() -> *const tc0::RegisterBlock {
273        Self::PTR
274    }
275}
276impl Deref for TC0 {
277    type Target = tc0::RegisterBlock;
278    #[inline(always)]
279    fn deref(&self) -> &Self::Target {
280        unsafe { &*Self::PTR }
281    }
282}
283impl core::fmt::Debug for TC0 {
284    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
285        f.debug_struct("TC0").finish()
286    }
287}
288#[doc = "Timer/Counter0, 8-bit, PWM"]
289pub mod tc0;
290#[doc = "Timer/Counter1, 8-bit"]
291pub struct TC1 {
292    _marker: PhantomData<*const ()>,
293}
294unsafe impl Send for TC1 {}
295impl TC1 {
296    #[doc = r"Pointer to the register block"]
297    pub const PTR: *const tc1::RegisterBlock = 0x43 as *const _;
298    #[doc = r"Return the pointer to the register block"]
299    #[inline(always)]
300    pub const fn ptr() -> *const tc1::RegisterBlock {
301        Self::PTR
302    }
303}
304impl Deref for TC1 {
305    type Target = tc1::RegisterBlock;
306    #[inline(always)]
307    fn deref(&self) -> &Self::Target {
308        unsafe { &*Self::PTR }
309    }
310}
311impl core::fmt::Debug for TC1 {
312    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
313        f.debug_struct("TC1").finish()
314    }
315}
316#[doc = "Timer/Counter1, 8-bit"]
317pub mod tc1;
318#[doc = "Universal Serial Interface"]
319pub struct USI {
320    _marker: PhantomData<*const ()>,
321}
322unsafe impl Send for USI {}
323impl USI {
324    #[doc = r"Pointer to the register block"]
325    pub const PTR: *const usi::RegisterBlock = 0x2d as *const _;
326    #[doc = r"Return the pointer to the register block"]
327    #[inline(always)]
328    pub const fn ptr() -> *const usi::RegisterBlock {
329        Self::PTR
330    }
331}
332impl Deref for USI {
333    type Target = usi::RegisterBlock;
334    #[inline(always)]
335    fn deref(&self) -> &Self::Target {
336        unsafe { &*Self::PTR }
337    }
338}
339impl core::fmt::Debug for USI {
340    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
341        f.debug_struct("USI").finish()
342    }
343}
344#[doc = "Universal Serial Interface"]
345pub mod usi;
346#[doc = "Watchdog Timer"]
347pub struct WDT {
348    _marker: PhantomData<*const ()>,
349}
350unsafe impl Send for WDT {}
351impl WDT {
352    #[doc = r"Pointer to the register block"]
353    pub const PTR: *const wdt::RegisterBlock = 0x41 as *const _;
354    #[doc = r"Return the pointer to the register block"]
355    #[inline(always)]
356    pub const fn ptr() -> *const wdt::RegisterBlock {
357        Self::PTR
358    }
359}
360impl Deref for WDT {
361    type Target = wdt::RegisterBlock;
362    #[inline(always)]
363    fn deref(&self) -> &Self::Target {
364        unsafe { &*Self::PTR }
365    }
366}
367impl core::fmt::Debug for WDT {
368    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
369        f.debug_struct("WDT").finish()
370    }
371}
372#[doc = "Watchdog Timer"]
373pub mod wdt;
374use crate::devices::DEVICE_PERIPHERALS;
375#[doc = r" All the peripherals."]
376#[allow(non_snake_case)]
377pub struct Peripherals {
378    #[doc = "AC"]
379    pub AC: AC,
380    #[doc = "ADC"]
381    pub ADC: ADC,
382    #[doc = "BOOT_LOAD"]
383    pub BOOT_LOAD: BOOT_LOAD,
384    #[doc = "CPU"]
385    pub CPU: CPU,
386    #[doc = "EEPROM"]
387    pub EEPROM: EEPROM,
388    #[doc = "EXINT"]
389    pub EXINT: EXINT,
390    #[doc = "FUSE"]
391    pub FUSE: FUSE,
392    #[doc = "LOCKBIT"]
393    pub LOCKBIT: LOCKBIT,
394    #[doc = "PORTB"]
395    pub PORTB: PORTB,
396    #[doc = "TC0"]
397    pub TC0: TC0,
398    #[doc = "TC1"]
399    pub TC1: TC1,
400    #[doc = "USI"]
401    pub USI: USI,
402    #[doc = "WDT"]
403    pub WDT: WDT,
404}
405impl Peripherals {
406    #[doc = r" Returns all the peripherals *once*."]
407    #[inline]
408    pub fn take() -> Option<Self> {
409        crate::interrupt::free(|_| {
410            if unsafe { DEVICE_PERIPHERALS } {
411                return None;
412            }
413            Some(unsafe { Peripherals::steal() })
414        })
415    }
416    #[doc = r" Unchecked version of `Peripherals::take`."]
417    #[doc = r""]
418    #[doc = r" # Safety"]
419    #[doc = r""]
420    #[doc = r" Each of the returned peripherals must be used at most once."]
421    #[inline]
422    pub unsafe fn steal() -> Self {
423        DEVICE_PERIPHERALS = true;
424        Peripherals {
425            AC: AC {
426                _marker: PhantomData,
427            },
428            ADC: ADC {
429                _marker: PhantomData,
430            },
431            BOOT_LOAD: BOOT_LOAD {
432                _marker: PhantomData,
433            },
434            CPU: CPU {
435                _marker: PhantomData,
436            },
437            EEPROM: EEPROM {
438                _marker: PhantomData,
439            },
440            EXINT: EXINT {
441                _marker: PhantomData,
442            },
443            FUSE: FUSE {
444                _marker: PhantomData,
445            },
446            LOCKBIT: LOCKBIT {
447                _marker: PhantomData,
448            },
449            PORTB: PORTB {
450                _marker: PhantomData,
451            },
452            TC0: TC0 {
453                _marker: PhantomData,
454            },
455            TC1: TC1 {
456                _marker: PhantomData,
457            },
458            USI: USI {
459                _marker: PhantomData,
460            },
461            WDT: WDT {
462                _marker: PhantomData,
463            },
464        }
465    }
466}