diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/mcxa/Cargo.toml | 1 | ||||
| -rw-r--r-- | examples/mcxa/src/bin/adc_interrupt.rs | 20 | ||||
| -rw-r--r-- | examples/mcxa/src/bin/adc_polling.rs | 26 | ||||
| -rw-r--r-- | examples/mcxa/src/bin/clkout.rs | 3 | ||||
| -rw-r--r-- | examples/mcxa/src/bin/i2c-scan-blocking.rs | 3 | ||||
| -rw-r--r-- | examples/mcxa/src/bin/trng.rs | 106 | ||||
| -rw-r--r-- | examples/mimxrt6/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/mimxrt6/src/bin/spi-async.rs | 35 | ||||
| -rw-r--r-- | examples/mimxrt6/src/bin/spi.rs | 51 | ||||
| -rw-r--r-- | examples/rp/src/bin/wifi_tcp_server.rs | 2 | ||||
| -rw-r--r-- | examples/rp/src/bin/wifi_webrequest.rs | 2 |
11 files changed, 221 insertions, 30 deletions
diff --git a/examples/mcxa/Cargo.toml b/examples/mcxa/Cargo.toml index d07cc4272..347659f5b 100644 --- a/examples/mcxa/Cargo.toml +++ b/examples/mcxa/Cargo.toml | |||
| @@ -21,6 +21,7 @@ embassy-time-driver = "0.2.1" | |||
| 21 | embedded-io-async = "0.6.1" | 21 | embedded-io-async = "0.6.1" |
| 22 | heapless = "0.9.2" | 22 | heapless = "0.9.2" |
| 23 | panic-probe = { version = "1.0", features = ["print-defmt"] } | 23 | panic-probe = { version = "1.0", features = ["print-defmt"] } |
| 24 | rand_core = "0.9" | ||
| 24 | static_cell = "2.1.1" | 25 | static_cell = "2.1.1" |
| 25 | tmp108 = "0.4.0" | 26 | tmp108 = "0.4.0" |
| 26 | 27 | ||
diff --git a/examples/mcxa/src/bin/adc_interrupt.rs b/examples/mcxa/src/bin/adc_interrupt.rs index 5876923a1..d2cda631c 100644 --- a/examples/mcxa/src/bin/adc_interrupt.rs +++ b/examples/mcxa/src/bin/adc_interrupt.rs | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use embassy_executor::Spawner; | 4 | use embassy_executor::Spawner; |
| 5 | use embassy_time::{Duration, Ticker}; | ||
| 5 | use hal::adc::{Adc, InterruptHandler, LpadcConfig, TriggerPriorityPolicy}; | 6 | use hal::adc::{Adc, InterruptHandler, LpadcConfig, TriggerPriorityPolicy}; |
| 6 | use hal::bind_interrupts; | 7 | use hal::bind_interrupts; |
| 7 | use hal::clocks::PoweredClock; | 8 | use hal::clocks::PoweredClock; |
| @@ -9,9 +10,8 @@ use hal::clocks::config::Div8; | |||
| 9 | use hal::clocks::periph_helpers::{AdcClockSel, Div4}; | 10 | use hal::clocks::periph_helpers::{AdcClockSel, Div4}; |
| 10 | use hal::config::Config; | 11 | use hal::config::Config; |
| 11 | use hal::pac::adc1::cfg::{Pwrsel, Refsel}; | 12 | use hal::pac::adc1::cfg::{Pwrsel, Refsel}; |
| 12 | use hal::pac::adc1::cmdl1::{Adch, Mode}; | 13 | use hal::pac::adc1::cmdl1::Mode; |
| 13 | use hal::pac::adc1::ctrl::CalAvgs; | 14 | use hal::pac::adc1::ctrl::CalAvgs; |
| 14 | use hal::pac::adc1::tctrl::Tcmd; | ||
| 15 | use hal::peripherals::ADC1; | 15 | use hal::peripherals::ADC1; |
| 16 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; | 16 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; |
| 17 | 17 | ||
| @@ -38,7 +38,6 @@ async fn main(_spawner: Spawner) { | |||
| 38 | trigger_priority_policy: TriggerPriorityPolicy::ConvPreemptImmediatelyNotAutoResumed, | 38 | trigger_priority_policy: TriggerPriorityPolicy::ConvPreemptImmediatelyNotAutoResumed, |
| 39 | enable_conv_pause: false, | 39 | enable_conv_pause: false, |
| 40 | conv_pause_delay: 0, | 40 | conv_pause_delay: 0, |
| 41 | fifo_watermark: 0, | ||
| 42 | power: PoweredClock::NormalEnabledDeepSleepDisabled, | 41 | power: PoweredClock::NormalEnabledDeepSleepDisabled, |
| 43 | source: AdcClockSel::FroLfDiv, | 42 | source: AdcClockSel::FroLfDiv, |
| 44 | div: Div4::no_div(), | 43 | div: Div4::no_div(), |
| @@ -47,23 +46,16 @@ async fn main(_spawner: Spawner) { | |||
| 47 | 46 | ||
| 48 | adc.do_offset_calibration(); | 47 | adc.do_offset_calibration(); |
| 49 | adc.do_auto_calibration(); | 48 | adc.do_auto_calibration(); |
| 50 | 49 | adc.set_resolution(Mode::Data16Bits); | |
| 51 | let mut conv_command_config = adc.get_default_conv_command_config(); | ||
| 52 | conv_command_config.channel_number = Adch::SelectCorrespondingChannel8; | ||
| 53 | conv_command_config.conversion_resolution_mode = Mode::Data16Bits; | ||
| 54 | adc.set_conv_command_config(1, &conv_command_config).unwrap(); | ||
| 55 | |||
| 56 | let mut conv_trigger_config = adc.get_default_conv_trigger_config(); | ||
| 57 | conv_trigger_config.target_command_id = Tcmd::ExecuteCmd1; | ||
| 58 | conv_trigger_config.enable_hardware_trigger = false; | ||
| 59 | adc.set_conv_trigger_config(0, &conv_trigger_config); | ||
| 60 | 50 | ||
| 61 | defmt::info!("ADC configuration done..."); | 51 | defmt::info!("ADC configuration done..."); |
| 52 | let mut ticker = Ticker::every(Duration::from_millis(100)); | ||
| 62 | 53 | ||
| 63 | loop { | 54 | loop { |
| 55 | ticker.next().await; | ||
| 64 | match adc.read().await { | 56 | match adc.read().await { |
| 65 | Ok(value) => { | 57 | Ok(value) => { |
| 66 | defmt::info!("*** ADC interrupt TRIGGERED! *** -- value: {}", value); | 58 | defmt::info!("ADC value: {}", value); |
| 67 | } | 59 | } |
| 68 | Err(e) => { | 60 | Err(e) => { |
| 69 | defmt::error!("ADC read error: {:?}", e); | 61 | defmt::error!("ADC read error: {:?}", e); |
diff --git a/examples/mcxa/src/bin/adc_polling.rs b/examples/mcxa/src/bin/adc_polling.rs index d048bb56f..5c4d5524c 100644 --- a/examples/mcxa/src/bin/adc_polling.rs +++ b/examples/mcxa/src/bin/adc_polling.rs | |||
| @@ -2,13 +2,15 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use embassy_executor::Spawner; | 4 | use embassy_executor::Spawner; |
| 5 | use embassy_mcxa::adc::{ConvCommandConfig, ConvTriggerConfig}; | ||
| 6 | use embassy_time::{Duration, Ticker}; | ||
| 5 | use hal::adc::{Adc, LpadcConfig, TriggerPriorityPolicy}; | 7 | use hal::adc::{Adc, LpadcConfig, TriggerPriorityPolicy}; |
| 6 | use hal::clocks::PoweredClock; | 8 | use hal::clocks::PoweredClock; |
| 7 | use hal::clocks::config::Div8; | 9 | use hal::clocks::config::Div8; |
| 8 | use hal::clocks::periph_helpers::{AdcClockSel, Div4}; | 10 | use hal::clocks::periph_helpers::{AdcClockSel, Div4}; |
| 9 | use hal::config::Config; | 11 | use hal::config::Config; |
| 10 | use hal::pac::adc1::cfg::{Pwrsel, Refsel}; | 12 | use hal::pac::adc1::cfg::{Pwrsel, Refsel}; |
| 11 | use hal::pac::adc1::cmdl1::{Adch, Mode}; | 13 | use hal::pac::adc1::cmdl1::Mode; |
| 12 | use hal::pac::adc1::ctrl::CalAvgs; | 14 | use hal::pac::adc1::ctrl::CalAvgs; |
| 13 | use hal::pac::adc1::tctrl::Tcmd; | 15 | use hal::pac::adc1::tctrl::Tcmd; |
| 14 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; | 16 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; |
| @@ -34,7 +36,6 @@ async fn main(_spawner: Spawner) { | |||
| 34 | trigger_priority_policy: TriggerPriorityPolicy::ConvPreemptImmediatelyNotAutoResumed, | 36 | trigger_priority_policy: TriggerPriorityPolicy::ConvPreemptImmediatelyNotAutoResumed, |
| 35 | enable_conv_pause: false, | 37 | enable_conv_pause: false, |
| 36 | conv_pause_delay: 0, | 38 | conv_pause_delay: 0, |
| 37 | fifo_watermark: 0, | ||
| 38 | power: PoweredClock::NormalEnabledDeepSleepDisabled, | 39 | power: PoweredClock::NormalEnabledDeepSleepDisabled, |
| 39 | source: AdcClockSel::FroLfDiv, | 40 | source: AdcClockSel::FroLfDiv, |
| 40 | div: Div4::no_div(), | 41 | div: Div4::no_div(), |
| @@ -44,20 +45,25 @@ async fn main(_spawner: Spawner) { | |||
| 44 | adc.do_offset_calibration(); | 45 | adc.do_offset_calibration(); |
| 45 | adc.do_auto_calibration(); | 46 | adc.do_auto_calibration(); |
| 46 | 47 | ||
| 47 | let mut conv_command_config = adc.get_default_conv_command_config(); | 48 | let conv_command_config = ConvCommandConfig { |
| 48 | conv_command_config.channel_number = Adch::SelectCorrespondingChannel8; | 49 | conversion_resolution_mode: Mode::Data16Bits, |
| 49 | conv_command_config.conversion_resolution_mode = Mode::Data16Bits; | 50 | ..ConvCommandConfig::default() |
| 51 | }; | ||
| 50 | adc.set_conv_command_config(1, &conv_command_config).unwrap(); | 52 | adc.set_conv_command_config(1, &conv_command_config).unwrap(); |
| 51 | 53 | ||
| 52 | let mut conv_trigger_config = adc.get_default_conv_trigger_config(); | 54 | let conv_trigger_config = ConvTriggerConfig { |
| 53 | conv_trigger_config.target_command_id = Tcmd::ExecuteCmd1; | 55 | target_command_id: Tcmd::ExecuteCmd1, |
| 54 | conv_trigger_config.enable_hardware_trigger = false; | 56 | enable_hardware_trigger: false, |
| 55 | adc.set_conv_trigger_config(0, &conv_trigger_config); | 57 | ..Default::default() |
| 58 | }; | ||
| 59 | adc.set_conv_trigger_config(0, &conv_trigger_config).unwrap(); | ||
| 56 | 60 | ||
| 57 | defmt::info!("=== ADC configuration done... ==="); | 61 | defmt::info!("=== ADC configuration done... ==="); |
| 62 | let mut tick = Ticker::every(Duration::from_millis(100)); | ||
| 58 | 63 | ||
| 59 | loop { | 64 | loop { |
| 60 | adc.do_software_trigger(1); | 65 | tick.next().await; |
| 66 | adc.do_software_trigger(1).unwrap(); | ||
| 61 | let result = loop { | 67 | let result = loop { |
| 62 | match adc.get_conv_result() { | 68 | match adc.get_conv_result() { |
| 63 | Ok(res) => break res, | 69 | Ok(res) => break res, |
diff --git a/examples/mcxa/src/bin/clkout.rs b/examples/mcxa/src/bin/clkout.rs index bfd963540..1e52912d3 100644 --- a/examples/mcxa/src/bin/clkout.rs +++ b/examples/mcxa/src/bin/clkout.rs | |||
| @@ -4,8 +4,7 @@ | |||
| 4 | use embassy_executor::Spawner; | 4 | use embassy_executor::Spawner; |
| 5 | use embassy_mcxa::clkout::{ClockOut, ClockOutSel, Config, Div4}; | 5 | use embassy_mcxa::clkout::{ClockOut, ClockOutSel, Config, Div4}; |
| 6 | use embassy_mcxa::clocks::PoweredClock; | 6 | use embassy_mcxa::clocks::PoweredClock; |
| 7 | use embassy_mcxa::gpio::{DriveStrength, SlewRate}; | 7 | use embassy_mcxa::gpio::{DriveStrength, Level, Output, SlewRate}; |
| 8 | use embassy_mcxa::{Level, Output}; | ||
| 9 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; | 9 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; |
| 11 | 10 | ||
diff --git a/examples/mcxa/src/bin/i2c-scan-blocking.rs b/examples/mcxa/src/bin/i2c-scan-blocking.rs index 0197f9b1d..bd706d712 100644 --- a/examples/mcxa/src/bin/i2c-scan-blocking.rs +++ b/examples/mcxa/src/bin/i2c-scan-blocking.rs | |||
| @@ -2,8 +2,7 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use embassy_executor::Spawner; | 4 | use embassy_executor::Spawner; |
| 5 | use embassy_mcxa::Input; | 5 | use embassy_mcxa::gpio::{Input, Pull}; |
| 6 | use embassy_mcxa::gpio::Pull; | ||
| 7 | use embassy_time::Timer; | 6 | use embassy_time::Timer; |
| 8 | use hal::clocks::config::Div8; | 7 | use hal::clocks::config::Div8; |
| 9 | use hal::config::Config; | 8 | use hal::config::Config; |
diff --git a/examples/mcxa/src/bin/trng.rs b/examples/mcxa/src/bin/trng.rs new file mode 100644 index 000000000..5f6e2408c --- /dev/null +++ b/examples/mcxa/src/bin/trng.rs | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use embassy_executor::Spawner; | ||
| 5 | use hal::bind_interrupts; | ||
| 6 | use hal::config::Config; | ||
| 7 | use hal::trng::{self, InterruptHandler, Trng}; | ||
| 8 | use rand_core::RngCore; | ||
| 9 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; | ||
| 10 | |||
| 11 | bind_interrupts!( | ||
| 12 | struct Irqs { | ||
| 13 | TRNG0 => InterruptHandler; | ||
| 14 | } | ||
| 15 | ); | ||
| 16 | |||
| 17 | #[embassy_executor::main] | ||
| 18 | async fn main(_spawner: Spawner) { | ||
| 19 | let config = Config::default(); | ||
| 20 | let mut p = hal::init(config); | ||
| 21 | |||
| 22 | defmt::info!("TRNG example"); | ||
| 23 | |||
| 24 | let mut trng = Trng::new_blocking_128(p.TRNG0.reborrow()); | ||
| 25 | let rand = trng.blocking_next_u32(); | ||
| 26 | defmt::info!("128-bit {}", rand); | ||
| 27 | |||
| 28 | drop(trng); | ||
| 29 | |||
| 30 | let mut trng = Trng::new_blocking_256(p.TRNG0.reborrow()); | ||
| 31 | let rand = trng.blocking_next_u32(); | ||
| 32 | defmt::info!("256-bit {}", rand); | ||
| 33 | |||
| 34 | drop(trng); | ||
| 35 | |||
| 36 | let mut trng = Trng::new_blocking_512(p.TRNG0.reborrow()); | ||
| 37 | let rand = trng.blocking_next_u32(); | ||
| 38 | defmt::info!("512-bit {}", rand); | ||
| 39 | |||
| 40 | drop(trng); | ||
| 41 | |||
| 42 | let config = trng::Config::default(); | ||
| 43 | let mut trng = Trng::new_blocking_with_custom_config(p.TRNG0.reborrow(), config); | ||
| 44 | |||
| 45 | defmt::info!("========== BLOCKING =========="); | ||
| 46 | |||
| 47 | defmt::info!("Generate 10 u32"); | ||
| 48 | for _ in 0..10 { | ||
| 49 | let rand = trng.blocking_next_u32(); | ||
| 50 | defmt::info!("{}", rand); | ||
| 51 | } | ||
| 52 | |||
| 53 | defmt::info!("Generate 10 u64"); | ||
| 54 | for _ in 0..10 { | ||
| 55 | let rand = trng.blocking_next_u64(); | ||
| 56 | defmt::info!("{}", rand); | ||
| 57 | } | ||
| 58 | |||
| 59 | let mut buf = [0_u8; 256]; | ||
| 60 | |||
| 61 | defmt::info!("Generate 10 256-byte buffers"); | ||
| 62 | for _ in 0..10 { | ||
| 63 | trng.blocking_fill_bytes(&mut buf); | ||
| 64 | defmt::info!("{:02x}", buf); | ||
| 65 | } | ||
| 66 | |||
| 67 | defmt::info!("RngCore"); | ||
| 68 | |||
| 69 | for _ in 0..10 { | ||
| 70 | defmt::info!("u32: {}", trng.next_u32()); | ||
| 71 | defmt::info!("u64: {}", trng.next_u64()); | ||
| 72 | } | ||
| 73 | |||
| 74 | drop(trng); | ||
| 75 | |||
| 76 | defmt::info!("========== ASYNC =========="); | ||
| 77 | |||
| 78 | let mut trng = Trng::new_with_custom_config(p.TRNG0.reborrow(), Irqs, config); | ||
| 79 | |||
| 80 | defmt::info!("Generate 10 u32"); | ||
| 81 | for _ in 0..10 { | ||
| 82 | let rand = trng.async_next_u32().await.unwrap(); | ||
| 83 | defmt::info!("{}", rand); | ||
| 84 | } | ||
| 85 | |||
| 86 | defmt::info!("Generate 10 u64"); | ||
| 87 | for _ in 0..10 { | ||
| 88 | let rand = trng.async_next_u64().await.unwrap(); | ||
| 89 | defmt::info!("{}", rand); | ||
| 90 | } | ||
| 91 | |||
| 92 | let mut buf = [0_u8; 256]; | ||
| 93 | |||
| 94 | defmt::info!("Generate 10 256-byte buffers"); | ||
| 95 | for _ in 0..10 { | ||
| 96 | trng.async_fill_bytes(&mut buf).await.unwrap(); | ||
| 97 | defmt::info!("{:02x}", buf); | ||
| 98 | } | ||
| 99 | |||
| 100 | defmt::info!("RngCore"); | ||
| 101 | |||
| 102 | for _ in 0..10 { | ||
| 103 | defmt::info!("u32: {}", trng.next_u32()); | ||
| 104 | defmt::info!("u64: {}", trng.next_u64()); | ||
| 105 | } | ||
| 106 | } | ||
diff --git a/examples/mimxrt6/Cargo.toml b/examples/mimxrt6/Cargo.toml index dc09e97e7..ada112833 100644 --- a/examples/mimxrt6/Cargo.toml +++ b/examples/mimxrt6/Cargo.toml | |||
| @@ -21,6 +21,8 @@ embedded-hal-async = "1.0.0" | |||
| 21 | 21 | ||
| 22 | mimxrt600-fcb = "0.2.2" | 22 | mimxrt600-fcb = "0.2.2" |
| 23 | panic-probe = { version = "1.0.0", features = ["print-defmt"] } | 23 | panic-probe = { version = "1.0.0", features = ["print-defmt"] } |
| 24 | embedded-hal-bus = "0.3.0" | ||
| 25 | is31fl3743b-driver = { version = "0.1.1", features = ["is_blocking"] } | ||
| 24 | 26 | ||
| 25 | # cargo build/run | 27 | # cargo build/run |
| 26 | [profile.dev] | 28 | [profile.dev] |
diff --git a/examples/mimxrt6/src/bin/spi-async.rs b/examples/mimxrt6/src/bin/spi-async.rs new file mode 100644 index 000000000..aa56f7c42 --- /dev/null +++ b/examples/mimxrt6/src/bin/spi-async.rs | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::info; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_imxrt::bind_interrupts; | ||
| 7 | use embassy_imxrt::flexcomm::spi::{InterruptHandler, Spi}; | ||
| 8 | use embassy_imxrt::peripherals::FLEXCOMM5; | ||
| 9 | use {defmt_rtt as _, embassy_imxrt_examples as _, panic_probe as _}; | ||
| 10 | |||
| 11 | bind_interrupts!(struct Irqs { | ||
| 12 | FLEXCOMM5 => InterruptHandler<FLEXCOMM5>; | ||
| 13 | }); | ||
| 14 | |||
| 15 | const BUFLEN: usize = 1024; | ||
| 16 | |||
| 17 | #[embassy_executor::main] | ||
| 18 | async fn main(_spawner: Spawner) { | ||
| 19 | let p = embassy_imxrt::init(Default::default()); | ||
| 20 | |||
| 21 | info!("Initializing SPI"); | ||
| 22 | |||
| 23 | let mut spi = Spi::new_async(p.FLEXCOMM5, p.PIO1_3, p.PIO1_5, p.PIO1_4, Irqs, Default::default()); | ||
| 24 | |||
| 25 | let mut rxbuf = [0x55; BUFLEN]; | ||
| 26 | let txbuf = [0xaa; BUFLEN]; | ||
| 27 | |||
| 28 | for _ in 0..10 { | ||
| 29 | spi.async_transfer(&mut rxbuf, &txbuf).await.unwrap(); | ||
| 30 | assert!(rxbuf.iter().all(|b| *b == 0xaa)); | ||
| 31 | rxbuf.fill(0x55); | ||
| 32 | } | ||
| 33 | |||
| 34 | info!("SPI transfers succeeded"); | ||
| 35 | } | ||
diff --git a/examples/mimxrt6/src/bin/spi.rs b/examples/mimxrt6/src/bin/spi.rs new file mode 100644 index 000000000..4854432e8 --- /dev/null +++ b/examples/mimxrt6/src/bin/spi.rs | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::info; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_imxrt::flexcomm::spi::Spi; | ||
| 7 | use embassy_imxrt::gpio; | ||
| 8 | use embassy_time::{Delay, Timer}; | ||
| 9 | use embedded_hal_bus::spi::ExclusiveDevice; | ||
| 10 | use is31fl3743b_driver::{CSy, Is31fl3743b, SWx}; | ||
| 11 | use {defmt_rtt as _, embassy_imxrt_examples as _, panic_probe as _}; | ||
| 12 | |||
| 13 | #[embassy_executor::main] | ||
| 14 | async fn main(_spawner: Spawner) { | ||
| 15 | let p = embassy_imxrt::init(Default::default()); | ||
| 16 | |||
| 17 | info!("Initializing SPI"); | ||
| 18 | |||
| 19 | let cs = gpio::Output::new( | ||
| 20 | p.PIO1_6, | ||
| 21 | gpio::Level::Low, | ||
| 22 | gpio::DriveMode::PushPull, | ||
| 23 | gpio::DriveStrength::Normal, | ||
| 24 | gpio::SlewRate::Standard, | ||
| 25 | ); | ||
| 26 | |||
| 27 | let spi = Spi::new_blocking(p.FLEXCOMM5, p.PIO1_3, p.PIO1_5, p.PIO1_4, Default::default()); | ||
| 28 | let delay = Delay; | ||
| 29 | |||
| 30 | // One SPI device only on the SPI bus | ||
| 31 | let spi_dev = ExclusiveDevice::new(spi, cs, delay).unwrap(); | ||
| 32 | |||
| 33 | // Instantiate IS31FL3743B device | ||
| 34 | let mut driver = Is31fl3743b::new(spi_dev).unwrap(); | ||
| 35 | |||
| 36 | // Enable phase delay to help reduce power noise | ||
| 37 | let _ = driver.enable_phase_delay(); | ||
| 38 | // Set global current, check method documentation for more info | ||
| 39 | let _ = driver.set_global_current(90); | ||
| 40 | |||
| 41 | let _ = driver.set_led_peak_current_bulk(SWx::SW1, CSy::CS1, &[100; 11 * 18]); | ||
| 42 | |||
| 43 | // Driver is fully set up, we can now start turning on LEDs! | ||
| 44 | // Create a white breathing effect | ||
| 45 | loop { | ||
| 46 | for brightness in (0..=255_u8).chain((0..=255).rev()) { | ||
| 47 | let _ = driver.set_led_brightness_bulk(SWx::SW1, CSy::CS1, &[brightness; 11 * 18]); | ||
| 48 | Timer::after_micros(1).await; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | } | ||
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index e39de4902..ef8d08b76 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs | |||
| @@ -101,7 +101,7 @@ async fn main(spawner: Spawner) { | |||
| 101 | .join(WIFI_NETWORK, JoinOptions::new(WIFI_PASSWORD.as_bytes())) | 101 | .join(WIFI_NETWORK, JoinOptions::new(WIFI_PASSWORD.as_bytes())) |
| 102 | .await | 102 | .await |
| 103 | { | 103 | { |
| 104 | info!("join failed with status={}", err.status); | 104 | info!("join failed: {:?}", err); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | info!("waiting for link..."); | 107 | info!("waiting for link..."); |
diff --git a/examples/rp/src/bin/wifi_webrequest.rs b/examples/rp/src/bin/wifi_webrequest.rs index ce85f4b9a..069afc794 100644 --- a/examples/rp/src/bin/wifi_webrequest.rs +++ b/examples/rp/src/bin/wifi_webrequest.rs | |||
| @@ -106,7 +106,7 @@ async fn main(spawner: Spawner) { | |||
| 106 | .join(WIFI_NETWORK, JoinOptions::new(WIFI_PASSWORD.as_bytes())) | 106 | .join(WIFI_NETWORK, JoinOptions::new(WIFI_PASSWORD.as_bytes())) |
| 107 | .await | 107 | .await |
| 108 | { | 108 | { |
| 109 | info!("join failed with status={}", err.status); | 109 | info!("join failed: {:?}", err); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | info!("waiting for link..."); | 112 | info!("waiting for link..."); |
