aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-12-14 16:01:51 +0100
committerDario Nieuwenhuis <[email protected]>2023-12-14 16:19:32 +0100
commitd81395fab3c4e336650b0481790ecdab7d7aa13f (patch)
tree449a894b8564dde713fff1e83cd717d263327b96 /embassy-rp
parent2c3d3992200939f71708c8b47d839328dcb12098 (diff)
Update embedded-hal to 1.0.0-rc.3
Diffstat (limited to 'embassy-rp')
-rw-r--r--embassy-rp/Cargo.toml6
-rw-r--r--embassy-rp/src/gpio.rs101
2 files changed, 61 insertions, 46 deletions
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml
index dfdd1fee9..c557940b1 100644
--- a/embassy-rp/Cargo.toml
+++ b/embassy-rp/Cargo.toml
@@ -78,9 +78,9 @@ fixed = "1.23.1"
78rp-pac = { version = "6" } 78rp-pac = { version = "6" }
79 79
80embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } 80embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
81embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } 81embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" }
82embedded-hal-async = { version = "=1.0.0-rc.2" } 82embedded-hal-async = { version = "=1.0.0-rc.3" }
83embedded-hal-nb = { version = "=1.0.0-rc.2" } 83embedded-hal-nb = { version = "=1.0.0-rc.3" }
84 84
85pio-proc = {version= "0.2" } 85pio-proc = {version= "0.2" }
86pio = {version= "0.2.1" } 86pio = {version= "0.2.1" }
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs
index 9034f3f36..23273e627 100644
--- a/embassy-rp/src/gpio.rs
+++ b/embassy-rp/src/gpio.rs
@@ -105,18 +105,18 @@ impl<'d, T: Pin> Input<'d, T> {
105 } 105 }
106 106
107 #[inline] 107 #[inline]
108 pub fn is_high(&self) -> bool { 108 pub fn is_high(&mut self) -> bool {
109 self.pin.is_high() 109 self.pin.is_high()
110 } 110 }
111 111
112 #[inline] 112 #[inline]
113 pub fn is_low(&self) -> bool { 113 pub fn is_low(&mut self) -> bool {
114 self.pin.is_low() 114 self.pin.is_low()
115 } 115 }
116 116
117 /// Returns current pin level 117 /// Returns current pin level
118 #[inline] 118 #[inline]
119 pub fn get_level(&self) -> Level { 119 pub fn get_level(&mut self) -> Level {
120 self.pin.get_level() 120 self.pin.get_level()
121 } 121 }
122 122
@@ -357,19 +357,19 @@ impl<'d, T: Pin> Output<'d, T> {
357 357
358 /// Is the output pin set as high? 358 /// Is the output pin set as high?
359 #[inline] 359 #[inline]
360 pub fn is_set_high(&self) -> bool { 360 pub fn is_set_high(&mut self) -> bool {
361 self.pin.is_set_high() 361 self.pin.is_set_high()
362 } 362 }
363 363
364 /// Is the output pin set as low? 364 /// Is the output pin set as low?
365 #[inline] 365 #[inline]
366 pub fn is_set_low(&self) -> bool { 366 pub fn is_set_low(&mut self) -> bool {
367 self.pin.is_set_low() 367 self.pin.is_set_low()
368 } 368 }
369 369
370 /// What level output is set to 370 /// What level output is set to
371 #[inline] 371 #[inline]
372 pub fn get_output_level(&self) -> Level { 372 pub fn get_output_level(&mut self) -> Level {
373 self.pin.get_output_level() 373 self.pin.get_output_level()
374 } 374 }
375 375
@@ -434,19 +434,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
434 434
435 /// Is the output level high? 435 /// Is the output level high?
436 #[inline] 436 #[inline]
437 pub fn is_set_high(&self) -> bool { 437 pub fn is_set_high(&mut self) -> bool {
438 !self.is_set_low() 438 !self.is_set_low()
439 } 439 }
440 440
441 /// Is the output level low? 441 /// Is the output level low?
442 #[inline] 442 #[inline]
443 pub fn is_set_low(&self) -> bool { 443 pub fn is_set_low(&mut self) -> bool {
444 self.pin.is_set_as_output() 444 self.pin.is_set_as_output()
445 } 445 }
446 446
447 /// What level output is set to 447 /// What level output is set to
448 #[inline] 448 #[inline]
449 pub fn get_output_level(&self) -> Level { 449 pub fn get_output_level(&mut self) -> Level {
450 self.is_set_high().into() 450 self.is_set_high().into()
451 } 451 }
452 452
@@ -457,18 +457,18 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
457 } 457 }
458 458
459 #[inline] 459 #[inline]
460 pub fn is_high(&self) -> bool { 460 pub fn is_high(&mut self) -> bool {
461 self.pin.is_high() 461 self.pin.is_high()
462 } 462 }
463 463
464 #[inline] 464 #[inline]
465 pub fn is_low(&self) -> bool { 465 pub fn is_low(&mut self) -> bool {
466 self.pin.is_low() 466 self.pin.is_low()
467 } 467 }
468 468
469 /// Returns current pin level 469 /// Returns current pin level
470 #[inline] 470 #[inline]
471 pub fn get_level(&self) -> Level { 471 pub fn get_level(&mut self) -> Level {
472 self.is_high().into() 472 self.is_high().into()
473 } 473 }
474 474
@@ -590,7 +590,12 @@ impl<'d, T: Pin> Flex<'d, T> {
590 } 590 }
591 591
592 #[inline] 592 #[inline]
593 fn is_set_as_output(&self) -> bool { 593 pub fn is_set_as_output(&mut self) -> bool {
594 self.ref_is_set_as_output()
595 }
596
597 #[inline]
598 pub(crate) fn ref_is_set_as_output(&self) -> bool {
594 (self.pin.sio_oe().value().read() & self.bit()) != 0 599 (self.pin.sio_oe().value().read() & self.bit()) != 0
595 } 600 }
596 601
@@ -600,18 +605,23 @@ impl<'d, T: Pin> Flex<'d, T> {
600 } 605 }
601 606
602 #[inline] 607 #[inline]
603 pub fn is_high(&self) -> bool { 608 pub fn is_high(&mut self) -> bool {
604 !self.is_low() 609 !self.is_low()
605 } 610 }
606 611
607 #[inline] 612 #[inline]
608 pub fn is_low(&self) -> bool { 613 pub fn is_low(&mut self) -> bool {
614 self.ref_is_low()
615 }
616
617 #[inline]
618 pub(crate) fn ref_is_low(&self) -> bool {
609 self.pin.sio_in().read() & self.bit() == 0 619 self.pin.sio_in().read() & self.bit() == 0
610 } 620 }
611 621
612 /// Returns current pin level 622 /// Returns current pin level
613 #[inline] 623 #[inline]
614 pub fn get_level(&self) -> Level { 624 pub fn get_level(&mut self) -> Level {
615 self.is_high().into() 625 self.is_high().into()
616 } 626 }
617 627
@@ -638,19 +648,24 @@ impl<'d, T: Pin> Flex<'d, T> {
638 648
639 /// Is the output level high? 649 /// Is the output level high?
640 #[inline] 650 #[inline]
641 pub fn is_set_high(&self) -> bool { 651 pub fn is_set_high(&mut self) -> bool {
642 !self.is_set_low() 652 !self.is_set_low()
643 } 653 }
644 654
645 /// Is the output level low? 655 /// Is the output level low?
646 #[inline] 656 #[inline]
647 pub fn is_set_low(&self) -> bool { 657 pub fn is_set_low(&mut self) -> bool {
658 self.ref_is_set_low()
659 }
660
661 #[inline]
662 pub(crate) fn ref_is_set_low(&self) -> bool {
648 (self.pin.sio_out().value().read() & self.bit()) == 0 663 (self.pin.sio_out().value().read() & self.bit()) == 0
649 } 664 }
650 665
651 /// What level output is set to 666 /// What level output is set to
652 #[inline] 667 #[inline]
653 pub fn get_output_level(&self) -> Level { 668 pub fn get_output_level(&mut self) -> Level {
654 self.is_set_high().into() 669 self.is_set_high().into()
655 } 670 }
656 671
@@ -912,11 +927,11 @@ mod eh02 {
912 type Error = Infallible; 927 type Error = Infallible;
913 928
914 fn is_high(&self) -> Result<bool, Self::Error> { 929 fn is_high(&self) -> Result<bool, Self::Error> {
915 Ok(self.is_high()) 930 Ok(!self.pin.ref_is_low())
916 } 931 }
917 932
918 fn is_low(&self) -> Result<bool, Self::Error> { 933 fn is_low(&self) -> Result<bool, Self::Error> {
919 Ok(self.is_low()) 934 Ok(self.pin.ref_is_low())
920 } 935 }
921 } 936 }
922 937
@@ -934,11 +949,11 @@ mod eh02 {
934 949
935 impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { 950 impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
936 fn is_set_high(&self) -> Result<bool, Self::Error> { 951 fn is_set_high(&self) -> Result<bool, Self::Error> {
937 Ok(self.is_set_high()) 952 Ok(!self.pin.ref_is_set_low())
938 } 953 }
939 954
940 fn is_set_low(&self) -> Result<bool, Self::Error> { 955 fn is_set_low(&self) -> Result<bool, Self::Error> {
941 Ok(self.is_set_low()) 956 Ok(self.pin.ref_is_set_low())
942 } 957 }
943 } 958 }
944 959
@@ -954,11 +969,11 @@ mod eh02 {
954 type Error = Infallible; 969 type Error = Infallible;
955 970
956 fn is_high(&self) -> Result<bool, Self::Error> { 971 fn is_high(&self) -> Result<bool, Self::Error> {
957 Ok(self.is_high()) 972 Ok(!self.pin.ref_is_low())
958 } 973 }
959 974
960 fn is_low(&self) -> Result<bool, Self::Error> { 975 fn is_low(&self) -> Result<bool, Self::Error> {
961 Ok(self.is_low()) 976 Ok(self.pin.ref_is_low())
962 } 977 }
963 } 978 }
964 979
@@ -978,11 +993,11 @@ mod eh02 {
978 993
979 impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { 994 impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> {
980 fn is_set_high(&self) -> Result<bool, Self::Error> { 995 fn is_set_high(&self) -> Result<bool, Self::Error> {
981 Ok(self.is_set_high()) 996 Ok(!self.pin.ref_is_set_as_output())
982 } 997 }
983 998
984 fn is_set_low(&self) -> Result<bool, Self::Error> { 999 fn is_set_low(&self) -> Result<bool, Self::Error> {
985 Ok(self.is_set_low()) 1000 Ok(self.pin.ref_is_set_as_output())
986 } 1001 }
987 } 1002 }
988 1003
@@ -998,11 +1013,11 @@ mod eh02 {
998 type Error = Infallible; 1013 type Error = Infallible;
999 1014
1000 fn is_high(&self) -> Result<bool, Self::Error> { 1015 fn is_high(&self) -> Result<bool, Self::Error> {
1001 Ok(self.is_high()) 1016 Ok(!self.ref_is_low())
1002 } 1017 }
1003 1018
1004 fn is_low(&self) -> Result<bool, Self::Error> { 1019 fn is_low(&self) -> Result<bool, Self::Error> {
1005 Ok(self.is_low()) 1020 Ok(self.ref_is_low())
1006 } 1021 }
1007 } 1022 }
1008 1023
@@ -1020,11 +1035,11 @@ mod eh02 {
1020 1035
1021 impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { 1036 impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
1022 fn is_set_high(&self) -> Result<bool, Self::Error> { 1037 fn is_set_high(&self) -> Result<bool, Self::Error> {
1023 Ok(self.is_set_high()) 1038 Ok(!self.ref_is_set_low())
1024 } 1039 }
1025 1040
1026 fn is_set_low(&self) -> Result<bool, Self::Error> { 1041 fn is_set_low(&self) -> Result<bool, Self::Error> {
1027 Ok(self.is_set_low()) 1042 Ok(self.ref_is_set_low())
1028 } 1043 }
1029 } 1044 }
1030 1045
@@ -1042,11 +1057,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
1042} 1057}
1043 1058
1044impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { 1059impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
1045 fn is_high(&self) -> Result<bool, Self::Error> { 1060 fn is_high(&mut self) -> Result<bool, Self::Error> {
1046 Ok(self.is_high()) 1061 Ok(self.is_high())
1047 } 1062 }
1048 1063
1049 fn is_low(&self) -> Result<bool, Self::Error> { 1064 fn is_low(&mut self) -> Result<bool, Self::Error> {
1050 Ok(self.is_low()) 1065 Ok(self.is_low())
1051 } 1066 }
1052} 1067}
@@ -1066,11 +1081,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
1066} 1081}
1067 1082
1068impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { 1083impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
1069 fn is_set_high(&self) -> Result<bool, Self::Error> { 1084 fn is_set_high(&mut self) -> Result<bool, Self::Error> {
1070 Ok(self.is_set_high()) 1085 Ok(self.is_set_high())
1071 } 1086 }
1072 1087
1073 fn is_set_low(&self) -> Result<bool, Self::Error> { 1088 fn is_set_low(&mut self) -> Result<bool, Self::Error> {
1074 Ok(self.is_set_low()) 1089 Ok(self.is_set_low())
1075 } 1090 }
1076} 1091}
@@ -1096,11 +1111,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> {
1096} 1111}
1097 1112
1098impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { 1113impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> {
1099 fn is_set_high(&self) -> Result<bool, Self::Error> { 1114 fn is_set_high(&mut self) -> Result<bool, Self::Error> {
1100 Ok(self.is_set_high()) 1115 Ok(self.is_set_high())
1101 } 1116 }
1102 1117
1103 fn is_set_low(&self) -> Result<bool, Self::Error> { 1118 fn is_set_low(&mut self) -> Result<bool, Self::Error> {
1104 Ok(self.is_set_low()) 1119 Ok(self.is_set_low())
1105 } 1120 }
1106} 1121}
@@ -1112,11 +1127,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for OutputOpenDrai
1112} 1127}
1113 1128
1114impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { 1129impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
1115 fn is_high(&self) -> Result<bool, Self::Error> { 1130 fn is_high(&mut self) -> Result<bool, Self::Error> {
1116 Ok(self.is_high()) 1131 Ok(self.is_high())
1117 } 1132 }
1118 1133
1119 fn is_low(&self) -> Result<bool, Self::Error> { 1134 fn is_low(&mut self) -> Result<bool, Self::Error> {
1120 Ok(self.is_low()) 1135 Ok(self.is_low())
1121 } 1136 }
1122} 1137}
@@ -1126,11 +1141,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> {
1126} 1141}
1127 1142
1128impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { 1143impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
1129 fn is_high(&self) -> Result<bool, Self::Error> { 1144 fn is_high(&mut self) -> Result<bool, Self::Error> {
1130 Ok(self.is_high()) 1145 Ok(self.is_high())
1131 } 1146 }
1132 1147
1133 fn is_low(&self) -> Result<bool, Self::Error> { 1148 fn is_low(&mut self) -> Result<bool, Self::Error> {
1134 Ok(self.is_low()) 1149 Ok(self.is_low())
1135 } 1150 }
1136} 1151}
@@ -1146,11 +1161,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
1146} 1161}
1147 1162
1148impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { 1163impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
1149 fn is_set_high(&self) -> Result<bool, Self::Error> { 1164 fn is_set_high(&mut self) -> Result<bool, Self::Error> {
1150 Ok(self.is_set_high()) 1165 Ok(self.is_set_high())
1151 } 1166 }
1152 1167
1153 fn is_set_low(&self) -> Result<bool, Self::Error> { 1168 fn is_set_low(&mut self) -> Result<bool, Self::Error> {
1154 Ok(self.is_set_low()) 1169 Ok(self.is_set_low())
1155 } 1170 }
1156} 1171}