@@ -78,6 +78,7 @@ pub struct spi_ioc_transfer<'a, 'b> {
78
78
}
79
79
80
80
impl < ' a , ' b > spi_ioc_transfer < ' a , ' b > {
81
+ /// Create a read transfer
81
82
pub fn read ( buff : & ' b mut [ u8 ] ) -> Self {
82
83
spi_ioc_transfer {
83
84
rx_buf : buff. as_ptr ( ) as * const ( ) as usize as u64 ,
@@ -86,6 +87,7 @@ impl<'a, 'b> spi_ioc_transfer<'a, 'b> {
86
87
}
87
88
}
88
89
90
+ /// Create a write transfer
89
91
pub fn write ( buff : & ' a [ u8 ] ) -> Self {
90
92
spi_ioc_transfer {
91
93
tx_buf : buff. as_ptr ( ) as * const ( ) as usize as u64 ,
@@ -94,7 +96,8 @@ impl<'a, 'b> spi_ioc_transfer<'a, 'b> {
94
96
}
95
97
}
96
98
97
- /// The `tx_buf` and `rx_buf` must be the same length.
99
+ /// Create a read/write transfer.
100
+ /// Note that the `tx_buf` and `rx_buf` must be the same length.
98
101
pub fn read_write ( tx_buf : & ' a [ u8 ] , rx_buf : & ' b mut [ u8 ] ) -> Self {
99
102
assert_eq ! ( tx_buf. len( ) , rx_buf. len( ) ) ;
100
103
spi_ioc_transfer {
@@ -104,6 +107,15 @@ impl<'a, 'b> spi_ioc_transfer<'a, 'b> {
104
107
..Default :: default ( )
105
108
}
106
109
}
110
+
111
+ /// Create a delay transfer of a number of microseconds
112
+ pub fn delay ( microseconds : u16 ) -> Self {
113
+ spi_ioc_transfer {
114
+ delay_usecs : microseconds,
115
+ len : 0 ,
116
+ ..Default :: default ( )
117
+ }
118
+ }
107
119
}
108
120
109
121
mod ioctl {
0 commit comments