aboutsummaryrefslogtreecommitdiff
path: root/embassy-lora
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-lora')
-rw-r--r--embassy-lora/Cargo.toml2
-rw-r--r--embassy-lora/src/sx127x/mod.rs24
-rw-r--r--embassy-lora/src/sx127x/sx127x_lora/mod.rs9
3 files changed, 19 insertions, 16 deletions
diff --git a/embassy-lora/Cargo.toml b/embassy-lora/Cargo.toml
index 9f04adabb..c27641521 100644
--- a/embassy-lora/Cargo.toml
+++ b/embassy-lora/Cargo.toml
@@ -18,6 +18,8 @@ log = { version = "0.4.14", optional = true }
18 18
19embassy = { version = "0.1.0", path = "../embassy", default-features = false } 19embassy = { version = "0.1.0", path = "../embassy", default-features = false }
20embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true } 20embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true }
21embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.6", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy", optional = true}
22embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy"}
21embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common", default-features = false } 23embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common", default-features = false }
22futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } 24futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] }
23embedded-hal = { version = "0.2", features = ["unproven"] } 25embedded-hal = { version = "0.2", features = ["unproven"] }
diff --git a/embassy-lora/src/sx127x/mod.rs b/embassy-lora/src/sx127x/mod.rs
index c26628b0f..6a15dab82 100644
--- a/embassy-lora/src/sx127x/mod.rs
+++ b/embassy-lora/src/sx127x/mod.rs
@@ -1,7 +1,7 @@
1use core::future::Future; 1use core::future::Future;
2use embassy::traits::gpio::WaitForRisingEdge;
3use embassy::traits::spi::*;
4use embedded_hal::digital::v2::OutputPin; 2use embedded_hal::digital::v2::OutputPin;
3use embedded_hal_async::digital::Wait;
4use embedded_hal_async::spi::*;
5use lorawan_device::async_device::{ 5use lorawan_device::async_device::{
6 radio::{Bandwidth, PhyRxTx, RfConfig, RxQuality, SpreadingFactor, TxConfig}, 6 radio::{Bandwidth, PhyRxTx, RfConfig, RxQuality, SpreadingFactor, TxConfig},
7 Timings, 7 Timings,
@@ -20,11 +20,11 @@ pub trait RadioSwitch {
20/// Semtech Sx127x radio peripheral 20/// Semtech Sx127x radio peripheral
21pub struct Sx127xRadio<SPI, CS, RESET, E, I, RFS> 21pub struct Sx127xRadio<SPI, CS, RESET, E, I, RFS>
22where 22where
23 SPI: FullDuplex<u8, Error = E> + 'static, 23 SPI: ReadWrite<u8, Error = E> + 'static,
24 E: 'static, 24 E: 'static,
25 CS: OutputPin + 'static, 25 CS: OutputPin + 'static,
26 RESET: OutputPin + 'static, 26 RESET: OutputPin + 'static,
27 I: WaitForRisingEdge + 'static, 27 I: Wait + 'static,
28 RFS: RadioSwitch + 'static, 28 RFS: RadioSwitch + 'static,
29{ 29{
30 radio: LoRa<SPI, CS, RESET>, 30 radio: LoRa<SPI, CS, RESET>,
@@ -42,10 +42,10 @@ pub enum State {
42 42
43impl<SPI, CS, RESET, E, I, RFS> Sx127xRadio<SPI, CS, RESET, E, I, RFS> 43impl<SPI, CS, RESET, E, I, RFS> Sx127xRadio<SPI, CS, RESET, E, I, RFS>
44where 44where
45 SPI: FullDuplex<u8, Error = E> + 'static, 45 SPI: ReadWrite<u8, Error = E> + 'static,
46 CS: OutputPin + 'static, 46 CS: OutputPin + 'static,
47 RESET: OutputPin + 'static, 47 RESET: OutputPin + 'static,
48 I: WaitForRisingEdge + 'static, 48 I: Wait + 'static,
49 RFS: RadioSwitch + 'static, 49 RFS: RadioSwitch + 'static,
50 E: 'static, 50 E: 'static,
51{ 51{
@@ -64,10 +64,10 @@ where
64 64
65impl<SPI, CS, RESET, E, I, RFS> Timings for Sx127xRadio<SPI, CS, RESET, E, I, RFS> 65impl<SPI, CS, RESET, E, I, RFS> Timings for Sx127xRadio<SPI, CS, RESET, E, I, RFS>
66where 66where
67 SPI: FullDuplex<u8, Error = E> + 'static, 67 SPI: ReadWrite<u8, Error = E> + 'static,
68 CS: OutputPin + 'static, 68 CS: OutputPin + 'static,
69 RESET: OutputPin + 'static, 69 RESET: OutputPin + 'static,
70 I: WaitForRisingEdge + 'static, 70 I: Wait + 'static,
71 RFS: RadioSwitch + 'static, 71 RFS: RadioSwitch + 'static,
72{ 72{
73 fn get_rx_window_offset_ms(&self) -> i32 { 73 fn get_rx_window_offset_ms(&self) -> i32 {
@@ -80,11 +80,11 @@ where
80 80
81impl<SPI, CS, RESET, E, I, RFS> PhyRxTx for Sx127xRadio<SPI, CS, RESET, E, I, RFS> 81impl<SPI, CS, RESET, E, I, RFS> PhyRxTx for Sx127xRadio<SPI, CS, RESET, E, I, RFS>
82where 82where
83 SPI: FullDuplex<u8, Error = E> + 'static, 83 SPI: ReadWrite<u8, Error = E> + 'static,
84 CS: OutputPin + 'static, 84 CS: OutputPin + 'static,
85 E: 'static, 85 E: 'static,
86 RESET: OutputPin + 'static, 86 RESET: OutputPin + 'static,
87 I: WaitForRisingEdge + 'static, 87 I: Wait + 'static,
88 RFS: RadioSwitch + 'static, 88 RFS: RadioSwitch + 'static,
89{ 89{
90 type PhyError = Sx127xError; 90 type PhyError = Sx127xError;
@@ -126,7 +126,7 @@ where
126 self.radio.transmit_start(buf).await?; 126 self.radio.transmit_start(buf).await?;
127 127
128 loop { 128 loop {
129 self.irq.wait_for_rising_edge().await; 129 self.irq.wait_for_rising_edge().await.unwrap();
130 self.radio.set_mode(RadioMode::Stdby).await.ok().unwrap(); 130 self.radio.set_mode(RadioMode::Stdby).await.ok().unwrap();
131 let irq = self.radio.clear_irq().await.ok().unwrap(); 131 let irq = self.radio.clear_irq().await.ok().unwrap();
132 if (irq & IRQ::IrqTxDoneMask.addr()) != 0 { 132 if (irq & IRQ::IrqTxDoneMask.addr()) != 0 {
@@ -171,7 +171,7 @@ where
171 self.radio.set_mode(RadioMode::RxContinuous).await?; 171 self.radio.set_mode(RadioMode::RxContinuous).await?;
172 172
173 loop { 173 loop {
174 self.irq.wait_for_rising_edge().await; 174 self.irq.wait_for_rising_edge().await.unwrap();
175 self.radio.set_mode(RadioMode::Stdby).await.ok().unwrap(); 175 self.radio.set_mode(RadioMode::Stdby).await.ok().unwrap();
176 let irq = self.radio.clear_irq().await.ok().unwrap(); 176 let irq = self.radio.clear_irq().await.ok().unwrap();
177 if (irq & IRQ::IrqRxDoneMask.addr()) != 0 { 177 if (irq & IRQ::IrqRxDoneMask.addr()) != 0 {
diff --git a/embassy-lora/src/sx127x/sx127x_lora/mod.rs b/embassy-lora/src/sx127x/sx127x_lora/mod.rs
index a903779ca..6fbd3a4bd 100644
--- a/embassy-lora/src/sx127x/sx127x_lora/mod.rs
+++ b/embassy-lora/src/sx127x/sx127x_lora/mod.rs
@@ -7,8 +7,8 @@
7 7
8use bit_field::BitField; 8use bit_field::BitField;
9use embassy::time::{Duration, Timer}; 9use embassy::time::{Duration, Timer};
10use embassy::traits::spi::*;
11use embedded_hal::digital::v2::OutputPin; 10use embedded_hal::digital::v2::OutputPin;
11use embedded_hal_async::spi::ReadWrite;
12 12
13mod register; 13mod register;
14use self::register::PaConfig; 14use self::register::PaConfig;
@@ -36,9 +36,10 @@ pub enum Error<SPI, CS, RESET> {
36 Transmitting, 36 Transmitting,
37} 37}
38 38
39use super::sx127x_lora::register::{FskDataModulationShaping, FskRampUpRamDown};
40use Error::*; 39use Error::*;
41 40
41use super::sx127x_lora::register::{FskDataModulationShaping, FskRampUpRamDown};
42
42#[cfg(not(feature = "version_0x09"))] 43#[cfg(not(feature = "version_0x09"))]
43const VERSION_CHECK: u8 = 0x12; 44const VERSION_CHECK: u8 = 0x12;
44 45
@@ -47,7 +48,7 @@ const VERSION_CHECK: u8 = 0x09;
47 48
48impl<SPI, CS, RESET, E> LoRa<SPI, CS, RESET> 49impl<SPI, CS, RESET, E> LoRa<SPI, CS, RESET>
49where 50where
50 SPI: FullDuplex<u8, Error = E>, 51 SPI: ReadWrite<u8, Error = E>,
51 CS: OutputPin, 52 CS: OutputPin,
52 RESET: OutputPin, 53 RESET: OutputPin,
53{ 54{
@@ -546,7 +547,7 @@ where
546 547
547 let _ = self 548 let _ = self
548 .spi 549 .spi
549 .read_write(&mut buffer, &[reg & 0x7f, 0]) 550 .transfer(&mut buffer, &[reg & 0x7f, 0])
550 .await 551 .await
551 .map_err(SPI)?; 552 .map_err(SPI)?;
552 553