Skip to content

Commit

Permalink
Implement support for XipCS1 pin function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Altaflux committed Nov 13, 2024
1 parent e87e2ac commit d8ffef4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rp235x-hal/src/gpio/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions rp235x-hal/src/gpio/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ pub(crate) fn set_function<P: PinId>(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,
Expand Down

0 comments on commit d8ffef4

Please sign in to comment.