diff options
Diffstat (limited to 'examples/stm32l4/src/bin/spe_adin1110_http_server.rs')
| -rw-r--r-- | examples/stm32l4/src/bin/spe_adin1110_http_server.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index 24efe526f..8f2510cdc 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs | |||
| @@ -16,21 +16,23 @@ | |||
| 16 | use core::marker::PhantomData; | 16 | use core::marker::PhantomData; |
| 17 | use core::sync::atomic::{AtomicI32, Ordering}; | 17 | use core::sync::atomic::{AtomicI32, Ordering}; |
| 18 | 18 | ||
| 19 | use defmt::{error, info, println, unwrap, Format}; | 19 | use defmt::{Format, error, info, println, unwrap}; |
| 20 | use defmt_rtt as _; // global logger | 20 | use defmt_rtt as _; // global logger |
| 21 | use embassy_executor::Spawner; | 21 | use embassy_executor::Spawner; |
| 22 | use embassy_futures::select::{select, Either}; | 22 | use embassy_futures::select::{Either, select}; |
| 23 | use embassy_futures::yield_now; | 23 | use embassy_futures::yield_now; |
| 24 | use embassy_net::tcp::TcpSocket; | 24 | use embassy_net::tcp::TcpSocket; |
| 25 | use embassy_net::{Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4}; | 25 | use embassy_net::{Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4}; |
| 26 | use embassy_net_adin1110::{Device, Runner, ADIN1110}; | 26 | use embassy_net_adin1110::{ADIN1110, Device, Runner}; |
| 27 | use embassy_stm32::exti::ExtiInput; | ||
| 27 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 28 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 28 | use embassy_stm32::i2c::{self, Config as I2C_Config, I2c}; | 29 | use embassy_stm32::i2c::{self, Config as I2C_Config, I2c}; |
| 29 | use embassy_stm32::mode::Async; | 30 | use embassy_stm32::mode::Async; |
| 30 | use embassy_stm32::rng::{self, Rng}; | 31 | use embassy_stm32::rng::{self, Rng}; |
| 32 | use embassy_stm32::spi::mode::Master; | ||
| 31 | use embassy_stm32::spi::{Config as SPI_Config, Spi}; | 33 | use embassy_stm32::spi::{Config as SPI_Config, Spi}; |
| 32 | use embassy_stm32::time::Hertz; | 34 | use embassy_stm32::time::Hertz; |
| 33 | use embassy_stm32::{bind_interrupts, exti, pac, peripherals}; | 35 | use embassy_stm32::{bind_interrupts, exti, interrupt, pac, peripherals}; |
| 34 | use embassy_time::{Delay, Duration, Ticker, Timer}; | 36 | use embassy_time::{Delay, Duration, Ticker, Timer}; |
| 35 | use embedded_hal_async::i2c::I2c as I2cBus; | 37 | use embedded_hal_async::i2c::I2c as I2cBus; |
| 36 | use embedded_hal_bus::spi::ExclusiveDevice; | 38 | use embedded_hal_bus::spi::ExclusiveDevice; |
| @@ -44,6 +46,7 @@ bind_interrupts!(struct Irqs { | |||
| 44 | I2C3_EV => i2c::EventInterruptHandler<peripherals::I2C3>; | 46 | I2C3_EV => i2c::EventInterruptHandler<peripherals::I2C3>; |
| 45 | I2C3_ER => i2c::ErrorInterruptHandler<peripherals::I2C3>; | 47 | I2C3_ER => i2c::ErrorInterruptHandler<peripherals::I2C3>; |
| 46 | RNG => rng::InterruptHandler<peripherals::RNG>; | 48 | RNG => rng::InterruptHandler<peripherals::RNG>; |
| 49 | EXTI15_10 => exti::InterruptHandler<interrupt::typelevel::EXTI15_10>; | ||
| 47 | }); | 50 | }); |
| 48 | 51 | ||
| 49 | // Basic settings | 52 | // Basic settings |
| @@ -54,7 +57,7 @@ const IP_ADDRESS: Ipv4Cidr = Ipv4Cidr::new(Ipv4Address::new(192, 168, 1, 5), 24) | |||
| 54 | // Listen port for the webserver | 57 | // Listen port for the webserver |
| 55 | const HTTP_LISTEN_PORT: u16 = 80; | 58 | const HTTP_LISTEN_PORT: u16 = 80; |
| 56 | 59 | ||
| 57 | pub type SpeSpi = Spi<'static, Async>; | 60 | pub type SpeSpi = Spi<'static, Async, Master>; |
| 58 | pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static>, Delay>; | 61 | pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static>, Delay>; |
| 59 | pub type SpeInt = exti::ExtiInput<'static>; | 62 | pub type SpeInt = exti::ExtiInput<'static>; |
| 60 | pub type SpeRst = Output<'static>; | 63 | pub type SpeRst = Output<'static>; |
| @@ -124,7 +127,7 @@ async fn main(spawner: Spawner) { | |||
| 124 | let spe_cfg1 = Input::new(dp.PC9, Pull::None); | 127 | let spe_cfg1 = Input::new(dp.PC9, Pull::None); |
| 125 | let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low); | 128 | let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low); |
| 126 | 129 | ||
| 127 | let spe_int = exti::ExtiInput::new(dp.PB11, dp.EXTI11, Pull::None); | 130 | let spe_int = ExtiInput::new(dp.PB11, dp.EXTI11, Pull::None, Irqs); |
| 128 | 131 | ||
| 129 | let spe_spi_cs_n = Output::new(dp.PB12, Level::High, Speed::High); | 132 | let spe_spi_cs_n = Output::new(dp.PB12, Level::High, Speed::High); |
| 130 | let spe_spi_sclk = dp.PB13; | 133 | let spe_spi_sclk = dp.PB13; |
| @@ -159,7 +162,9 @@ async fn main(spawner: Spawner) { | |||
| 159 | 162 | ||
| 160 | // Check the SPI mode selected with the "HW CFG" dip-switch | 163 | // Check the SPI mode selected with the "HW CFG" dip-switch |
| 161 | if !cfg1_spi_mode { | 164 | if !cfg1_spi_mode { |
| 162 | error!("Driver doesn´t support SPI Protolcol \"OPEN Alliance\".\nplease use the \"Generic SPI\"! Turn On \"HW CFG\": \"SPI_CFG1\""); | 165 | error!( |
| 166 | "Driver doesn´t support SPI Protolcol \"OPEN Alliance\".\nplease use the \"Generic SPI\"! Turn On \"HW CFG\": \"SPI_CFG1\"" | ||
| 167 | ); | ||
| 163 | loop { | 168 | loop { |
| 164 | led_uc2_red.toggle(); | 169 | led_uc2_red.toggle(); |
| 165 | Timer::after(Duration::from_hz(10)).await; | 170 | Timer::after(Duration::from_hz(10)).await; |
