From d8ffef47a2b9936f2a190638e4fd19f3686e9abe Mon Sep 17 00:00:00 2001 From: Pablo Lozano <4032486+Altaflux@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:10:04 -0800 Subject: [PATCH] Implement support for XipCS1 pin function. --- rp235x-hal/src/gpio/func.rs | 6 +++++- rp235x-hal/src/gpio/pin.rs | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rp235x-hal/src/gpio/func.rs b/rp235x-hal/src/gpio/func.rs index 21bab59ee..fd807ad91 100644 --- a/rp235x-hal/src/gpio/func.rs +++ b/rp235x-hal/src/gpio/func.rs @@ -48,6 +48,8 @@ pub enum DynFunction { /// The 'Clock' function. This can be used to input or output clock references to or from the /// rp235x. Clock, + /// The XIP CS1 function. + XipCs1, /// The 'USB' function. Only VBUS detect, VBUS enable and overcurrent detect are configurable. /// Other USB io have dedicated pins. Usb, @@ -105,7 +107,7 @@ macro_rules! pin_func { })* }; } -pin_func!(Xip, Spi, Uart, I2c as I2C, Pwm, Pio0, Pio1, Pio2, Clock, Usb, UartAux, Null); +pin_func!(Xip, Spi, Uart, I2c as I2C, Pwm, Pio0, Pio1, Pio2, Clock, XipCs1, Usb, UartAux, Null); //============================================================================== // SIO sub-types @@ -169,6 +171,7 @@ impl DynFunction { let dyn_pin = id.as_dyn(); match (self, dyn_pin.bank, dyn_pin.num) { (Xip, Bank0, _) => false, + (XipCs1, Bank0, 0 | 8 | 19 | 47) => true, (Clock, _, 0..=19 | 26..=29) => false, (UartAux, _, n) if (n & 0x02) == 0 => false, (_, Bank0, 0..=29) => true, @@ -205,6 +208,7 @@ pin_valid_func!( [2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27] ); pin_valid_func!(bank0 as Gpio, [Clock], [20, 21, 22, 23, 24, 25]); +pin_valid_func!(bank0 as Gpio, [XipCs1], [0, 8, 19, 47]); pin_valid_func!(qspi as Qspi, [Xip, Null], [Sclk, Sd0, Sd1, Sd2, Sd3, Ss]); macro_rules! pin_valid_func_sio { diff --git a/rp235x-hal/src/gpio/pin.rs b/rp235x-hal/src/gpio/pin.rs index 20db6d46e..ef4aa6b2a 100644 --- a/rp235x-hal/src/gpio/pin.rs +++ b/rp235x-hal/src/gpio/pin.rs @@ -168,6 +168,7 @@ pub(crate) fn set_function(pin: &P, function: DynFunction) { DynFunction::Pio1 => FUNCSEL_A::PIO1, DynFunction::Pio2 => FUNCSEL_A::PIO2, DynFunction::Clock => FUNCSEL_A::GPCK, + DynFunction::XipCs1 => FUNCSEL_A::GPCK, DynFunction::Usb => FUNCSEL_A::USB, DynFunction::UartAux => FUNCSEL_A::UART_AUX, DynFunction::Null => FUNCSEL_A::NULL,