mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-23 09:46:33 +11:00
Do reset in a good way instead of a wacky way
This commit is contained in:
parent
b3b7677f82
commit
7e45c96a65
1 changed files with 2 additions and 9 deletions
|
@ -89,7 +89,6 @@ macro_rules! gpio {
|
||||||
use core::convert::Infallible;
|
use core::convert::Infallible;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin};
|
use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin};
|
||||||
use pac::generic::ResetValue;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
impl GpioExt<pac::$PADSX, pac::SIO> for pac::$GPIOX {
|
impl GpioExt<pac::$PADSX, pac::SIO> for pac::$GPIOX {
|
||||||
|
@ -120,12 +119,6 @@ macro_rules! gpio {
|
||||||
)+
|
)+
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset_pad(pads: &pac::$padsx::RegisterBlock, index: usize) {
|
|
||||||
let reset_value: u32 = pac::$padsx::GPIO::reset_value();
|
|
||||||
// This is safe, we get the value we're setting directly from the PAC
|
|
||||||
pads.gpio[index].write(|w| unsafe { w.bits(reset_value) });
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_gpio_function(gpios: &pac::$gpiox::RegisterBlock, index: usize, function: GpioFunction) {
|
fn set_gpio_function(gpios: &pac::$gpiox::RegisterBlock, index: usize, function: GpioFunction) {
|
||||||
gpios.gpio[index]
|
gpios.gpio[index]
|
||||||
.gpio_ctrl
|
.gpio_ctrl
|
||||||
|
@ -152,7 +145,7 @@ macro_rules! gpio {
|
||||||
self,
|
self,
|
||||||
) -> $PXi<Output> {
|
) -> $PXi<Output> {
|
||||||
unsafe {
|
unsafe {
|
||||||
reset_pad(&*pac::$PADSX::ptr(), $i);
|
(*pac::$PADSX::ptr()).gpio[$i].reset();
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
set_gpio_function(&*pac::$GPIOX::ptr(), $i, GpioFunction::Sio);
|
set_gpio_function(&*pac::$GPIOX::ptr(), $i, GpioFunction::Sio);
|
||||||
|
@ -168,7 +161,7 @@ macro_rules! gpio {
|
||||||
self,
|
self,
|
||||||
) -> $PXi<Input> {
|
) -> $PXi<Input> {
|
||||||
unsafe {
|
unsafe {
|
||||||
reset_pad(&*pac::$PADSX::ptr(), $i);
|
(*pac::$PADSX::ptr()).gpio[$i].reset();
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
set_gpio_function(&*pac::$GPIOX::ptr(), $i, GpioFunction::Sio);
|
set_gpio_function(&*pac::$GPIOX::ptr(), $i, GpioFunction::Sio);
|
||||||
|
|
Loading…
Add table
Reference in a new issue