@@ -76,11 +76,21 @@ pub enum Event {
76
76
pub mod config {
77
77
use crate :: time:: Hertz ;
78
78
79
+ /// The number of bits in a serial data word
80
+ ///
81
+ /// Note that the length includes the data bits and any parity bits, but not start or stop bits.
79
82
#[ derive( Copy , Clone , PartialEq ) ]
80
83
pub enum WordLength {
81
84
DataBits8 ,
82
85
DataBits9 ,
83
86
}
87
+ /// The parity bits appended to each serial data word
88
+ ///
89
+ /// When enabled parity bits will be automatically added by hardware on transmit, and automatically checked by
90
+ /// hardware on receive. For example, `read()` would return [`Error::Parity`](super::Error::Parity).
91
+ ///
92
+ /// Note that parity bits are included in the serial word length, so if parity is used word length should be set to
93
+ /// [`WordLength::DataBits9`].
84
94
#[ derive( Copy , Clone , PartialEq ) ]
85
95
pub enum Parity {
86
96
ParityNone ,
@@ -162,11 +172,19 @@ pub mod config {
162
172
self
163
173
}
164
174
175
+ /// Enables Even Parity
176
+ ///
177
+ /// Note that parity bits are included in the serial word length, so if parity is used word length should be set
178
+ /// to [`WordLength::DataBits9`].
165
179
pub fn parity_even ( mut self ) -> Self {
166
180
self . parity = Parity :: ParityEven ;
167
181
self
168
182
}
169
183
184
+ /// Enables Odd Parity
185
+ ///
186
+ /// Note that parity bits are included in the serial word length, so if parity is used word length should be set
187
+ /// to [`WordLength::DataBits9`].
170
188
pub fn parity_odd ( mut self ) -> Self {
171
189
self . parity = Parity :: ParityOdd ;
172
190
self
@@ -177,6 +195,10 @@ pub mod config {
177
195
self
178
196
}
179
197
198
+ /// Set the serial word length to 9
199
+ ///
200
+ /// Note that the HAL currently only supports transmitting 8-bit serial data, so the 9th bit will always be zero
201
+ /// except when it is a parity bit.
180
202
pub fn wordlength_9 ( mut self ) -> Self {
181
203
self . wordlength = WordLength :: DataBits9 ;
182
204
self
0 commit comments