Set frequency in stm32 SPI examples
This commit is contained in:
parent
d8420ed5a0
commit
d8f02e151b
@ -8,6 +8,7 @@ use core::str::from_utf8;
|
||||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use heapless::String;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
@ -16,7 +17,10 @@ async fn main(_spawner: Spawner) {
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let mut spi = Spi::new(p.SPI1, p.PB3, p.PB5, p.PB4, p.DMA1_CH3, p.DMA1_CH2, Config::default());
|
||||
let mut spi_config = Config::default();
|
||||
spi_config.frequency = Hertz(1_000_000);
|
||||
|
||||
let mut spi = Spi::new(p.SPI1, p.PB3, p.PB5, p.PB4, p.DMA1_CH3, p.DMA1_CH2, spi_config);
|
||||
|
||||
for n in 0u32.. {
|
||||
let mut write: String<128> = String::new();
|
||||
|
@ -7,6 +7,7 @@ use defmt::*;
|
||||
use embassy_stm32::dma::NoDma;
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[entry]
|
||||
@ -15,7 +16,10 @@ fn main() -> ! {
|
||||
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
|
||||
let mut spi = Spi::new(p.SPI3, p.PC10, p.PC12, p.PC11, NoDma, NoDma, Config::default());
|
||||
let mut spi_config = Config::default();
|
||||
spi_config.frequency = Hertz(1_000_000);
|
||||
|
||||
let mut spi = Spi::new(p.SPI3, p.PC10, p.PC12, p.PC11, NoDma, NoDma, spi_config);
|
||||
|
||||
let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh);
|
||||
|
||||
|
@ -8,6 +8,7 @@ use core::str::from_utf8;
|
||||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use heapless::String;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
@ -16,7 +17,10 @@ async fn main(_spawner: Spawner) {
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let mut spi = Spi::new(p.SPI1, p.PB3, p.PB5, p.PB4, p.DMA2_CH3, p.DMA2_CH2, Config::default());
|
||||
let mut spi_config = Config::default();
|
||||
spi_config.frequency = Hertz(1_000_000);
|
||||
|
||||
let mut spi = Spi::new(p.SPI1, p.PB3, p.PB5, p.PB4, p.DMA2_CH3, p.DMA2_CH2, spi_config);
|
||||
|
||||
for n in 0u32.. {
|
||||
let mut write: String<128> = String::new();
|
||||
|
@ -7,6 +7,7 @@ use embassy_executor::Spawner;
|
||||
use embassy_stm32::dma::NoDma;
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -14,7 +15,10 @@ async fn main(_spawner: Spawner) {
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World, folks!");
|
||||
|
||||
let mut spi = Spi::new(p.SPI1, p.PB3, p.PA7, p.PA6, NoDma, NoDma, Config::default());
|
||||
let mut spi_config = Config::default();
|
||||
spi_config.frequency = Hertz(1_000_000);
|
||||
|
||||
let mut spi = Spi::new(p.SPI1, p.PB3, p.PA7, p.PA6, NoDma, NoDma, spi_config);
|
||||
|
||||
let mut cs = Output::new(p.PA15, Level::High, Speed::VeryHigh);
|
||||
|
||||
|
@ -7,6 +7,7 @@ use embassy_executor::Spawner;
|
||||
use embassy_stm32::dma::NoDma;
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -14,7 +15,10 @@ async fn main(_spawner: Spawner) {
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World, folks!");
|
||||
|
||||
let mut spi = Spi::new(p.SPI1, p.PA5, p.PA7, p.PA6, NoDma, NoDma, Config::default());
|
||||
let mut spi_config = Config::default();
|
||||
spi_config.frequency = Hertz(1_000_000);
|
||||
|
||||
let mut spi = Spi::new(p.SPI1, p.PA5, p.PA7, p.PA6, NoDma, NoDma, spi_config);
|
||||
|
||||
let mut cs = Output::new(p.PA4, Level::High, Speed::VeryHigh);
|
||||
|
||||
|
@ -6,6 +6,7 @@ use defmt::*;
|
||||
use embassy_stm32::dma::NoDma;
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[cortex_m_rt::entry]
|
||||
@ -14,7 +15,10 @@ fn main() -> ! {
|
||||
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
|
||||
let mut spi = Spi::new(p.SPI3, p.PC10, p.PC12, p.PC11, NoDma, NoDma, Config::default());
|
||||
let mut spi_config = Config::default();
|
||||
spi_config.frequency = Hertz(1_000_000);
|
||||
|
||||
let mut spi = Spi::new(p.SPI3, p.PC10, p.PC12, p.PC11, NoDma, NoDma, spi_config);
|
||||
|
||||
let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh);
|
||||
|
||||
|
@ -8,6 +8,7 @@ use embassy_executor::Spawner;
|
||||
use embassy_stm32::dma::NoDma;
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embedded_hal_async::spi::SpiBus;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
@ -16,7 +17,10 @@ async fn main(_spawner: Spawner) {
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let spi = Spi::new(p.SPI3, p.PC10, p.PC12, p.PC11, NoDma, NoDma, Config::default());
|
||||
let mut spi_config = Config::default();
|
||||
spi_config.frequency = Hertz(1_000_000);
|
||||
|
||||
let spi = Spi::new(p.SPI3, p.PC10, p.PC12, p.PC11, NoDma, NoDma, spi_config);
|
||||
|
||||
let mut spi = BlockingAsync::new(spi);
|
||||
|
||||
|
@ -6,6 +6,7 @@ use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -13,15 +14,10 @@ async fn main(_spawner: Spawner) {
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let mut spi = Spi::new(
|
||||
p.SPI3,
|
||||
p.PC10,
|
||||
p.PC12,
|
||||
p.PC11,
|
||||
p.DMA1_CH1,
|
||||
p.DMA1_CH2,
|
||||
Config::default(),
|
||||
);
|
||||
let mut spi_config = Config::default();
|
||||
spi_config.frequency = Hertz(1_000_000);
|
||||
|
||||
let mut spi = Spi::new(p.SPI3, p.PC10, p.PC12, p.PC11, p.DMA1_CH1, p.DMA1_CH2, spi_config);
|
||||
|
||||
// These are the pins for the Inventek eS-Wifi SPI Wifi Adapter.
|
||||
|
||||
|
@ -9,6 +9,7 @@ use defmt::assert_eq;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::dma::NoDma;
|
||||
use embassy_stm32::spi::{self, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
@ -34,14 +35,14 @@ async fn main(_spawner: Spawner) {
|
||||
#[cfg(feature = "stm32c031c6")]
|
||||
let (spi, sck, mosi, miso) = (p.SPI1, p.PA5, p.PA7, p.PA6);
|
||||
|
||||
let mut spi_config = spi::Config::default();
|
||||
spi_config.frequency = Hertz(1_000_000);
|
||||
|
||||
let mut spi = Spi::new(
|
||||
spi,
|
||||
sck, // Arduino D13
|
||||
spi, sck, // Arduino D13
|
||||
mosi, // Arduino D11
|
||||
miso, // Arduino D12
|
||||
NoDma,
|
||||
NoDma,
|
||||
spi::Config::default(),
|
||||
NoDma, NoDma, spi_config,
|
||||
);
|
||||
|
||||
let data: [u8; 9] = [0x00, 0xFF, 0xAA, 0x55, 0xC0, 0xFF, 0xEE, 0xC0, 0xDE];
|
||||
|
@ -8,6 +8,7 @@ use common::*;
|
||||
use defmt::assert_eq;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::spi::{self, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
@ -33,14 +34,14 @@ async fn main(_spawner: Spawner) {
|
||||
#[cfg(feature = "stm32c031c6")]
|
||||
let (spi, sck, mosi, miso, tx_dma, rx_dma) = (p.SPI1, p.PA5, p.PA7, p.PA6, p.DMA1_CH1, p.DMA1_CH2);
|
||||
|
||||
let mut spi_config = spi::Config::default();
|
||||
spi_config.frequency = Hertz(1_000_000);
|
||||
|
||||
let mut spi = Spi::new(
|
||||
spi,
|
||||
sck, // Arduino D13
|
||||
spi, sck, // Arduino D13
|
||||
mosi, // Arduino D11
|
||||
miso, // Arduino D12
|
||||
tx_dma,
|
||||
rx_dma,
|
||||
spi::Config::default(),
|
||||
tx_dma, rx_dma, spi_config,
|
||||
);
|
||||
|
||||
let data: [u8; 9] = [0x00, 0xFF, 0xAA, 0x55, 0xC0, 0xFF, 0xEE, 0xC0, 0xDE];
|
||||
|
Loading…
Reference in New Issue
Block a user