-
Notifications
You must be signed in to change notification settings - Fork 1
/
lib.rs
383 lines (383 loc) · 11.3 KB
/
lib.rs
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#![feature(abi_msp430_interrupt)]
#![doc = "Peripheral access API for MSP430G2211 microcontrollers (generated using svd2rust v0.25.1 (481f6b8 2022-09-06))\n\nYou can find an overview of the generated API [here].\n\nAPI features to be included in the [next]
svd2rust 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.25.1/svd2rust/#peripheral-api\n[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n[repository]: https://github.com/rust-embedded/svd2rust"]
#![deny(const_err)]
#![deny(dead_code)]
#![deny(improper_ctypes)]
#![deny(missing_docs)]
#![deny(no_mangle_generic_items)]
#![deny(non_shorthand_field_patterns)]
#![deny(overflowing_literals)]
#![deny(path_statements)]
#![deny(patterns_in_fns_without_body)]
#![deny(private_in_public)]
#![deny(unconditional_recursion)]
#![deny(unused_allocation)]
#![deny(unused_comparisons)]
#![deny(unused_parens)]
#![deny(while_true)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![no_std]
#[cfg(feature = "rt")]
pub use self::Interrupt as interrupt;
use core::marker::PhantomData;
use core::ops::Deref;
#[allow(unused_imports)]
use generic::*;
#[cfg(feature = "rt")]
pub use msp430_rt::interrupt;
#[doc = "Common register and bit access and modify traits"]
pub mod generic;
#[cfg(feature = "rt")]
extern "msp430-interrupt" {
fn PORT1();
fn PORT2();
fn TIMERA1();
fn TIMERA0();
fn WDT();
fn COMPARATORA();
fn NMI();
}
#[doc(hidden)]
pub union Vector {
_handler: unsafe extern "msp430-interrupt" fn(),
_reserved: u16,
}
#[cfg(feature = "rt")]
#[doc(hidden)]
#[link_section = ".vector_table.interrupts"]
#[no_mangle]
#[used]
pub static __INTERRUPTS: [Vector; 15] = [
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _handler: PORT1 },
Vector { _handler: PORT2 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _handler: TIMERA1 },
Vector { _handler: TIMERA0 },
Vector { _handler: WDT },
Vector {
_handler: COMPARATORA,
},
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _handler: NMI },
];
#[doc = r"Enumeration of all the interrupts. This enum is seldom used in application or library crates. It is present primarily for documenting the device's implemented interrupts."]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u16)]
pub enum Interrupt {
#[doc = "2 - 0xFFE4 Port 1"]
PORT1 = 2,
#[doc = "3 - 0xFFE6 Port 2"]
PORT2 = 3,
#[doc = "8 - 0xFFF0 Timer A CC1-2, TA"]
TIMERA1 = 8,
#[doc = "9 - 0xFFF2 Timer A CC0"]
TIMERA0 = 9,
#[doc = "10 - 0xFFF4 Watchdog Timer"]
WDT = 10,
#[doc = "11 - 0xFFF6 Comparator A"]
COMPARATORA = 11,
#[doc = "14 - 0xFFFC Non-maskable"]
NMI = 14,
}
#[doc = "Special Function"]
pub struct SPECIAL_FUNCTION {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for SPECIAL_FUNCTION {}
impl SPECIAL_FUNCTION {
#[doc = r"Pointer to the register block"]
pub const PTR: *const special_function::RegisterBlock = 0 as *const _;
#[doc = r"Return the pointer to the register block"]
#[inline(always)]
pub const fn ptr() -> *const special_function::RegisterBlock {
Self::PTR
}
}
impl Deref for SPECIAL_FUNCTION {
type Target = special_function::RegisterBlock;
#[inline(always)]
fn deref(&self) -> &Self::Target {
unsafe { &*Self::PTR }
}
}
impl core::fmt::Debug for SPECIAL_FUNCTION {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("SPECIAL_FUNCTION").finish()
}
}
#[doc = "Special Function"]
pub mod special_function;
#[doc = "Port 1/2"]
pub struct PORT_1_2 {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for PORT_1_2 {}
impl PORT_1_2 {
#[doc = r"Pointer to the register block"]
pub const PTR: *const port_1_2::RegisterBlock = 0x20 as *const _;
#[doc = r"Return the pointer to the register block"]
#[inline(always)]
pub const fn ptr() -> *const port_1_2::RegisterBlock {
Self::PTR
}
}
impl Deref for PORT_1_2 {
type Target = port_1_2::RegisterBlock;
#[inline(always)]
fn deref(&self) -> &Self::Target {
unsafe { &*Self::PTR }
}
}
impl core::fmt::Debug for PORT_1_2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PORT_1_2").finish()
}
}
#[doc = "Port 1/2"]
pub mod port_1_2;
#[doc = "System Clock"]
pub struct SYSTEM_CLOCK {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for SYSTEM_CLOCK {}
impl SYSTEM_CLOCK {
#[doc = r"Pointer to the register block"]
pub const PTR: *const system_clock::RegisterBlock = 0x52 as *const _;
#[doc = r"Return the pointer to the register block"]
#[inline(always)]
pub const fn ptr() -> *const system_clock::RegisterBlock {
Self::PTR
}
}
impl Deref for SYSTEM_CLOCK {
type Target = system_clock::RegisterBlock;
#[inline(always)]
fn deref(&self) -> &Self::Target {
unsafe { &*Self::PTR }
}
}
impl core::fmt::Debug for SYSTEM_CLOCK {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("SYSTEM_CLOCK").finish()
}
}
#[doc = "System Clock"]
pub mod system_clock;
#[doc = "Comparator A"]
pub struct COMPARATOR_A {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for COMPARATOR_A {}
impl COMPARATOR_A {
#[doc = r"Pointer to the register block"]
pub const PTR: *const comparator_a::RegisterBlock = 0x58 as *const _;
#[doc = r"Return the pointer to the register block"]
#[inline(always)]
pub const fn ptr() -> *const comparator_a::RegisterBlock {
Self::PTR
}
}
impl Deref for COMPARATOR_A {
type Target = comparator_a::RegisterBlock;
#[inline(always)]
fn deref(&self) -> &Self::Target {
unsafe { &*Self::PTR }
}
}
impl core::fmt::Debug for COMPARATOR_A {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("COMPARATOR_A").finish()
}
}
#[doc = "Comparator A"]
pub mod comparator_a;
#[doc = "Calibration Data"]
pub struct CALIBRATION_DATA {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for CALIBRATION_DATA {}
impl CALIBRATION_DATA {
#[doc = r"Pointer to the register block"]
pub const PTR: *const calibration_data::RegisterBlock = 0x10fe as *const _;
#[doc = r"Return the pointer to the register block"]
#[inline(always)]
pub const fn ptr() -> *const calibration_data::RegisterBlock {
Self::PTR
}
}
impl Deref for CALIBRATION_DATA {
type Target = calibration_data::RegisterBlock;
#[inline(always)]
fn deref(&self) -> &Self::Target {
unsafe { &*Self::PTR }
}
}
impl core::fmt::Debug for CALIBRATION_DATA {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("CALIBRATION_DATA").finish()
}
}
#[doc = "Calibration Data"]
pub mod calibration_data;
#[doc = "Watchdog Timer"]
pub struct WATCHDOG_TIMER {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for WATCHDOG_TIMER {}
impl WATCHDOG_TIMER {
#[doc = r"Pointer to the register block"]
pub const PTR: *const watchdog_timer::RegisterBlock = 0x0120 as *const _;
#[doc = r"Return the pointer to the register block"]
#[inline(always)]
pub const fn ptr() -> *const watchdog_timer::RegisterBlock {
Self::PTR
}
}
impl Deref for WATCHDOG_TIMER {
type Target = watchdog_timer::RegisterBlock;
#[inline(always)]
fn deref(&self) -> &Self::Target {
unsafe { &*Self::PTR }
}
}
impl core::fmt::Debug for WATCHDOG_TIMER {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("WATCHDOG_TIMER").finish()
}
}
#[doc = "Watchdog Timer"]
pub mod watchdog_timer;
#[doc = "Flash"]
pub struct FLASH {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for FLASH {}
impl FLASH {
#[doc = r"Pointer to the register block"]
pub const PTR: *const flash::RegisterBlock = 0x0128 as *const _;
#[doc = r"Return the pointer to the register block"]
#[inline(always)]
pub const fn ptr() -> *const flash::RegisterBlock {
Self::PTR
}
}
impl Deref for FLASH {
type Target = flash::RegisterBlock;
#[inline(always)]
fn deref(&self) -> &Self::Target {
unsafe { &*Self::PTR }
}
}
impl core::fmt::Debug for FLASH {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("FLASH").finish()
}
}
#[doc = "Flash"]
pub mod flash;
#[doc = "Timer A2"]
pub struct TIMER_A2 {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for TIMER_A2 {}
impl TIMER_A2 {
#[doc = r"Pointer to the register block"]
pub const PTR: *const timer_a2::RegisterBlock = 0x012e as *const _;
#[doc = r"Return the pointer to the register block"]
#[inline(always)]
pub const fn ptr() -> *const timer_a2::RegisterBlock {
Self::PTR
}
}
impl Deref for TIMER_A2 {
type Target = timer_a2::RegisterBlock;
#[inline(always)]
fn deref(&self) -> &Self::Target {
unsafe { &*Self::PTR }
}
}
impl core::fmt::Debug for TIMER_A2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TIMER_A2").finish()
}
}
#[doc = "Timer A2"]
pub mod timer_a2;
#[no_mangle]
static mut DEVICE_PERIPHERALS: bool = false;
#[doc = r" All the peripherals."]
#[allow(non_snake_case)]
pub struct Peripherals {
#[doc = "SPECIAL_FUNCTION"]
pub SPECIAL_FUNCTION: SPECIAL_FUNCTION,
#[doc = "PORT_1_2"]
pub PORT_1_2: PORT_1_2,
#[doc = "SYSTEM_CLOCK"]
pub SYSTEM_CLOCK: SYSTEM_CLOCK,
#[doc = "COMPARATOR_A"]
pub COMPARATOR_A: COMPARATOR_A,
#[doc = "CALIBRATION_DATA"]
pub CALIBRATION_DATA: CALIBRATION_DATA,
#[doc = "WATCHDOG_TIMER"]
pub WATCHDOG_TIMER: WATCHDOG_TIMER,
#[doc = "FLASH"]
pub FLASH: FLASH,
#[doc = "TIMER_A2"]
pub TIMER_A2: TIMER_A2,
}
impl Peripherals {
#[doc = r" Returns all the peripherals *once*."]
#[cfg(feature = "critical-section")]
#[inline]
pub fn take() -> Option<Self> {
critical_section::with(|_| {
if unsafe { DEVICE_PERIPHERALS } {
return None;
}
Some(unsafe { Peripherals::steal() })
})
}
#[doc = r" Unchecked version of `Peripherals::take`."]
#[doc = r""]
#[doc = r" # Safety"]
#[doc = r""]
#[doc = r" Each of the returned peripherals must be used at most once."]
#[inline]
pub unsafe fn steal() -> Self {
DEVICE_PERIPHERALS = true;
Peripherals {
SPECIAL_FUNCTION: SPECIAL_FUNCTION {
_marker: PhantomData,
},
PORT_1_2: PORT_1_2 {
_marker: PhantomData,
},
SYSTEM_CLOCK: SYSTEM_CLOCK {
_marker: PhantomData,
},
COMPARATOR_A: COMPARATOR_A {
_marker: PhantomData,
},
CALIBRATION_DATA: CALIBRATION_DATA {
_marker: PhantomData,
},
WATCHDOG_TIMER: WATCHDOG_TIMER {
_marker: PhantomData,
},
FLASH: FLASH {
_marker: PhantomData,
},
TIMER_A2: TIMER_A2 {
_marker: PhantomData,
},
}
}
}