35
35
) ]
36
36
//! Which chips the crate is built for depends on the feature flag used.
37
37
//! The following chips are available (using feature flags of the same name):
38
- //! * `at90usb1286`
39
- //! * `atmega1280`
40
- //! * `atmega1284p`
41
- //! * `atmega128rfa1`
42
- //! * `atmega164pa`
43
- //! * `atmega168`
44
- //! * `atmega2560`
45
- //! * `atmega8`
46
- //! * `atmega8u2`
47
- //! * `atmega328p`
48
- //! * `atmega328pb`
49
- //! * `atmega32u4`
50
- //! * `atmega4809`
51
- //! * `atmega48p`
52
- //! * `atmega64`
53
- //! * `atmega644`
54
- //! * `attiny13a`
55
- //! * `attiny167`
56
- //! * `attiny1614`
57
- //! * `attiny202`
58
- //! * `attiny2313`
59
- //! * `attiny2313a`
60
- //! * `attiny816`
61
- //! * `attiny84`
62
- //! * `attiny841`
63
- //! * `attiny85`
64
- //! * `attiny861`
65
- //! * `attiny88`
38
+ //! `at90usb1286`,
39
+ //! `atmega1280`,
40
+ //! `atmega1284p`,
41
+ //! `atmega128rfa1`,
42
+ //! `atmega164pa`,
43
+ //! `atmega168`,
44
+ //! `atmega2560`,
45
+ //! `atmega8`,
46
+ //! `atmega8u2`,
47
+ //! `atmega328p`,
48
+ //! `atmega328pb`,
49
+ //! `atmega32u4`,
50
+ //! `atmega4809`,
51
+ //! `atmega48p`,
52
+ //! `atmega64`,
53
+ //! `atmega644`,
54
+ //! `attiny13a`,
55
+ //! `attiny167`,
56
+ //! `attiny1614`,
57
+ //! `attiny202`,
58
+ //! `attiny2313`,
59
+ //! `attiny2313a`,
60
+ //! `attiny816`,
61
+ //! `attiny84`,
62
+ //! `attiny841`,
63
+ //! `attiny85`,
64
+ //! `attiny861`,
65
+ //! `attiny88`,
66
+ //!
67
+ //! # How to use this crate?
68
+ //!
69
+ //! In most cases you probably don't want to use this crate directly.
70
+ //!
71
+ //! This is a low level peripheral access crate (PAC).
72
+ //! There are more high level crates, like `avr-hal`, that implement a more convenient
73
+ //! and higher level API built ontop of `avr-device`.
74
+ //! However, sometimes it's required to operate on bare device register level.
75
+ //! That's what this crate is for.
76
+ //!
77
+ //! ## Main program entry point
78
+ //!
79
+ //! ```
80
+ //! #[avr_device::entry] // requires avr_device's rt feature.
81
+ //! fn main() -> ! {
82
+ //! loop {
83
+ //! // Your code here.
84
+ //! }
85
+ //! }
86
+ //! ```
87
+ //!
88
+ //! ## Get access to the device peripherals
89
+ //!
90
+ //! ```ignore
91
+ //! // To get access to the Peripherals struct, use this *once*:
92
+ //! let dp = avr_device::atmega328p::Peripherals::take().unwrap();
93
+ //! ```
94
+ //!
95
+ //! ## Example: Digital I/O port access
96
+ //!
97
+ //! ```ignore
98
+ //! // Configure bit 5 of port B as output:
99
+ //! dp.PORTB.ddrb.write(|w| w.pb5().set_bit());
100
+ //! // Clear bit 5 of port B:
101
+ //! dp.PORTB.portb.write(|w| w.pb5().clear_bit());
102
+ //! // Set bit 5 of port B:
103
+ //! dp.PORTB.portb.write(|w| w.pb5().set_bit());
104
+ //!
105
+ //! // Configure bit 6 of port B as input with pullup:
106
+ //! dp.PORTB.ddrb.write(|w| w.pb6().clear_bit());
107
+ //! dp.PORTB.portb.write(|w| w.pb6().set_bit());
108
+ //! // Read bit 6 of pin B:
109
+ //! let _mybit = dp.PORTB.pinb.read().pb6().bit_is_set();
110
+ //! // Read bit 6 and write to bit 5 of port B:
111
+ //! dp.PORTB.portb.modify(|r, w| w.pb6().bit(r.pb5().bit_is_set()))
112
+ //! ```
113
+ //!
114
+ //! ## Example: Other peripheral register access
115
+ //!
116
+ //! Other peripheral register accesses are similar to I/O port access.
117
+ //! Please read the documentation of the `struct R` and `struct W`
118
+ //! for the register of interest.
119
+ //!
120
+ //! e.g. [crate::atmega328p::spi::spcr::W]
121
+ //!
122
+ //! ```ignore
123
+ //! // Set SPE in SPCR (Enable SPI):
124
+ //! dp.SPI.spcr.write(|w| w.spe().set_bit());
125
+ //! ```
126
+ //!
127
+ //! # Crate feature flags
128
+ //!
129
+ //! * Device selection: To enable your device, select the crate feature that matches your device.
130
+ //! For a full list of supported devices, see the list at the beginning of this documentation.
131
+ //! * To enable the crate's runtime environment, use the `rt` feature.
132
+
66
133
#![ no_std]
67
134
#![ cfg_attr( avr_device_asm_macro, feature( asm_experimental_arch) ) ]
68
135
#![ cfg_attr( not( avr_device_asm_macro) , feature( llvm_asm) ) ]
@@ -91,6 +158,7 @@ pub mod generic;
91
158
/// vector. This is an unfortunate requirement of the current crate
92
159
/// architecture and might change in the future.
93
160
/// - The function must have a signature of `[unsafe] fn() [-> !]`.
161
+ /// - This macro requires the avr-device `rt` crate feature.
94
162
#[ cfg( feature = "rt" ) ]
95
163
pub use avr_device_macros:: interrupt;
96
164
@@ -105,7 +173,9 @@ pub use avr_device_macros::interrupt;
105
173
/// }
106
174
/// ```
107
175
///
108
- /// The entry function must have a signature of `[unsafe] fn() -> !`.
176
+ /// # Constraints
177
+ /// - The entry function must have a signature of `[unsafe] fn() -> !`.
178
+ /// - This macro requires the avr-device `rt` crate feature.
109
179
#[ cfg( feature = "rt" ) ]
110
180
pub use avr_device_macros:: entry;
111
181
0 commit comments