Skip to content

Commit 9236f4a

Browse files
committed
Update to use pinctrl module.
1 parent 2733303 commit 9236f4a

File tree

6 files changed

+1907
-86
lines changed

6 files changed

+1907
-86
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ embedded-io = "0.6.1"
3030
fugit = "0.3.7"
3131
proposed-traits = { git = "https://github.com/rusty1968/proposed_traits.git", package = "proposed-traits", rev = "85641310df5a5276c67f81621b104322cff0286c" }
3232
hex-literal = "0.4"
33+
paste = "1.0"
3334

3435
cortex-m = { version = "0.7.5" }
3536
cortex-m-rt = { version = "0.6.5", features = ["device"] }

src/gpio.rs

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
//! GPIO pins
44
5-
use ast1060_pac::{Gpio, Scu};
5+
use ast1060_pac::Gpio;
66
use core::marker::PhantomData;
77
use embedded_hal::digital::{InputPin, OutputPin, StatefulOutputPin};
88

@@ -197,91 +197,9 @@ macro_rules! gpio_macro {
197197
}
198198

199199
impl<MODE> $PXi<MODE> {
200-
pub fn set_up_multifunc_pin_ctrl(self) {
201-
let p = unsafe{ &*Scu::ptr() };
202-
match $x {
203-
'a' | 'b' | 'c' | 'd' => {
204-
p.scu410().modify(|r, w| unsafe {
205-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
206-
});
207-
p.scu4b0().modify(|r, w| unsafe {
208-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
209-
});
210-
p.scu690().modify(|r, w| unsafe {
211-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
212-
});
213-
},
214-
'e' | 'f' | 'g' | 'h' => {
215-
p.scu414().modify(|r, w| unsafe {
216-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
217-
});
218-
if $x != 'h' || $i < 6 {
219-
p.scu4b4().modify(|r, w| unsafe {
220-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
221-
});
222-
p.scu694().modify(|r, w| unsafe {
223-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
224-
});
225-
}
226-
},
227-
'i' | 'j' | 'k' | 'l' => {
228-
p.scu418().modify(|r, w| unsafe {
229-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
230-
});
231-
if $x == 'j' || $x == 'k' || ($x == 'l' && $i > 3) {
232-
p.scu4b8().modify(|r, w| unsafe {
233-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
234-
});
235-
}
236-
if $x == 'l' && $i > 3 {
237-
p.scu698().modify(|r, w| unsafe {
238-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
239-
});
240-
}
241-
},
242-
'm' | 'n' | 'o' | 'p' => {
243-
p.scu41c().modify(|r, w| unsafe {
244-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
245-
});
246-
if ($x == 'n' && $i != 2) || $x == 'o' || $x == 'p' {
247-
p.scu4bc().modify(|r, w| unsafe {
248-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
249-
});
250-
}
251-
if ($x == 'o' && $i > 3) || ($x == 'p' && ($i == 0 || $i > 5)) {
252-
p.scu69c().modify(|r, w| unsafe {
253-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
254-
});
255-
}
256-
},
257-
'q' | 'r' | 's' => {
258-
p.scu430().modify(|r, w| unsafe {
259-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
260-
});
261-
if $x == 'q' && $i < 5 {
262-
p.scu6b0().modify(|r, w| unsafe {
263-
w.bits(r.bits() & !(1u32 << ($pos + $i)))
264-
});
265-
}
266-
},
267-
't' => {
268-
p.scu430().modify(|r, w| unsafe {
269-
w.bits(r.bits() | (1u32 << ($pos + $i)))
270-
});
271-
},
272-
'u' => {
273-
p.scu434().modify(|r, w| unsafe {
274-
w.bits(r.bits() | (1u32 << ($pos + $i)))
275-
});
276-
},
277-
_ => {},
278-
}
279-
}
280-
281200
/// Configures the pin to operate as a pulled down input pin
282201
#[must_use]
283202
pub fn into_pull_down_input(self) -> $PXi<Input<PullDown>> {
284-
self.set_up_multifunc_pin_ctrl();
285203
let p = unsafe{ &*Gpio::ptr() };
286204
//dir
287205
p.$dir_reg().modify(|r, w| unsafe {
@@ -297,7 +215,6 @@ macro_rules! gpio_macro {
297215
/// Configures the pin to operate as a pulled up input pin
298216
#[must_use]
299217
pub fn into_pull_up_input(self) -> $PXi<Input<PullUp>> {
300-
self.set_up_multifunc_pin_ctrl();
301218
let p = unsafe{ &*Gpio::ptr() };
302219
//dir
303220
p.$dir_reg().modify(|r, w| unsafe {
@@ -313,7 +230,6 @@ macro_rules! gpio_macro {
313230
/// Configures the pin to operate as an open drain output pin
314231
#[must_use]
315232
pub fn into_open_drain_output<ODM>(self) -> $PXi<Output<OpenDrain<ODM>>> where ODM:OpenDrainMode {
316-
self.set_up_multifunc_pin_ctrl();
317233
let p = unsafe { &*Gpio::ptr()};
318234
//data
319235
// 0 for active low; 1 for active high??
@@ -330,7 +246,6 @@ macro_rules! gpio_macro {
330246
/// Configures the pin to operate as an push pull output pin
331247
#[must_use]
332248
pub fn into_push_pull_output(self) -> $PXi<Output<PushPull>> {
333-
self.set_up_multifunc_pin_ctrl();
334249
let p = unsafe { &*Gpio::ptr()};
335250
//dir
336251
p.$dir_reg().modify(|r, w| unsafe {

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub mod gpio;
66
pub mod hace_controller;
77
pub mod hash;
88
pub mod hmac;
9+
pub mod pinctrl;
910
pub mod rsa;
1011
pub mod syscon;
1112
pub mod tests;

0 commit comments

Comments
 (0)