diff options
| author | ceekdee <[email protected]> | 2023-04-25 13:51:19 -0500 |
|---|---|---|
| committer | ceekdee <[email protected]> | 2023-04-25 13:51:19 -0500 |
| commit | f729d2d060043889eacb04dc924757a536eb247f (patch) | |
| tree | 10d50fdcb5d0cb6244f9f6cd8c91b859a5adacaa /examples | |
| parent | 73f25093c7793ad2e8bd6fceeca46d9b5b1031ad (diff) | |
Deprecate original LoRa drivers. Update rust-lorawan releases.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf52840/Cargo.toml | 4 | ||||
| -rw-r--r-- | examples/rp/Cargo.toml | 4 | ||||
| -rw-r--r-- | examples/stm32l0/Cargo.toml | 4 | ||||
| -rw-r--r-- | examples/stm32wl/Cargo.toml | 4 | ||||
| -rw-r--r-- | examples/stm32wl/src/bin/subghz.rs | 119 |
5 files changed, 8 insertions, 127 deletions
diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index a1bcc4b6f..be8b5328e 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml | |||
| @@ -20,8 +20,8 @@ embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defm | |||
| 20 | embedded-io = "0.4.0" | 20 | embedded-io = "0.4.0" |
| 21 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx126x", "time", "defmt", "external-lora-phy"], optional = true } | 21 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx126x", "time", "defmt", "external-lora-phy"], optional = true } |
| 22 | lora-phy = { version = "1" } | 22 | lora-phy = { version = "1" } |
| 23 | lorawan-device = { version = "0.9.0", path = "../../../rust-lorawan/device", default-features = false, features = ["async", "external-lora-phy"], optional = true } | 23 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } |
| 24 | lorawan = { version = "0.7.2", path = "../../../rust-lorawan/encoding", default-features = false, features = ["default-crypto"], optional = true } | 24 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"], optional = true } |
| 25 | 25 | ||
| 26 | defmt = "0.3" | 26 | defmt = "0.3" |
| 27 | defmt-rtt = "0.4" | 27 | defmt-rtt = "0.4" |
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 5f0a397ea..45af8762e 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -17,8 +17,8 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | |||
| 17 | embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" } | 17 | embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" } |
| 18 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt", "external-lora-phy"] } | 18 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt", "external-lora-phy"] } |
| 19 | lora-phy = { version = "1" } | 19 | lora-phy = { version = "1" } |
| 20 | lorawan-device = { version = "0.9.0", path = "../../../rust-lorawan/device", default-features = false, features = ["async", "external-lora-phy"] } | 20 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"] } |
| 21 | lorawan = { version = "0.7.2", path = "../../../rust-lorawan/encoding", default-features = false, features = ["default-crypto"] } | 21 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"] } |
| 22 | 22 | ||
| 23 | defmt = "0.3" | 23 | defmt = "0.3" |
| 24 | defmt-rtt = "0.4" | 24 | defmt-rtt = "0.4" |
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index fe4b4f3c3..c51f1b904 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml | |||
| @@ -15,8 +15,8 @@ embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["ni | |||
| 15 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } | 15 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } |
| 16 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt", "external-lora-phy"], optional = true } | 16 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt", "external-lora-phy"], optional = true } |
| 17 | lora-phy = { version = "1" } | 17 | lora-phy = { version = "1" } |
| 18 | lorawan-device = { version = "0.9.0", path = "../../../rust-lorawan/device", default-features = false, features = ["async", "external-lora-phy"], optional = true } | 18 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } |
| 19 | lorawan = { version = "0.7.2", path = "../../../rust-lorawan/encoding", default-features = false, features = ["default-crypto"], optional = true } | 19 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"], optional = true } |
| 20 | 20 | ||
| 21 | defmt = "0.3" | 21 | defmt = "0.3" |
| 22 | defmt-rtt = "0.4" | 22 | defmt-rtt = "0.4" |
diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 45e720f01..0eb24bc44 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml | |||
| @@ -12,8 +12,8 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [" | |||
| 12 | embassy-embedded-hal = {version = "0.1.0", path = "../../embassy-embedded-hal" } | 12 | embassy-embedded-hal = {version = "0.1.0", path = "../../embassy-embedded-hal" } |
| 13 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt", "external-lora-phy"] } | 13 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt", "external-lora-phy"] } |
| 14 | lora-phy = { version = "1" } | 14 | lora-phy = { version = "1" } |
| 15 | lorawan-device = { version = "0.9.0", path = "../../../rust-lorawan/device", default-features = false, features = ["async", "external-lora-phy"] } | 15 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"] } |
| 16 | lorawan = { version = "0.7.2", path = "../../../rust-lorawan/encoding", default-features = false, features = ["default-crypto"] } | 16 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"] } |
| 17 | 17 | ||
| 18 | defmt = "0.3" | 18 | defmt = "0.3" |
| 19 | defmt-rtt = "0.4" | 19 | defmt-rtt = "0.4" |
diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs deleted file mode 100644 index 32c8b5515..000000000 --- a/examples/stm32wl/src/bin/subghz.rs +++ /dev/null | |||
| @@ -1,119 +0,0 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![macro_use] | ||
| 4 | #![allow(dead_code)] | ||
| 5 | #![feature(type_alias_impl_trait)] | ||
| 6 | |||
| 7 | use defmt::*; | ||
| 8 | use embassy_executor::Spawner; | ||
| 9 | use embassy_stm32::dma::NoDma; | ||
| 10 | use embassy_stm32::exti::ExtiInput; | ||
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | ||
| 12 | use embassy_stm32::interrupt; | ||
| 13 | use embassy_stm32::interrupt::{Interrupt, InterruptExt}; | ||
| 14 | use embassy_stm32::subghz::*; | ||
| 15 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 16 | use embassy_sync::signal::Signal; | ||
| 17 | use {defmt_rtt as _, panic_probe as _}; | ||
| 18 | |||
| 19 | const PING_DATA: &str = "PING"; | ||
| 20 | const DATA_LEN: u8 = PING_DATA.len() as u8; | ||
| 21 | const PING_DATA_BYTES: &[u8] = PING_DATA.as_bytes(); | ||
| 22 | const PREAMBLE_LEN: u16 = 5 * 8; | ||
| 23 | |||
| 24 | const RF_FREQ: RfFreq = RfFreq::from_frequency(867_500_000); | ||
| 25 | |||
| 26 | const SYNC_WORD: [u8; 8] = [0x79, 0x80, 0x0C, 0xC0, 0x29, 0x95, 0xF8, 0x4A]; | ||
| 27 | const SYNC_WORD_LEN: u8 = SYNC_WORD.len() as u8; | ||
| 28 | const SYNC_WORD_LEN_BITS: u8 = SYNC_WORD_LEN * 8; | ||
| 29 | |||
| 30 | const TX_BUF_OFFSET: u8 = 128; | ||
| 31 | const RX_BUF_OFFSET: u8 = 0; | ||
| 32 | const LORA_PACKET_PARAMS: LoRaPacketParams = LoRaPacketParams::new() | ||
| 33 | .set_crc_en(true) | ||
| 34 | .set_preamble_len(PREAMBLE_LEN) | ||
| 35 | .set_payload_len(DATA_LEN) | ||
| 36 | .set_invert_iq(false) | ||
| 37 | .set_header_type(HeaderType::Fixed); | ||
| 38 | |||
| 39 | const LORA_MOD_PARAMS: LoRaModParams = LoRaModParams::new() | ||
| 40 | .set_bw(LoRaBandwidth::Bw125) | ||
| 41 | .set_cr(CodingRate::Cr45) | ||
| 42 | .set_ldro_en(true) | ||
| 43 | .set_sf(SpreadingFactor::Sf7); | ||
| 44 | |||
| 45 | // configuration for +10 dBm output power | ||
| 46 | // see table 35 "PA optimal setting and operating modes" | ||
| 47 | const PA_CONFIG: PaConfig = PaConfig::new().set_pa_duty_cycle(0x1).set_hp_max(0x0).set_pa(PaSel::Lp); | ||
| 48 | |||
| 49 | const TCXO_MODE: TcxoMode = TcxoMode::new() | ||
| 50 | .set_txco_trim(TcxoTrim::Volts1pt7) | ||
| 51 | .set_timeout(Timeout::from_duration_sat(core::time::Duration::from_millis(10))); | ||
| 52 | |||
| 53 | const TX_PARAMS: TxParams = TxParams::new().set_power(0x0D).set_ramp_time(RampTime::Micros40); | ||
| 54 | |||
| 55 | #[embassy_executor::main] | ||
| 56 | async fn main(_spawner: Spawner) { | ||
| 57 | let mut config = embassy_stm32::Config::default(); | ||
| 58 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; | ||
| 59 | let p = embassy_stm32::init(config); | ||
| 60 | |||
| 61 | let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); | ||
| 62 | let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low); | ||
| 63 | let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low); | ||
| 64 | |||
| 65 | let button = Input::new(p.PA0, Pull::Up); | ||
| 66 | let mut pin = ExtiInput::new(button, p.EXTI0); | ||
| 67 | |||
| 68 | static IRQ_SIGNAL: Signal<CriticalSectionRawMutex, ()> = Signal::new(); | ||
| 69 | let radio_irq = interrupt::take!(SUBGHZ_RADIO); | ||
| 70 | radio_irq.set_handler(|_| { | ||
| 71 | IRQ_SIGNAL.signal(()); | ||
| 72 | unsafe { interrupt::SUBGHZ_RADIO::steal() }.disable(); | ||
| 73 | }); | ||
| 74 | |||
| 75 | let mut radio = SubGhz::new(p.SUBGHZSPI, NoDma, NoDma); | ||
| 76 | |||
| 77 | defmt::info!("Radio ready for use"); | ||
| 78 | |||
| 79 | led1.set_low(); | ||
| 80 | |||
| 81 | led2.set_high(); | ||
| 82 | |||
| 83 | unwrap!(radio.set_standby(StandbyClk::Rc)); | ||
| 84 | unwrap!(radio.set_tcxo_mode(&TCXO_MODE)); | ||
| 85 | unwrap!(radio.set_standby(StandbyClk::Hse)); | ||
| 86 | unwrap!(radio.set_regulator_mode(RegMode::Ldo)); | ||
| 87 | unwrap!(radio.set_buffer_base_address(TX_BUF_OFFSET, RX_BUF_OFFSET)); | ||
| 88 | unwrap!(radio.set_pa_config(&PA_CONFIG)); | ||
| 89 | unwrap!(radio.set_pa_ocp(Ocp::Max60m)); | ||
| 90 | unwrap!(radio.set_tx_params(&TX_PARAMS)); | ||
| 91 | unwrap!(radio.set_packet_type(PacketType::LoRa)); | ||
| 92 | unwrap!(radio.set_lora_sync_word(LoRaSyncWord::Public)); | ||
| 93 | unwrap!(radio.set_lora_mod_params(&LORA_MOD_PARAMS)); | ||
| 94 | unwrap!(radio.set_lora_packet_params(&LORA_PACKET_PARAMS)); | ||
| 95 | unwrap!(radio.calibrate_image(CalibrateImage::ISM_863_870)); | ||
| 96 | unwrap!(radio.set_rf_frequency(&RF_FREQ)); | ||
| 97 | |||
| 98 | defmt::info!("Status: {:?}", unwrap!(radio.status())); | ||
| 99 | |||
| 100 | led2.set_low(); | ||
| 101 | |||
| 102 | loop { | ||
| 103 | pin.wait_for_rising_edge().await; | ||
| 104 | led3.set_high(); | ||
| 105 | unwrap!(radio.set_irq_cfg(&CfgIrq::new().irq_enable_all(Irq::TxDone))); | ||
| 106 | unwrap!(radio.write_buffer(TX_BUF_OFFSET, PING_DATA_BYTES)); | ||
| 107 | unwrap!(radio.set_tx(Timeout::DISABLED)); | ||
| 108 | |||
| 109 | radio_irq.enable(); | ||
| 110 | IRQ_SIGNAL.wait().await; | ||
| 111 | |||
| 112 | let (_, irq_status) = unwrap!(radio.irq_status()); | ||
| 113 | if irq_status & Irq::TxDone.mask() != 0 { | ||
| 114 | defmt::info!("TX done"); | ||
| 115 | } | ||
| 116 | unwrap!(radio.clear_irq_status(irq_status)); | ||
| 117 | led3.set_low(); | ||
| 118 | } | ||
| 119 | } | ||
