From 81af3a25c1678ee2a1ff9da45e0cabe867f350b4 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Fri, 17 May 2024 18:53:05 +1000 Subject: [PATCH] boards/apollo3: redboard_artemis_atp: Enable SPI controller Signed-off-by: Alistair Francis --- .../apollo3/redboard_artemis_atp/src/main.rs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/boards/apollo3/redboard_artemis_atp/src/main.rs b/boards/apollo3/redboard_artemis_atp/src/main.rs index 7bdaf5d941..7305e1c2b9 100644 --- a/boards/apollo3/redboard_artemis_atp/src/main.rs +++ b/boards/apollo3/redboard_artemis_atp/src/main.rs @@ -94,6 +94,13 @@ struct RedboardArtemisAtp { apollo3::ios::Ios<'static>, >, >, + spi_controller: &'static capsules_core::spi_controller::Spi< + 'static, + capsules_core::virtualizers::virtual_spi::VirtualSpiMasterDevice< + 'static, + apollo3::iom::Iom<'static>, + >, + >, ble_radio: &'static capsules_extra::ble_advertising_driver::BLE< 'static, apollo3::ble::Ble<'static>, @@ -115,6 +122,7 @@ impl SyscallDriverLookup for RedboardArtemisAtp { capsules_core::gpio::DRIVER_NUM => f(Some(self.gpio)), capsules_core::console::DRIVER_NUM => f(Some(self.console)), capsules_core::i2c_master_slave_driver::DRIVER_NUM => f(Some(self.i2c_master_slave)), + capsules_core::spi_controller::DRIVER_NUM => f(Some(self.spi_controller)), capsules_extra::ble_advertising_driver::DRIVER_NUM => f(Some(self.ble_radio)), _ => f(None), } @@ -195,6 +203,12 @@ unsafe fn setup() -> ( peripherals .gpio_port .enable_i2c_slave(&peripherals.gpio_port[1], &peripherals.gpio_port[0]); + // Enable Main SPI + peripherals.gpio_port.enable_spi( + &peripherals.gpio_port[5], + &peripherals.gpio_port[7], + &peripherals.gpio_port[6], + ); // Configure kernel debug gpios as early as possible kernel::debug::assign_gpios( @@ -300,6 +314,24 @@ unsafe fn setup() -> ( peripherals.iom4.enable(); + // Init the SPI controller + let mux_spi = components::spi::SpiMuxComponent::new(&peripherals.iom0).finalize( + components::spi_mux_component_static!(apollo3::iom::Iom<'static>), + ); + + // The IOM0 expects an auto chip select on pin D11 or D15 + // We already use manual CS control for other Apollo3 boards, so + // let's use A13 as it's broken out next to the SPI ports + let spi_controller = components::spi::SpiSyscallComponent::new( + board_kernel, + mux_spi, + &peripherals.gpio_port[13], // A13 + capsules_core::spi_controller::DRIVER_NUM, + ) + .finalize(components::spi_syscall_component_static!( + apollo3::iom::Iom<'static> + )); + // Setup BLE mcu_ctrl.enable_ble(); clkgen.enable_ble(); @@ -349,6 +381,7 @@ unsafe fn setup() -> ( gpio, console, i2c_master_slave, + spi_controller, ble_radio, scheduler, systick,