Skip to content

Commit

Permalink
Merge pull request tock#3994 from alistair23/alistair/apollo3-atp-spi
Browse files Browse the repository at this point in the history
boards/apollo3: redboard_artemis_atp: Enable SPI controller
  • Loading branch information
alevy authored May 31, 2024
2 parents fe92699 + 81af3a2 commit 95e9146
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions boards/apollo3/redboard_artemis_atp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,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>,
Expand All @@ -117,6 +124,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),
}
Expand Down Expand Up @@ -197,6 +205,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(
Expand Down Expand Up @@ -299,6 +313,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();
Expand Down Expand Up @@ -348,6 +380,7 @@ unsafe fn setup() -> (
gpio,
console,
i2c_master_slave,
spi_controller,
ble_radio,
scheduler,
systick,
Expand Down

0 comments on commit 95e9146

Please sign in to comment.