From b6b84d79c9da6f52e1f7ba4d2bac55acd340f06d Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Sun, 5 Jan 2020 19:18:26 +0100 Subject: [PATCH] application: Set up pins for the MX25L flash memory. This configures SPI0 as well as the GPIO used as the flash's chip select line. --- src/application/main.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/application/main.rs b/src/application/main.rs index 92429e5..8f7bd6d 100644 --- a/src/application/main.rs +++ b/src/application/main.rs @@ -36,6 +36,7 @@ use common::port; use common::gpio; use common::nvic; use common::i2c; +use common::spi; use common::uart; use common::usb_serial; use common::display; @@ -104,6 +105,20 @@ pub unsafe extern "C" fn _start() -> ! { gpio::set_direction(gpio::GPIOB, 1 << 16, gpio::Direction::Output); port::set_af(port::PORTB, 16, 1); + // Configure pin for the MX25L's chip select line. + gpio::set_direction(gpio::GPIOD, 1 << 0, gpio::Direction::Output); + port::set_af(port::PORTD, 0, 1); + gpio::set(gpio::GPIOD, 1 << 0); + + // Configure pins for SPI0. + port::set_af(port::PORTD, 1, 2); + port::set_af(port::PORTD, 2, 5); + port::set_af(port::PORTD, 3, 5); + + spi::configure(spi::SPI0); + + nvic::disable_irq(10); // SPI0 + // Configure pins for UART0. port::set_af(port::PORTE, 20, 4); port::set_af(port::PORTE, 21, 4); -- 2.30.2