mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
consolidate spi pin setup
This commit is contained in:
parent
2e086f4152
commit
728fab3b62
2 changed files with 8 additions and 95 deletions
|
|
@ -43,10 +43,13 @@ cramium-soc = [
|
||||||
"cramium-hal",
|
"cramium-hal",
|
||||||
"cramium-hal/std",
|
"cramium-hal/std",
|
||||||
]
|
]
|
||||||
|
board-baosec = ["cramium-hal/board-baosec"]
|
||||||
|
board-baosor = ["cramium-hal/board-baosor"]
|
||||||
|
board-dabao = ["cramium-hal/board-dabao"]
|
||||||
|
|
||||||
precursor = ["utralib/precursor"]
|
precursor = ["utralib/precursor"]
|
||||||
hosted = ["utralib/hosted"]
|
hosted = ["utralib/hosted"]
|
||||||
renode = ["utralib/renode"]
|
renode = ["utralib/renode"]
|
||||||
spi-alt-channel = []
|
|
||||||
debugprint = []
|
debugprint = []
|
||||||
braille = []
|
braille = []
|
||||||
gfx-testing = []
|
gfx-testing = []
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,9 @@
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
|
|
||||||
use cram_hal_service::IoxHal;
|
use cram_hal_service::IoxHal;
|
||||||
|
use cramium_hal::board::setup_display_pins;
|
||||||
|
use cramium_hal::udma;
|
||||||
use cramium_hal::udma::PeriphId;
|
use cramium_hal::udma::PeriphId;
|
||||||
use cramium_hal::{iox, udma};
|
|
||||||
|
|
||||||
use crate::api::Point;
|
use crate::api::Point;
|
||||||
use crate::api::{LINES, WIDTH};
|
use crate::api::{LINES, WIDTH};
|
||||||
|
|
@ -104,99 +105,8 @@ impl XousDisplay {
|
||||||
|
|
||||||
// setup the I/O pins
|
// setup the I/O pins
|
||||||
let iox = IoxHal::new();
|
let iox = IoxHal::new();
|
||||||
#[cfg(feature = "spi-alt-channel")]
|
let channel = setup_display_pins(&iox);
|
||||||
let channel = {
|
udma_global.udma_clock_config(PeriphId::from(channel), true);
|
||||||
const SPI_CS_PIN: u8 = 10;
|
|
||||||
const SPI_CLK_PIN: u8 = 7;
|
|
||||||
const SPI_DAT_PIN: u8 = 8;
|
|
||||||
const SPI_PORT: iox::IoxPort = iox::IoxPort::PD;
|
|
||||||
|
|
||||||
// SPIM_CLK_B[1]
|
|
||||||
iox.setup_io_pin(
|
|
||||||
SPI_PORT,
|
|
||||||
SPI_CLK_PIN,
|
|
||||||
Some(iox::IoxDir::Output),
|
|
||||||
Some(iox::IoxFunction::AF2),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Some(iox::IoxEnable::Enable),
|
|
||||||
Some(iox::IoxDriveStrength::Drive2mA),
|
|
||||||
);
|
|
||||||
// SPIM_SD0_B[1]
|
|
||||||
iox.setup_io_pin(
|
|
||||||
SPI_PORT,
|
|
||||||
SPI_DAT_PIN,
|
|
||||||
Some(iox::IoxDir::Output),
|
|
||||||
Some(iox::IoxFunction::AF2),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Some(iox::IoxEnable::Enable),
|
|
||||||
Some(iox::IoxDriveStrength::Drive2mA),
|
|
||||||
);
|
|
||||||
// SPIM_SCSN0_B[1]
|
|
||||||
// chip select toggle by UDMA has ~6 cycles setup and 1 cycles hold time, which
|
|
||||||
// meets the requirements for the display.
|
|
||||||
iox.setup_io_pin(
|
|
||||||
SPI_PORT,
|
|
||||||
SPI_CS_PIN,
|
|
||||||
Some(iox::IoxDir::Output),
|
|
||||||
Some(iox::IoxFunction::AF2),
|
|
||||||
None,
|
|
||||||
Some(iox::IoxEnable::Enable),
|
|
||||||
Some(iox::IoxEnable::Enable),
|
|
||||||
Some(iox::IoxDriveStrength::Drive2mA),
|
|
||||||
);
|
|
||||||
// using bank SPIM_B[1]
|
|
||||||
udma_global.udma_clock_config(PeriphId::Spim1, true);
|
|
||||||
udma::SpimChannel::Channel1
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(not(feature = "spi-alt-channel"))]
|
|
||||||
let channel = {
|
|
||||||
const SPI_CS_PIN: u8 = 5;
|
|
||||||
const SPI_CLK_PIN: u8 = 4;
|
|
||||||
const SPI_DAT_PIN: u8 = 0;
|
|
||||||
const SPI_PORT: iox::IoxPort = iox::IoxPort::PD;
|
|
||||||
|
|
||||||
// SPIM_CLK_A[0]
|
|
||||||
iox.setup_io_pin(
|
|
||||||
SPI_PORT,
|
|
||||||
SPI_CLK_PIN,
|
|
||||||
Some(iox::IoxDir::Output),
|
|
||||||
Some(iox::IoxFunction::AF1),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Some(iox::IoxEnable::Enable),
|
|
||||||
Some(iox::IoxDriveStrength::Drive2mA),
|
|
||||||
);
|
|
||||||
// SPIM_SD0_A[0]
|
|
||||||
iox.setup_io_pin(
|
|
||||||
SPI_PORT,
|
|
||||||
SPI_DAT_PIN,
|
|
||||||
Some(iox::IoxDir::Output),
|
|
||||||
Some(iox::IoxFunction::AF1),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Some(iox::IoxEnable::Enable),
|
|
||||||
Some(iox::IoxDriveStrength::Drive2mA),
|
|
||||||
);
|
|
||||||
// SPIM_CSN0_A[0]
|
|
||||||
// chip select toggle by UDMA has ~6 cycles setup and 1 cycles hold time, which
|
|
||||||
// meets the requirements for the display.
|
|
||||||
iox.setup_io_pin(
|
|
||||||
SPI_PORT,
|
|
||||||
SPI_CS_PIN,
|
|
||||||
Some(iox::IoxDir::Output),
|
|
||||||
Some(iox::IoxFunction::AF1),
|
|
||||||
None,
|
|
||||||
Some(iox::IoxEnable::Enable),
|
|
||||||
Some(iox::IoxEnable::Enable),
|
|
||||||
Some(iox::IoxDriveStrength::Drive2mA),
|
|
||||||
);
|
|
||||||
// using bank SPIM_B[1]
|
|
||||||
udma_global.udma_clock_config(PeriphId::Spim0, true);
|
|
||||||
udma::SpimChannel::Channel0
|
|
||||||
};
|
|
||||||
|
|
||||||
log::info!("gfx using spi channel {:?}", channel);
|
log::info!("gfx using spi channel {:?}", channel);
|
||||||
// safety: this is safe because we remembered to set up the clock config; and,
|
// safety: this is safe because we remembered to set up the clock config; and,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue