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
|
use super::word::Word;
use super::{AnyChannel, Request, Transfer, TransferOptions};
use crate::Peri;
/// Convenience wrapper, contains a channel and a request number.
///
/// Commonly used in peripheral drivers that own DMA channels.
pub(crate) struct ChannelAndRequest<'d> {
pub channel: Peri<'d, AnyChannel>,
pub request: Request,
}
impl<'d> ChannelAndRequest<'d> {
pub unsafe fn read<'a, W: Word>(
&'a mut self,
peri_addr: *mut W,
buf: &'a mut [W],
options: TransferOptions,
) -> Transfer<'a> {
Transfer::new_read(self.channel.reborrow(), self.request, peri_addr, buf, options)
}
#[allow(dead_code)]
pub unsafe fn read_unchecked<'a, W: Word>(
&'a self,
peri_addr: *mut W,
buf: &'a mut [W],
options: TransferOptions,
) -> Transfer<'a> {
Transfer::new_read(self.channel.clone_unchecked(), self.request, peri_addr, buf, options)
}
pub unsafe fn read_raw<'a, MW: Word, PW: Word>(
&'a mut self,
peri_addr: *mut PW,
buf: *mut [MW],
options: TransferOptions,
) -> Transfer<'a> {
Transfer::new_read_raw(self.channel.reborrow(), self.request, peri_addr, buf, options)
}
#[allow(dead_code)]
pub unsafe fn read_raw_unchecked<'a, MW: Word, PW: Word>(
&'a self,
peri_addr: *mut PW,
buf: *mut [MW],
options: TransferOptions,
) -> Transfer<'a> {
Transfer::new_read_raw(self.channel.clone_unchecked(), self.request, peri_addr, buf, options)
}
pub unsafe fn write<'a, W: Word>(
&'a mut self,
buf: &'a [W],
peri_addr: *mut W,
options: TransferOptions,
) -> Transfer<'a> {
Transfer::new_write(self.channel.reborrow(), self.request, buf, peri_addr, options)
}
#[allow(dead_code)]
pub unsafe fn write_unchecked<'a, W: Word>(
&'a self,
buf: &'a [W],
peri_addr: *mut W,
options: TransferOptions,
) -> Transfer<'a> {
Transfer::new_write(self.channel.clone_unchecked(), self.request, buf, peri_addr, options)
}
pub unsafe fn write_raw<'a, MW: Word, PW: Word>(
&'a mut self,
buf: *const [MW],
peri_addr: *mut PW,
options: TransferOptions,
) -> Transfer<'a> {
Transfer::new_write_raw(self.channel.reborrow(), self.request, buf, peri_addr, options)
}
#[allow(dead_code)]
pub unsafe fn write_raw_unchecked<'a, MW: Word, PW: Word>(
&'a self,
buf: *const [MW],
peri_addr: *mut PW,
options: TransferOptions,
) -> Transfer<'a> {
Transfer::new_write_raw(self.channel.clone_unchecked(), self.request, buf, peri_addr, options)
}
#[allow(dead_code)]
pub unsafe fn write_repeated<'a, W: Word>(
&'a mut self,
repeated: &'a W,
count: usize,
peri_addr: *mut W,
options: TransferOptions,
) -> Transfer<'a> {
Transfer::new_write_repeated(
self.channel.reborrow(),
self.request,
repeated,
count,
peri_addr,
options,
)
}
#[allow(dead_code)]
pub unsafe fn write_repeated_unchecked<'a, W: Word>(
&'a self,
repeated: &'a W,
count: usize,
peri_addr: *mut W,
options: TransferOptions,
) -> Transfer<'a> {
Transfer::new_write_repeated(
self.channel.clone_unchecked(),
self.request,
repeated,
count,
peri_addr,
options,
)
}
}
|