diff options
Diffstat (limited to 'embassy-mspm0/src/gpio.rs')
| -rw-r--r-- | embassy-mspm0/src/gpio.rs | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/embassy-mspm0/src/gpio.rs b/embassy-mspm0/src/gpio.rs index d5fd36dbf..709102c59 100644 --- a/embassy-mspm0/src/gpio.rs +++ b/embassy-mspm0/src/gpio.rs | |||
| @@ -5,12 +5,12 @@ use core::future::Future; | |||
| 5 | use core::pin::Pin as FuturePin; | 5 | use core::pin::Pin as FuturePin; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::pac::gpio::vals::*; | 11 | use crate::pac::gpio::vals::*; |
| 12 | use crate::pac::gpio::{self}; | 12 | use crate::pac::gpio::{self}; |
| 13 | #[cfg(all(feature = "rt", any(mspm0c110x, mspm0c1105_c1106, mspm0l110x)))] | 13 | #[cfg(all(feature = "rt", any(gpioa_interrupt, gpiob_interrupt)))] |
| 14 | use crate::pac::interrupt; | 14 | use crate::pac::interrupt; |
| 15 | use crate::pac::{self}; | 15 | use crate::pac::{self}; |
| 16 | 16 | ||
| @@ -156,7 +156,12 @@ impl<'d> Flex<'d> { | |||
| 156 | w.set_pf(GPIO_PF); | 156 | w.set_pf(GPIO_PF); |
| 157 | w.set_hiz1(true); | 157 | w.set_hiz1(true); |
| 158 | w.set_pc(true); | 158 | w.set_pc(true); |
| 159 | w.set_inena(false); | 159 | w.set_inena(true); |
| 160 | }); | ||
| 161 | |||
| 162 | // Enable output driver (DOE) - required for open-drain to drive low | ||
| 163 | self.pin.block().doeset31_0().write(|w| { | ||
| 164 | w.set_dio(self.pin.bit_index(), true); | ||
| 160 | }); | 165 | }); |
| 161 | 166 | ||
| 162 | self.set_pull(Pull::None); | 167 | self.set_pull(Pull::None); |
| @@ -836,6 +841,7 @@ impl<'d> embedded_hal_async::digital::Wait for OutputOpenDrain<'d> { | |||
| 836 | } | 841 | } |
| 837 | } | 842 | } |
| 838 | 843 | ||
| 844 | #[cfg_attr(mspm0g518x, allow(dead_code))] | ||
| 839 | #[derive(Copy, Clone)] | 845 | #[derive(Copy, Clone)] |
| 840 | pub struct PfType { | 846 | pub struct PfType { |
| 841 | pull: Pull, | 847 | pull: Pull, |
| @@ -943,6 +949,7 @@ pub(crate) trait SealedPin { | |||
| 943 | }); | 949 | }); |
| 944 | } | 950 | } |
| 945 | 951 | ||
| 952 | #[cfg_attr(mspm0g518x, allow(dead_code))] | ||
| 946 | fn update_pf(&self, ty: PfType) { | 953 | fn update_pf(&self, ty: PfType) { |
| 947 | let pincm = pac::IOMUX.pincm(self._pin_cm() as usize); | 954 | let pincm = pac::IOMUX.pincm(self._pin_cm() as usize); |
| 948 | let pf = pincm.read().pf(); | 955 | let pf = pincm.read().pf(); |
| @@ -950,6 +957,7 @@ pub(crate) trait SealedPin { | |||
| 950 | set_pf(self._pin_cm() as usize, pf, ty); | 957 | set_pf(self._pin_cm() as usize, pf, ty); |
| 951 | } | 958 | } |
| 952 | 959 | ||
| 960 | #[cfg_attr(mspm0g518x, allow(dead_code))] | ||
| 953 | fn set_as_pf(&self, pf: u8, ty: PfType) { | 961 | fn set_as_pf(&self, pf: u8, ty: PfType) { |
| 954 | set_pf(self._pin_cm() as usize, pf, ty) | 962 | set_pf(self._pin_cm() as usize, pf, ty) |
| 955 | } | 963 | } |
| @@ -962,6 +970,7 @@ pub(crate) trait SealedPin { | |||
| 962 | /// | 970 | /// |
| 963 | /// Note that this also disables the internal weak pull-up and pull-down resistors. | 971 | /// Note that this also disables the internal weak pull-up and pull-down resistors. |
| 964 | #[inline] | 972 | #[inline] |
| 973 | #[cfg_attr(mspm0g518x, allow(dead_code))] | ||
| 965 | fn set_as_disconnected(&self) { | 974 | fn set_as_disconnected(&self) { |
| 966 | self.set_as_analog(); | 975 | self.set_as_analog(); |
| 967 | } | 976 | } |
| @@ -1105,16 +1114,21 @@ fn irq_handler(gpio: gpio::Gpio, wakers: &[AtomicWaker; 32]) { | |||
| 1105 | } | 1114 | } |
| 1106 | } | 1115 | } |
| 1107 | 1116 | ||
| 1117 | #[cfg(all(gpioa_interrupt, gpioa_group))] | ||
| 1118 | compile_error!("gpioa_interrupt and gpioa_group are mutually exclusive cfgs"); | ||
| 1119 | #[cfg(all(gpiob_interrupt, gpiob_group))] | ||
| 1120 | compile_error!("gpiob_interrupt and gpiob_group are mutually exclusive cfgs"); | ||
| 1121 | |||
| 1108 | // C110x and L110x have a dedicated interrupts just for GPIOA. | 1122 | // C110x and L110x have a dedicated interrupts just for GPIOA. |
| 1109 | // | 1123 | // |
| 1110 | // These chips do not have a GROUP1 interrupt. | 1124 | // These chips do not have a GROUP1 interrupt. |
| 1111 | #[cfg(all(feature = "rt", any(mspm0c110x, mspm0c1105_c1106, mspm0l110x)))] | 1125 | #[cfg(all(feature = "rt", gpioa_interrupt))] |
| 1112 | #[interrupt] | 1126 | #[interrupt] |
| 1113 | fn GPIOA() { | 1127 | fn GPIOA() { |
| 1114 | irq_handler(pac::GPIOA, &PORTA_WAKERS); | 1128 | irq_handler(pac::GPIOA, &PORTA_WAKERS); |
| 1115 | } | 1129 | } |
| 1116 | 1130 | ||
| 1117 | #[cfg(all(feature = "rt", mspm0c1105_c1106))] | 1131 | #[cfg(all(feature = "rt", gpiob_interrupt))] |
| 1118 | #[interrupt] | 1132 | #[interrupt] |
| 1119 | fn GPIOB() { | 1133 | fn GPIOB() { |
| 1120 | irq_handler(pac::GPIOB, &PORTB_WAKERS); | 1134 | irq_handler(pac::GPIOB, &PORTB_WAKERS); |
| @@ -1124,23 +1138,23 @@ fn GPIOB() { | |||
| 1124 | // | 1138 | // |
| 1125 | // Defining these as no_mangle is required so that the linker will pick these over the default handler. | 1139 | // Defining these as no_mangle is required so that the linker will pick these over the default handler. |
| 1126 | 1140 | ||
| 1127 | #[cfg(all(feature = "rt", not(any(mspm0c110x, mspm0c1105_c1106, mspm0l110x))))] | 1141 | #[cfg(all(feature = "rt", gpioa_group))] |
| 1128 | #[no_mangle] | 1142 | #[unsafe(no_mangle)] |
| 1129 | #[allow(non_snake_case)] | 1143 | #[allow(non_snake_case)] |
| 1130 | fn GPIOA() { | 1144 | fn GPIOA() { |
| 1131 | irq_handler(pac::GPIOA, &PORTA_WAKERS); | 1145 | irq_handler(pac::GPIOA, &PORTA_WAKERS); |
| 1132 | } | 1146 | } |
| 1133 | 1147 | ||
| 1134 | #[cfg(all(feature = "rt", gpio_pb, not(mspm0c1105_c1106)))] | 1148 | #[cfg(all(feature = "rt", gpiob_group))] |
| 1135 | #[no_mangle] | 1149 | #[unsafe(no_mangle)] |
| 1136 | #[allow(non_snake_case)] | 1150 | #[allow(non_snake_case)] |
| 1137 | fn GPIOB() { | 1151 | fn GPIOB() { |
| 1138 | irq_handler(pac::GPIOB, &PORTB_WAKERS); | 1152 | irq_handler(pac::GPIOB, &PORTB_WAKERS); |
| 1139 | } | 1153 | } |
| 1140 | 1154 | ||
| 1141 | #[cfg(all(feature = "rt", gpio_pc))] | 1155 | #[cfg(all(feature = "rt", gpioc_group))] |
| 1142 | #[allow(non_snake_case)] | 1156 | #[allow(non_snake_case)] |
| 1143 | #[no_mangle] | 1157 | #[unsafe(no_mangle)] |
| 1144 | fn GPIOC() { | 1158 | fn GPIOC() { |
| 1145 | irq_handler(pac::GPIOC, &PORTC_WAKERS); | 1159 | irq_handler(pac::GPIOC, &PORTC_WAKERS); |
| 1146 | } | 1160 | } |
