mirror board constants from API; make SPIM channel a const

this implements the API/HAL split on the HAL side, and also
reveals SPIM channel as a constant that can be just read out
so that spim accessors that need to build from raw parts
can do it without having to re-allocate IOs.
This commit is contained in:
bunnie 2025-10-04 00:53:22 +08:00
parent 869da85ef7
commit 7f9b783027

View file

@ -7,13 +7,16 @@ pub const I2C_AXP2101_ADR: u8 = 0x34;
pub const I2C_TUSB320_ADR: u8 = 0x47;
pub const I2C_BQ27427_ADR: u8 = 0x55;
// location and organization of SPINOR should be board-specific
pub const SPINOR_PAGE_LEN: u32 = 0x100;
pub const SPINOR_ERASE_SIZE: u32 = 0x1000; // this is the smallest sector size.
pub const SPINOR_BULK_ERASE_SIZE: u32 = 0x1_0000; // this is the bulk erase size.
pub const SPINOR_LEN: u32 = 16384 * 1024;
pub const PDDB_LOC: u32 = 4096 * 1024; // located 4MiB in, after the swap image
pub const PDDB_LEN: u32 = 4096 * 1024; // 4MiB data for the PDDB total
// re-export these constants from the API crate
// the API crate has to list *all* offsets, not just those targeting the
// current build. This re-export allows us to have "generic" offsets
// independent of builds.
pub const SPINOR_PAGE_LEN: u32 = bao1x_api::offsets::baosec::SPINOR_PAGE_LEN;
pub const SPINOR_ERASE_SIZE: u32 = bao1x_api::offsets::baosec::SPINOR_ERASE_SIZE;
pub const SPINOR_BULK_ERASE_SIZE: u32 = bao1x_api::offsets::baosec::SPINOR_BULK_ERASE_SIZE;
pub const SPINOR_LEN: u32 = bao1x_api::offsets::baosec::SPI_FLASH_LEN as _;
pub const PDDB_LOC: u32 = bao1x_api::offsets::baosec::PDDB_ORIGIN as _;
pub const PDDB_LEN: u32 = bao1x_api::offsets::baosec::PDDB_LEN as _;
// Define the virtual region that memory-mapped FLASH should go to
// top 8 megs are reserved for staging updates, backups, etc.
@ -59,6 +62,8 @@ const SPI_DAT_PIN: u8 = 1;
const SPI_CD_PIN: u8 = 2;
const SPI_PORT: IoxPort = IoxPort::PC;
pub const SPI_MEM_CHANNEL: SpimChannel = SpimChannel::Channel1;
/// 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)
@ -162,7 +167,7 @@ pub fn setup_memory_pins(iox: &dyn IoSetup) -> SpimChannel {
Some(IoxEnable::Disable),
Some(IoxDriveStrength::Drive8mA),
);
SpimChannel::Channel1
SPI_MEM_CHANNEL
}
/// This also sets up I2C-adjacent interrupt inputs as well