Add lora-phy examples.

This commit is contained in:
ceekdee
2023-04-23 18:32:34 -05:00
parent a3f727e2e1
commit 73f25093c7
20 changed files with 1218 additions and 316 deletions

View File

@ -1,6 +1,6 @@
//! This example runs on the RAK4631 WisBlock, which has an nRF52840 MCU and Semtech Sx126x radio.
//! Other nrf/sx126x combinations may work with appropriate pin modifications.
//! It demonstates LORA CAD functionality.
//! It demonstrates LORA CAD functionality.
#![no_std]
#![no_main]
#![macro_use]
@ -17,6 +17,8 @@ use lora_phy::sx1261_2::SX1261_2;
use lora_phy::LoRa;
use {defmt_rtt as _, panic_probe as _};
const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region
bind_interrupts!(struct Irqs {
SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1 => spim::InterruptHandler<peripherals::TWISPI1>;
});
@ -59,7 +61,12 @@ async fn main(_spawner: Spawner) {
start_indicator.set_low();
let mdltn_params = {
match lora.create_modulation_params(SpreadingFactor::_10, Bandwidth::_250KHz, CodingRate::_4_8, 903900000) {
match lora.create_modulation_params(
SpreadingFactor::_10,
Bandwidth::_250KHz,
CodingRate::_4_8,
LORA_FREQUENCY_IN_HZ,
) {
Ok(mp) => mp,
Err(err) => {
info!("Radio error = {}", err);
@ -84,7 +91,7 @@ async fn main(_spawner: Spawner) {
info!("cad successful without activity detected")
}
debug_indicator.set_high();
Timer::after(Duration::from_secs(15)).await;
Timer::after(Duration::from_secs(5)).await;
debug_indicator.set_low();
}
Err(err) => info!("cad unsuccessful = {}", err),