diff options
| author | ceekdee <[email protected]> | 2022-10-10 12:35:42 -0500 |
|---|---|---|
| committer | ceekdee <[email protected]> | 2022-10-10 12:35:42 -0500 |
| commit | 327d3cf0df7a1b116ea7ec44d36a569e6ba6ca16 (patch) | |
| tree | 67c69a2d511ba9dee2def2f7858e859d8150559b /embassy-lora | |
| parent | 79ba20d315f456ac525daf4c3d5dd0d2ce92ad2b (diff) | |
Change rak4631 feature to sx126x, removing use in board-specific processing; simplify the P2P examples; correct RSSI computation.
Diffstat (limited to 'embassy-lora')
| -rw-r--r-- | embassy-lora/Cargo.toml | 4 | ||||
| -rw-r--r-- | embassy-lora/src/lib.rs | 2 | ||||
| -rw-r--r-- | embassy-lora/src/sx126x/sx126x_lora/board_specific.rs | 28 | ||||
| -rw-r--r-- | embassy-lora/src/sx126x/sx126x_lora/subroutine.rs | 6 |
4 files changed, 14 insertions, 26 deletions
diff --git a/embassy-lora/Cargo.toml b/embassy-lora/Cargo.toml index bcb837d9d..ea2c3fe67 100644 --- a/embassy-lora/Cargo.toml +++ b/embassy-lora/Cargo.toml | |||
| @@ -9,7 +9,7 @@ src_base = "https://github.com/embassy-rs/embassy/blob/embassy-lora-v$VERSION/em | |||
| 9 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/" | 9 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/" |
| 10 | features = ["time", "defmt"] | 10 | features = ["time", "defmt"] |
| 11 | flavors = [ | 11 | flavors = [ |
| 12 | { name = "rak4631", target = "thumbv7em-none-eabihf", features = ["rak4631"] }, | 12 | { name = "sx126x", target = "thumbv7em-none-eabihf", features = ["sx126x"] }, |
| 13 | { name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any"] }, | 13 | { name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any"] }, |
| 14 | { name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any"] }, | 14 | { name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any"] }, |
| 15 | ] | 15 | ] |
| @@ -17,7 +17,7 @@ flavors = [ | |||
| 17 | [lib] | 17 | [lib] |
| 18 | 18 | ||
| 19 | [features] | 19 | [features] |
| 20 | rak4631 = [] | 20 | sx126x = [] |
| 21 | sx127x = [] | 21 | sx127x = [] |
| 22 | stm32wl = ["embassy-stm32", "embassy-stm32/subghz"] | 22 | stm32wl = ["embassy-stm32", "embassy-stm32/subghz"] |
| 23 | time = [] | 23 | time = [] |
diff --git a/embassy-lora/src/lib.rs b/embassy-lora/src/lib.rs index 342f66b2a..3e4748430 100644 --- a/embassy-lora/src/lib.rs +++ b/embassy-lora/src/lib.rs | |||
| @@ -7,7 +7,7 @@ pub(crate) mod fmt; | |||
| 7 | 7 | ||
| 8 | #[cfg(feature = "stm32wl")] | 8 | #[cfg(feature = "stm32wl")] |
| 9 | pub mod stm32wl; | 9 | pub mod stm32wl; |
| 10 | #[cfg(feature = "rak4631")] | 10 | #[cfg(feature = "sx126x")] |
| 11 | pub mod sx126x; | 11 | pub mod sx126x; |
| 12 | #[cfg(feature = "sx127x")] | 12 | #[cfg(feature = "sx127x")] |
| 13 | pub mod sx127x; | 13 | pub mod sx127x; |
diff --git a/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs b/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs index 1fb085887..a7b9e1486 100644 --- a/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs +++ b/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs | |||
| @@ -10,8 +10,7 @@ use super::LoRa; | |||
| 10 | // Defines the time required for the TCXO to wakeup [ms]. | 10 | // Defines the time required for the TCXO to wakeup [ms]. |
| 11 | const BRD_TCXO_WAKEUP_TIME: u32 = 10; | 11 | const BRD_TCXO_WAKEUP_TIME: u32 = 10; |
| 12 | 12 | ||
| 13 | // Provides board-specific functionality for Semtech SX126x-based boards. Use #[cfg(feature = "board_type")] to specify unique board functionality. | 13 | // Provides board-specific functionality for Semtech SX126x-based boards. |
| 14 | // The base implementation supports the RAK4631 board. | ||
| 15 | 14 | ||
| 16 | impl<SPI, CTRL, WAIT, BUS> LoRa<SPI, CTRL, WAIT> | 15 | impl<SPI, CTRL, WAIT, BUS> LoRa<SPI, CTRL, WAIT> |
| 17 | where | 16 | where |
| @@ -203,44 +202,33 @@ where | |||
| 203 | 202 | ||
| 204 | // Get the radio type | 203 | // Get the radio type |
| 205 | pub(super) fn brd_get_radio_type(&mut self) -> RadioType { | 204 | pub(super) fn brd_get_radio_type(&mut self) -> RadioType { |
| 206 | #[cfg(feature = "rak4631")] | ||
| 207 | RadioType::SX1262 | 205 | RadioType::SX1262 |
| 208 | } | 206 | } |
| 209 | 207 | ||
| 210 | // Quiesce the antenna(s). | 208 | // Quiesce the antenna(s). |
| 211 | pub(super) fn brd_ant_sleep(&mut self) -> Result<(), RadioError<BUS>> { | 209 | pub(super) fn brd_ant_sleep(&mut self) -> Result<(), RadioError<BUS>> { |
| 212 | #[cfg(feature = "rak4631")] | 210 | self.antenna_tx.set_low().map_err(|_| AntTx)?; |
| 213 | { | 211 | self.antenna_rx.set_low().map_err(|_| AntRx)?; |
| 214 | self.antenna_tx.set_low().map_err(|_| AntTx)?; | ||
| 215 | self.antenna_rx.set_low().map_err(|_| AntRx)?; | ||
| 216 | } | ||
| 217 | Ok(()) | 212 | Ok(()) |
| 218 | } | 213 | } |
| 219 | 214 | ||
| 220 | // Prepare the antenna(s) for a receive operation | 215 | // Prepare the antenna(s) for a receive operation |
| 221 | pub(super) fn brd_ant_set_rx(&mut self) -> Result<(), RadioError<BUS>> { | 216 | pub(super) fn brd_ant_set_rx(&mut self) -> Result<(), RadioError<BUS>> { |
| 222 | #[cfg(feature = "rak4631")] | 217 | self.antenna_tx.set_low().map_err(|_| AntTx)?; |
| 223 | { | 218 | self.antenna_rx.set_high().map_err(|_| AntRx)?; |
| 224 | self.antenna_tx.set_low().map_err(|_| AntTx)?; | ||
| 225 | self.antenna_rx.set_high().map_err(|_| AntRx)?; | ||
| 226 | } | ||
| 227 | Ok(()) | 219 | Ok(()) |
| 228 | } | 220 | } |
| 229 | 221 | ||
| 230 | // Prepare the antenna(s) for a send operation | 222 | // Prepare the antenna(s) for a send operation |
| 231 | pub(super) fn brd_ant_set_tx(&mut self) -> Result<(), RadioError<BUS>> { | 223 | pub(super) fn brd_ant_set_tx(&mut self) -> Result<(), RadioError<BUS>> { |
| 232 | #[cfg(feature = "rak4631")] | 224 | self.antenna_rx.set_low().map_err(|_| AntRx)?; |
| 233 | { | 225 | self.antenna_tx.set_high().map_err(|_| AntTx)?; |
| 234 | self.antenna_rx.set_low().map_err(|_| AntRx)?; | ||
| 235 | self.antenna_tx.set_high().map_err(|_| AntTx)?; | ||
| 236 | } | ||
| 237 | Ok(()) | 226 | Ok(()) |
| 238 | } | 227 | } |
| 239 | 228 | ||
| 240 | // Check if the given RF frequency is supported by the hardware | 229 | // Check if the given RF frequency is supported by the hardware |
| 241 | pub(super) async fn brd_check_rf_frequency(&mut self, _frequency: u32) -> Result<bool, RadioError<BUS>> { | 230 | pub(super) async fn brd_check_rf_frequency(&mut self, _frequency: u32) -> Result<bool, RadioError<BUS>> { |
| 242 | #[cfg(feature = "rak4631")] | 231 | Ok(true) |
| 243 | Ok(true) // all frequencies currently supported for the SX1262 within a rak4631 | ||
| 244 | } | 232 | } |
| 245 | 233 | ||
| 246 | // Get the duration required for the TCXO to wakeup [ms]. | 234 | // Get the duration required for the TCXO to wakeup [ms]. |
diff --git a/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs b/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs index 283e60993..2e78b919b 100644 --- a/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs +++ b/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs | |||
| @@ -564,7 +564,7 @@ where | |||
| 564 | pub(super) async fn sub_get_rssi_inst(&mut self) -> Result<i8, RadioError<BUS>> { | 564 | pub(super) async fn sub_get_rssi_inst(&mut self) -> Result<i8, RadioError<BUS>> { |
| 565 | let mut buffer = [0x00u8]; | 565 | let mut buffer = [0x00u8]; |
| 566 | self.brd_read_command(OpCode::GetRSSIInst, &mut buffer).await?; | 566 | self.brd_read_command(OpCode::GetRSSIInst, &mut buffer).await?; |
| 567 | let rssi: i8 = (-(buffer[0] as i8)) >> 1; // check this ??? | 567 | let rssi: i8 = ((-(buffer[0] as i32)) >> 1) as i8; // check this ??? |
| 568 | Ok(rssi) | 568 | Ok(rssi) |
| 569 | } | 569 | } |
| 570 | 570 | ||
| @@ -597,9 +597,9 @@ where | |||
| 597 | self.brd_read_command(OpCode::GetPacketStatus, &mut status).await?; | 597 | self.brd_read_command(OpCode::GetPacketStatus, &mut status).await?; |
| 598 | 598 | ||
| 599 | // check this ??? | 599 | // check this ??? |
| 600 | let rssi = (-(status[0] as i8)) >> 1; | 600 | let rssi = ((-(status[0] as i32)) >> 1) as i8; |
| 601 | let snr = ((status[1] as i8) + 2) >> 2; | 601 | let snr = ((status[1] as i8) + 2) >> 2; |
| 602 | let signal_rssi = (-(status[2] as i8)) >> 1; | 602 | let signal_rssi = ((-(status[2] as i32)) >> 1) as i8; |
| 603 | let freq_error = self.frequency_error; | 603 | let freq_error = self.frequency_error; |
| 604 | 604 | ||
| 605 | Ok(PacketStatus { | 605 | Ok(PacketStatus { |
