split pin numbers from pin setting

this allows us to probe pins/clone them without having to re-allocate
them.
This commit is contained in:
bunnie 2025-02-23 16:53:28 +08:00
parent 20f96f189a
commit b7ef119a04

View file

@ -40,15 +40,20 @@ pub const CRG_UDC_MEMBASE: usize =
pub const IFRAM0_RESERVED_PAGE_RANGE: [usize; 2] = [31 - 9, 31]; pub const IFRAM0_RESERVED_PAGE_RANGE: [usize; 2] = [31 - 9, 31];
pub const IFRAM1_RESERVED_PAGE_RANGE: [usize; 2] = [31 - CAM_IFRAM_LEN_PAGES, 31]; pub const IFRAM1_RESERVED_PAGE_RANGE: [usize; 2] = [31 - CAM_IFRAM_LEN_PAGES, 31];
// Display pins
const SPI_CS_PIN: u8 = 3;
const SPI_CLK_PIN: u8 = 0;
const SPI_DAT_PIN: u8 = 1;
const SPI_CD_PIN: u8 = 2;
const SPI_PORT: IoxPort = IoxPort::PC;
/// Returns just the pin mappings without setting anything up.
pub fn get_display_pins() -> (SpimChannel, IoxPort, u8, u8) {
(SpimChannel::Channel2, SPI_PORT, SPI_CD_PIN, SPI_CS_PIN)
}
/// Setup pins for the baosec display /// Setup pins for the baosec display
/// Returns a spi channel object and descriptor for the C/D + CS pins as a (port, c/d pin, cs pin) tuple /// Returns a spi channel object and descriptor for the C/D + CS pins as a (port, c/d pin, cs pin) tuple
pub fn setup_display_pins(iox: &dyn IoSetup) -> (SpimChannel, IoxPort, u8, u8) { pub fn setup_display_pins(iox: &dyn IoSetup) -> (SpimChannel, IoxPort, u8, u8) {
const SPI_CS_PIN: u8 = 3;
const SPI_CLK_PIN: u8 = 0;
const SPI_DAT_PIN: u8 = 1;
const SPI_CD_PIN: u8 = 2;
const SPI_PORT: IoxPort = IoxPort::PC;
// SPIM_CLK_B[2] // SPIM_CLK_B[2]
iox.setup_pin( iox.setup_pin(
SPI_PORT, SPI_PORT,
@ -94,7 +99,7 @@ pub fn setup_display_pins(iox: &dyn IoSetup) -> (SpimChannel, IoxPort, u8, u8) {
Some(IoxDriveStrength::Drive2mA), Some(IoxDriveStrength::Drive2mA),
); );
// using bank SPIM_B[2] // using bank SPIM_B[2]
(SpimChannel::Channel2, SPI_PORT, SPI_CD_PIN, SPI_CS_PIN) get_display_pins()
} }
pub fn setup_memory_pins(iox: &dyn IoSetup) -> SpimChannel { pub fn setup_memory_pins(iox: &dyn IoSetup) -> SpimChannel {