File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,13 @@ macro_rules! uart_shared {
168
168
let usart = unsafe { & ( * $USARTX:: ptr( ) ) } ;
169
169
usart. cr1. modify( |_, w| w. rxneie( ) . clear_bit( ) ) ;
170
170
}
171
+
172
+ /// Return true if the rx register is not empty (and can be read)
173
+ pub fn is_rxne( & self ) -> bool {
174
+ let usart = unsafe { & ( * $USARTX:: ptr( ) ) } ;
175
+ usart. isr. read( ) . rxne( ) . bit_is_set( )
176
+ }
177
+
171
178
}
172
179
173
180
impl <Config > hal:: serial:: Read <u8 > for Rx <$USARTX, Config > {
@@ -219,6 +226,13 @@ macro_rules! uart_shared {
219
226
let usart = unsafe { & ( * $USARTX:: ptr( ) ) } ;
220
227
usart. cr1. modify( |_, w| w. txeie( ) . clear_bit( ) ) ;
221
228
}
229
+
230
+ /// Return true if the tx register is empty (and can accept data)
231
+ pub fn is_txe( & self ) -> bool {
232
+ let usart = unsafe { & ( * $USARTX:: ptr( ) ) } ;
233
+ usart. isr. read( ) . txe( ) . bit_is_set( )
234
+ }
235
+
222
236
}
223
237
224
238
impl <Config > hal:: serial:: Write <u8 > for Tx <$USARTX, Config > {
You can’t perform that action at this time.
0 commit comments