Commit 3e60d1d 1 parent 3bc2ee4 commit 3e60d1d Copy full SHA for 3e60d1d
File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -892,7 +892,15 @@ impl<Uart: Instance> embedded_hal_nb::serial::Read<u8> for Rx<Uart> {
892
892
893
893
impl < Uart : Instance > embedded_io:: Read for Rx < Uart > {
894
894
fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , Self :: Error > {
895
+ if buf. is_empty ( ) {
896
+ return Ok ( 0 ) ;
897
+ }
895
898
let mut read = 0 ;
899
+ loop {
900
+ if self . 0 . rxstatus ( ) . read ( ) . rdavl ( ) . bit_is_set ( ) {
901
+ break ;
902
+ }
903
+ }
896
904
for byte in buf. iter_mut ( ) {
897
905
match <Self as embedded_hal_nb:: serial:: Read < u8 > >:: read ( self ) {
898
906
Ok ( w) => {
@@ -1058,6 +1066,14 @@ impl<Uart: Instance> embedded_hal_nb::serial::Write<u8> for Tx<Uart> {
1058
1066
1059
1067
impl < Uart : Instance > embedded_io:: Write for Tx < Uart > {
1060
1068
fn write ( & mut self , buf : & [ u8 ] ) -> Result < usize , Self :: Error > {
1069
+ if buf. is_empty ( ) {
1070
+ return Ok ( 0 ) ;
1071
+ }
1072
+ loop {
1073
+ if self . 0 . txstatus ( ) . read ( ) . wrrdy ( ) . bit_is_set ( ) {
1074
+ break ;
1075
+ }
1076
+ }
1061
1077
let mut written = 0 ;
1062
1078
for byte in buf. iter ( ) {
1063
1079
match <Self as embedded_hal_nb:: serial:: Write < u8 > >:: write ( self , * byte) {
@@ -1066,7 +1082,7 @@ impl<Uart: Instance> embedded_io::Write for Tx<Uart> {
1066
1082
}
1067
1083
}
1068
1084
1069
- Ok ( buf . len ( ) )
1085
+ Ok ( written )
1070
1086
}
1071
1087
1072
1088
fn flush ( & mut self ) -> Result < ( ) , Self :: Error > {
You can’t perform that action at this time.
0 commit comments