diff options
| author | ceekdee <[email protected]> | 2022-10-08 14:32:22 -0500 |
|---|---|---|
| committer | ceekdee <[email protected]> | 2022-10-08 14:32:22 -0500 |
| commit | f554962f54b9f9e8f85a0dd099635619bd1acd1d (patch) | |
| tree | 6a5eb23c04618dd6a333061bdf265ead9e527928 | |
| parent | bb84d7a0aeee967a2facdfb0590b03493b703e9f (diff) | |
Improve generics and consolidate antenna handling
| -rw-r--r-- | embassy-lora/src/sx126x/mod.rs | 48 | ||||
| -rw-r--r-- | embassy-lora/src/sx126x/sx126x_lora/board_specific.rs | 39 | ||||
| -rw-r--r-- | embassy-lora/src/sx126x/sx126x_lora/mod.rs | 19 | ||||
| -rw-r--r-- | embassy-lora/src/sx126x/sx126x_lora/subroutine.rs | 34 | ||||
| -rw-r--r-- | examples/nrf/src/bin/lora_p2p_report.rs | 8 | ||||
| -rw-r--r-- | examples/nrf/src/bin/lora_p2p_sense.rs | 8 |
6 files changed, 69 insertions, 87 deletions
diff --git a/embassy-lora/src/sx126x/mod.rs b/embassy-lora/src/sx126x/mod.rs index d67c7b109..ed8cb4059 100644 --- a/embassy-lora/src/sx126x/mod.rs +++ b/embassy-lora/src/sx126x/mod.rs | |||
| @@ -13,35 +13,29 @@ use sx126x_lora::LoRa; | |||
| 13 | use self::sx126x_lora::mod_params::RadioError; | 13 | use self::sx126x_lora::mod_params::RadioError; |
| 14 | 14 | ||
| 15 | /// Semtech Sx126x LoRa peripheral | 15 | /// Semtech Sx126x LoRa peripheral |
| 16 | pub struct Sx126xRadio<SPI, CS, RESET, ANTRX, ANTTX, WAIT, BUS> | 16 | pub struct Sx126xRadio<SPI, CTRL, WAIT, BUS> |
| 17 | where | 17 | where |
| 18 | SPI: SpiBus<u8, Error = BUS> + 'static, | 18 | SPI: SpiBus<u8, Error = BUS> + 'static, |
| 19 | CS: OutputPin + 'static, | 19 | CTRL: OutputPin + 'static, |
| 20 | RESET: OutputPin + 'static, | ||
| 21 | ANTRX: OutputPin + 'static, | ||
| 22 | ANTTX: OutputPin + 'static, | ||
| 23 | WAIT: Wait + 'static, | 20 | WAIT: Wait + 'static, |
| 24 | BUS: Error + Format + 'static, | 21 | BUS: Error + Format + 'static, |
| 25 | { | 22 | { |
| 26 | pub lora: LoRa<SPI, CS, RESET, ANTRX, ANTTX, WAIT>, | 23 | pub lora: LoRa<SPI, CTRL, WAIT>, |
| 27 | } | 24 | } |
| 28 | 25 | ||
| 29 | impl<SPI, CS, RESET, ANTRX, ANTTX, WAIT, BUS> Sx126xRadio<SPI, CS, RESET, ANTRX, ANTTX, WAIT, BUS> | 26 | impl<SPI, CTRL, WAIT, BUS> Sx126xRadio<SPI, CTRL, WAIT, BUS> |
| 30 | where | 27 | where |
| 31 | SPI: SpiBus<u8, Error = BUS> + 'static, | 28 | SPI: SpiBus<u8, Error = BUS> + 'static, |
| 32 | CS: OutputPin + 'static, | 29 | CTRL: OutputPin + 'static, |
| 33 | RESET: OutputPin + 'static, | ||
| 34 | ANTRX: OutputPin + 'static, | ||
| 35 | ANTTX: OutputPin + 'static, | ||
| 36 | WAIT: Wait + 'static, | 30 | WAIT: Wait + 'static, |
| 37 | BUS: Error + Format + 'static, | 31 | BUS: Error + Format + 'static, |
| 38 | { | 32 | { |
| 39 | pub async fn new( | 33 | pub async fn new( |
| 40 | spi: SPI, | 34 | spi: SPI, |
| 41 | cs: CS, | 35 | cs: CTRL, |
| 42 | reset: RESET, | 36 | reset: CTRL, |
| 43 | antenna_rx: ANTRX, | 37 | antenna_rx: CTRL, |
| 44 | antenna_tx: ANTTX, | 38 | antenna_tx: CTRL, |
| 45 | dio1: WAIT, | 39 | dio1: WAIT, |
| 46 | busy: WAIT, | 40 | busy: WAIT, |
| 47 | enable_public_network: bool, | 41 | enable_public_network: bool, |
| @@ -53,13 +47,10 @@ where | |||
| 53 | } | 47 | } |
| 54 | } | 48 | } |
| 55 | 49 | ||
| 56 | impl<SPI, CS, RESET, ANTRX, ANTTX, WAIT, BUS> Timings for Sx126xRadio<SPI, CS, RESET, ANTRX, ANTTX, WAIT, BUS> | 50 | impl<SPI, CTRL, WAIT, BUS> Timings for Sx126xRadio<SPI, CTRL, WAIT, BUS> |
| 57 | where | 51 | where |
| 58 | SPI: SpiBus<u8, Error = BUS> + 'static, | 52 | SPI: SpiBus<u8, Error = BUS> + 'static, |
| 59 | CS: OutputPin + 'static, | 53 | CTRL: OutputPin + 'static, |
| 60 | RESET: OutputPin + 'static, | ||
| 61 | ANTRX: OutputPin + 'static, | ||
| 62 | ANTTX: OutputPin + 'static, | ||
| 63 | WAIT: Wait + 'static, | 54 | WAIT: Wait + 'static, |
| 64 | BUS: Error + Format + 'static, | 55 | BUS: Error + Format + 'static, |
| 65 | { | 56 | { |
| @@ -71,13 +62,10 @@ where | |||
| 71 | } | 62 | } |
| 72 | } | 63 | } |
| 73 | 64 | ||
| 74 | impl<SPI, CS, RESET, ANTRX, ANTTX, WAIT, BUS> PhyRxTx for Sx126xRadio<SPI, CS, RESET, ANTRX, ANTTX, WAIT, BUS> | 65 | impl<SPI, CTRL, WAIT, BUS> PhyRxTx for Sx126xRadio<SPI, CTRL, WAIT, BUS> |
| 75 | where | 66 | where |
| 76 | SPI: SpiBus<u8, Error = BUS> + 'static, | 67 | SPI: SpiBus<u8, Error = BUS> + 'static, |
| 77 | CS: OutputPin + 'static, | 68 | CTRL: OutputPin + 'static, |
| 78 | RESET: OutputPin + 'static, | ||
| 79 | ANTRX: OutputPin + 'static, | ||
| 80 | ANTTX: OutputPin + 'static, | ||
| 81 | WAIT: Wait + 'static, | 69 | WAIT: Wait + 'static, |
| 82 | BUS: Error + Format + 'static, | 70 | BUS: Error + Format + 'static, |
| 83 | { | 71 | { |
| @@ -86,10 +74,7 @@ where | |||
| 86 | type TxFuture<'m> = impl Future<Output = Result<u32, Self::PhyError>> + 'm | 74 | type TxFuture<'m> = impl Future<Output = Result<u32, Self::PhyError>> + 'm |
| 87 | where | 75 | where |
| 88 | SPI: 'm, | 76 | SPI: 'm, |
| 89 | CS: 'm, | 77 | CTRL: 'm, |
| 90 | RESET: 'm, | ||
| 91 | ANTRX: 'm, | ||
| 92 | ANTTX: 'm, | ||
| 93 | WAIT: 'm, | 78 | WAIT: 'm, |
| 94 | BUS: 'm; | 79 | BUS: 'm; |
| 95 | 80 | ||
| @@ -122,10 +107,7 @@ where | |||
| 122 | type RxFuture<'m> = impl Future<Output = Result<(usize, RxQuality), Self::PhyError>> + 'm | 107 | type RxFuture<'m> = impl Future<Output = Result<(usize, RxQuality), Self::PhyError>> + 'm |
| 123 | where | 108 | where |
| 124 | SPI: 'm, | 109 | SPI: 'm, |
| 125 | CS: 'm, | 110 | CTRL: 'm, |
| 126 | RESET: 'm, | ||
| 127 | ANTRX: 'm, | ||
| 128 | ANTTX: 'm, | ||
| 129 | WAIT: 'm, | 111 | WAIT: 'm, |
| 130 | BUS: 'm; | 112 | BUS: 'm; |
| 131 | 113 | ||
diff --git a/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs b/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs index 5b4891c04..1fb085887 100644 --- a/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs +++ b/embassy-lora/src/sx126x/sx126x_lora/board_specific.rs | |||
| @@ -13,13 +13,10 @@ const BRD_TCXO_WAKEUP_TIME: u32 = 10; | |||
| 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. Use #[cfg(feature = "board_type")] to specify unique board functionality. |
| 14 | // The base implementation supports the RAK4631 board. | 14 | // The base implementation supports the RAK4631 board. |
| 15 | 15 | ||
| 16 | impl<SPI, CS, RESET, ANTRX, ANTTX, WAIT, BUS> LoRa<SPI, CS, RESET, ANTRX, ANTTX, WAIT> | 16 | impl<SPI, CTRL, WAIT, BUS> LoRa<SPI, CTRL, WAIT> |
| 17 | where | 17 | where |
| 18 | SPI: SpiBus<u8, Error = BUS>, | 18 | SPI: SpiBus<u8, Error = BUS>, |
| 19 | CS: OutputPin, | 19 | CTRL: OutputPin, |
| 20 | RESET: OutputPin, | ||
| 21 | ANTRX: OutputPin, | ||
| 22 | ANTTX: OutputPin, | ||
| 23 | WAIT: Wait, | 20 | WAIT: Wait, |
| 24 | { | 21 | { |
| 25 | // De-initialize the radio I/Os pins interface. Useful when going into MCU low power modes. | 22 | // De-initialize the radio I/Os pins interface. Useful when going into MCU low power modes. |
| @@ -210,14 +207,34 @@ where | |||
| 210 | RadioType::SX1262 | 207 | RadioType::SX1262 |
| 211 | } | 208 | } |
| 212 | 209 | ||
| 213 | // Initialize the RF switch I/O pins interface | 210 | // Quiesce the antenna(s). |
| 214 | pub(super) async fn brd_ant_sw_on(&mut self) -> Result<(), RadioError<BUS>> { | 211 | pub(super) fn brd_ant_sleep(&mut self) -> Result<(), RadioError<BUS>> { |
| 215 | Ok(()) // no operation currently | 212 | #[cfg(feature = "rak4631")] |
| 213 | { | ||
| 214 | self.antenna_tx.set_low().map_err(|_| AntTx)?; | ||
| 215 | self.antenna_rx.set_low().map_err(|_| AntRx)?; | ||
| 216 | } | ||
| 217 | Ok(()) | ||
| 216 | } | 218 | } |
| 217 | 219 | ||
| 218 | // De-initialize the RF switch I/O pins interface for MCU low power modes | 220 | // Prepare the antenna(s) for a receive operation |
| 219 | pub(super) async fn brd_ant_sw_off(&mut self) -> Result<(), RadioError<BUS>> { | 221 | pub(super) fn brd_ant_set_rx(&mut self) -> Result<(), RadioError<BUS>> { |
| 220 | Ok(()) // no operation currently | 222 | #[cfg(feature = "rak4631")] |
| 223 | { | ||
| 224 | self.antenna_tx.set_low().map_err(|_| AntTx)?; | ||
| 225 | self.antenna_rx.set_high().map_err(|_| AntRx)?; | ||
| 226 | } | ||
| 227 | Ok(()) | ||
| 228 | } | ||
| 229 | |||
| 230 | // Prepare the antenna(s) for a send operation | ||
| 231 | pub(super) fn brd_ant_set_tx(&mut self) -> Result<(), RadioError<BUS>> { | ||
| 232 | #[cfg(feature = "rak4631")] | ||
| 233 | { | ||
| 234 | self.antenna_rx.set_low().map_err(|_| AntRx)?; | ||
| 235 | self.antenna_tx.set_high().map_err(|_| AntTx)?; | ||
| 236 | } | ||
| 237 | Ok(()) | ||
| 221 | } | 238 | } |
| 222 | 239 | ||
| 223 | // Check if the given RF frequency is supported by the hardware | 240 | // Check if the given RF frequency is supported by the hardware |
diff --git a/embassy-lora/src/sx126x/sx126x_lora/mod.rs b/embassy-lora/src/sx126x/sx126x_lora/mod.rs index 53fbde749..280f26d51 100644 --- a/embassy-lora/src/sx126x/sx126x_lora/mod.rs +++ b/embassy-lora/src/sx126x/sx126x_lora/mod.rs | |||
| @@ -26,12 +26,12 @@ const LORA_BANDWIDTHS: [Bandwidth; 3] = [Bandwidth::_125KHz, Bandwidth::_250KHz, | |||
| 26 | const RADIO_WAKEUP_TIME: u32 = 3; | 26 | const RADIO_WAKEUP_TIME: u32 = 3; |
| 27 | 27 | ||
| 28 | /// Provides high-level access to Semtech SX126x-based boards | 28 | /// Provides high-level access to Semtech SX126x-based boards |
| 29 | pub struct LoRa<SPI, CS, RESET, ANTRX, ANTTX, WAIT> { | 29 | pub struct LoRa<SPI, CTRL, WAIT> { |
| 30 | spi: SPI, | 30 | spi: SPI, |
| 31 | cs: CS, | 31 | cs: CTRL, |
| 32 | reset: RESET, | 32 | reset: CTRL, |
| 33 | antenna_rx: ANTRX, | 33 | antenna_rx: CTRL, |
| 34 | antenna_tx: ANTTX, | 34 | antenna_tx: CTRL, |
| 35 | dio1: WAIT, | 35 | dio1: WAIT, |
| 36 | busy: WAIT, | 36 | busy: WAIT, |
| 37 | operating_mode: RadioMode, | 37 | operating_mode: RadioMode, |
| @@ -45,17 +45,14 @@ pub struct LoRa<SPI, CS, RESET, ANTRX, ANTTX, WAIT> { | |||
| 45 | frequency_error: u32, | 45 | frequency_error: u32, |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | impl<SPI, CS, RESET, ANTRX, ANTTX, WAIT, BUS> LoRa<SPI, CS, RESET, ANTRX, ANTTX, WAIT> | 48 | impl<SPI, CTRL, WAIT, BUS> LoRa<SPI, CTRL, WAIT> |
| 49 | where | 49 | where |
| 50 | SPI: SpiBus<u8, Error = BUS>, | 50 | SPI: SpiBus<u8, Error = BUS>, |
| 51 | CS: OutputPin, | 51 | CTRL: OutputPin, |
| 52 | RESET: OutputPin, | ||
| 53 | ANTRX: OutputPin, | ||
| 54 | ANTTX: OutputPin, | ||
| 55 | WAIT: Wait, | 52 | WAIT: Wait, |
| 56 | { | 53 | { |
| 57 | /// Builds and returns a new instance of the radio. Only one instance of the radio should exist at a time () | 54 | /// Builds and returns a new instance of the radio. Only one instance of the radio should exist at a time () |
| 58 | pub fn new(spi: SPI, cs: CS, reset: RESET, antenna_rx: ANTRX, antenna_tx: ANTTX, dio1: WAIT, busy: WAIT) -> Self { | 55 | pub fn new(spi: SPI, cs: CTRL, reset: CTRL, antenna_rx: CTRL, antenna_tx: CTRL, dio1: WAIT, busy: WAIT) -> Self { |
| 59 | Self { | 56 | Self { |
| 60 | spi, | 57 | spi, |
| 61 | cs, | 58 | cs, |
diff --git a/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs b/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs index 02a0a72ec..283e60993 100644 --- a/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs +++ b/embassy-lora/src/sx126x/sx126x_lora/subroutine.rs | |||
| @@ -19,13 +19,10 @@ const SX126X_MAX_LORA_SYMB_NUM_TIMEOUT: u8 = 248; | |||
| 19 | 19 | ||
| 20 | // Provides board-specific functionality for Semtech SX126x-based boards | 20 | // Provides board-specific functionality for Semtech SX126x-based boards |
| 21 | 21 | ||
| 22 | impl<SPI, CS, RESET, ANTRX, ANTTX, WAIT, BUS> LoRa<SPI, CS, RESET, ANTRX, ANTTX, WAIT> | 22 | impl<SPI, CTRL, WAIT, BUS> LoRa<SPI, CTRL, WAIT> |
| 23 | where | 23 | where |
| 24 | SPI: SpiBus<u8, Error = BUS>, | 24 | SPI: SpiBus<u8, Error = BUS>, |
| 25 | CS: OutputPin, | 25 | CTRL: OutputPin, |
| 26 | RESET: OutputPin, | ||
| 27 | ANTRX: OutputPin, | ||
| 28 | ANTTX: OutputPin, | ||
| 29 | WAIT: Wait, | 26 | WAIT: Wait, |
| 30 | { | 27 | { |
| 31 | // Initialize the radio driver | 28 | // Initialize the radio driver |
| @@ -44,7 +41,6 @@ where | |||
| 44 | let operating_mode = self.brd_get_operating_mode(); | 41 | let operating_mode = self.brd_get_operating_mode(); |
| 45 | if operating_mode == RadioMode::Sleep || operating_mode == RadioMode::ReceiveDutyCycle { | 42 | if operating_mode == RadioMode::Sleep || operating_mode == RadioMode::ReceiveDutyCycle { |
| 46 | self.brd_wakeup().await?; | 43 | self.brd_wakeup().await?; |
| 47 | self.brd_ant_sw_on().await?; | ||
| 48 | } | 44 | } |
| 49 | self.brd_wait_on_busy().await?; | 45 | self.brd_wait_on_busy().await?; |
| 50 | Ok(()) | 46 | Ok(()) |
| @@ -117,10 +113,7 @@ where | |||
| 117 | 113 | ||
| 118 | // Set the radio in sleep mode | 114 | // Set the radio in sleep mode |
| 119 | pub(super) async fn sub_set_sleep(&mut self, sleep_config: SleepParams) -> Result<(), RadioError<BUS>> { | 115 | pub(super) async fn sub_set_sleep(&mut self, sleep_config: SleepParams) -> Result<(), RadioError<BUS>> { |
| 120 | self.brd_ant_sw_off().await?; | 116 | self.brd_ant_sleep()?; |
| 121 | |||
| 122 | let _fix_rx = self.antenna_rx.set_low(); | ||
| 123 | let _fix_tx = self.antenna_tx.set_low(); | ||
| 124 | 117 | ||
| 125 | if !sleep_config.warm_start { | 118 | if !sleep_config.warm_start { |
| 126 | self.image_calibrated = false; | 119 | self.image_calibrated = false; |
| @@ -141,8 +134,7 @@ where | |||
| 141 | self.brd_set_operating_mode(RadioMode::StandbyXOSC); | 134 | self.brd_set_operating_mode(RadioMode::StandbyXOSC); |
| 142 | } | 135 | } |
| 143 | 136 | ||
| 144 | let _fix_rx = self.antenna_rx.set_low(); | 137 | self.brd_ant_sleep()?; |
| 145 | let _fix_tx = self.antenna_tx.set_low(); | ||
| 146 | Ok(()) | 138 | Ok(()) |
| 147 | } | 139 | } |
| 148 | 140 | ||
| @@ -162,8 +154,7 @@ where | |||
| 162 | Self::timeout_3(timeout), | 154 | Self::timeout_3(timeout), |
| 163 | ]; | 155 | ]; |
| 164 | 156 | ||
| 165 | let _fix_rx = self.antenna_rx.set_low(); | 157 | self.brd_ant_set_tx()?; |
| 166 | let _fix_tx = self.antenna_tx.set_high(); | ||
| 167 | 158 | ||
| 168 | self.brd_set_operating_mode(RadioMode::Transmit); | 159 | self.brd_set_operating_mode(RadioMode::Transmit); |
| 169 | self.brd_write_command(OpCode::SetTx, &buffer).await?; | 160 | self.brd_write_command(OpCode::SetTx, &buffer).await?; |
| @@ -178,8 +169,7 @@ where | |||
| 178 | Self::timeout_3(timeout), | 169 | Self::timeout_3(timeout), |
| 179 | ]; | 170 | ]; |
| 180 | 171 | ||
| 181 | let _fix_rx = self.antenna_rx.set_high(); | 172 | self.brd_ant_set_rx()?; |
| 182 | let _fix_tx = self.antenna_tx.set_low(); | ||
| 183 | 173 | ||
| 184 | self.brd_set_operating_mode(RadioMode::Receive); | 174 | self.brd_set_operating_mode(RadioMode::Receive); |
| 185 | self.brd_write_registers(Register::RxGain, &[0x94u8]).await?; | 175 | self.brd_write_registers(Register::RxGain, &[0x94u8]).await?; |
| @@ -195,8 +185,7 @@ where | |||
| 195 | Self::timeout_3(timeout), | 185 | Self::timeout_3(timeout), |
| 196 | ]; | 186 | ]; |
| 197 | 187 | ||
| 198 | let _fix_rx = self.antenna_rx.set_high(); | 188 | self.brd_ant_set_rx()?; |
| 199 | let _fix_tx = self.antenna_tx.set_low(); | ||
| 200 | 189 | ||
| 201 | self.brd_set_operating_mode(RadioMode::Receive); | 190 | self.brd_set_operating_mode(RadioMode::Receive); |
| 202 | // set max LNA gain, increase current by ~2mA for around ~3dB in sensitivity | 191 | // set max LNA gain, increase current by ~2mA for around ~3dB in sensitivity |
| @@ -225,8 +214,7 @@ where | |||
| 225 | 214 | ||
| 226 | // Set the radio in CAD mode | 215 | // Set the radio in CAD mode |
| 227 | pub(super) async fn sub_set_cad(&mut self) -> Result<(), RadioError<BUS>> { | 216 | pub(super) async fn sub_set_cad(&mut self) -> Result<(), RadioError<BUS>> { |
| 228 | let _fix_rx = self.antenna_rx.set_high(); | 217 | self.brd_ant_set_rx()?; |
| 229 | let _fix_tx = self.antenna_tx.set_low(); | ||
| 230 | 218 | ||
| 231 | self.brd_write_command(OpCode::SetCAD, &[]).await?; | 219 | self.brd_write_command(OpCode::SetCAD, &[]).await?; |
| 232 | self.brd_set_operating_mode(RadioMode::ChannelActivityDetection); | 220 | self.brd_set_operating_mode(RadioMode::ChannelActivityDetection); |
| @@ -235,8 +223,7 @@ where | |||
| 235 | 223 | ||
| 236 | // Set the radio in continuous wave transmission mode | 224 | // Set the radio in continuous wave transmission mode |
| 237 | pub(super) async fn sub_set_tx_continuous_wave(&mut self) -> Result<(), RadioError<BUS>> { | 225 | pub(super) async fn sub_set_tx_continuous_wave(&mut self) -> Result<(), RadioError<BUS>> { |
| 238 | let _fix_rx = self.antenna_rx.set_low(); | 226 | self.brd_ant_set_tx()?; |
| 239 | let _fix_tx = self.antenna_tx.set_high(); | ||
| 240 | 227 | ||
| 241 | self.brd_write_command(OpCode::SetTxContinuousWave, &[]).await?; | 228 | self.brd_write_command(OpCode::SetTxContinuousWave, &[]).await?; |
| 242 | self.brd_set_operating_mode(RadioMode::Transmit); | 229 | self.brd_set_operating_mode(RadioMode::Transmit); |
| @@ -245,8 +232,7 @@ where | |||
| 245 | 232 | ||
| 246 | // Set the radio in continuous preamble transmission mode | 233 | // Set the radio in continuous preamble transmission mode |
| 247 | pub(super) async fn sub_set_tx_infinite_preamble(&mut self) -> Result<(), RadioError<BUS>> { | 234 | pub(super) async fn sub_set_tx_infinite_preamble(&mut self) -> Result<(), RadioError<BUS>> { |
| 248 | let _fix_rx = self.antenna_rx.set_low(); | 235 | self.brd_ant_set_tx()?; |
| 249 | let _fix_tx = self.antenna_tx.set_high(); | ||
| 250 | 236 | ||
| 251 | self.brd_write_command(OpCode::SetTxContinuousPremable, &[]).await?; | 237 | self.brd_write_command(OpCode::SetTxContinuousPremable, &[]).await?; |
| 252 | self.brd_set_operating_mode(RadioMode::Transmit); | 238 | self.brd_set_operating_mode(RadioMode::Transmit); |
diff --git a/examples/nrf/src/bin/lora_p2p_report.rs b/examples/nrf/src/bin/lora_p2p_report.rs index 46cb848b1..4ba3d30ce 100644 --- a/examples/nrf/src/bin/lora_p2p_report.rs +++ b/examples/nrf/src/bin/lora_p2p_report.rs | |||
| @@ -24,12 +24,12 @@ async fn main(_spawner: Spawner) { | |||
| 24 | let irq = interrupt::take!(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1); | 24 | let irq = interrupt::take!(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1); |
| 25 | let spim = spim::Spim::new(p.TWISPI1, irq, p.P1_11, p.P1_13, p.P1_12, spi_config); | 25 | let spim = spim::Spim::new(p.TWISPI1, irq, p.P1_11, p.P1_13, p.P1_12, spi_config); |
| 26 | 26 | ||
| 27 | let cs = Output::new(p.P1_10, Level::High, OutputDrive::Standard); | 27 | let cs = Output::new(p.P1_10.degrade(), Level::High, OutputDrive::Standard); |
| 28 | let reset = Output::new(p.P1_06, Level::High, OutputDrive::Standard); | 28 | let reset = Output::new(p.P1_06.degrade(), Level::High, OutputDrive::Standard); |
| 29 | let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); | 29 | let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); |
| 30 | let busy = Input::new(p.P1_14.degrade(), Pull::Down); | 30 | let busy = Input::new(p.P1_14.degrade(), Pull::Down); |
| 31 | let antenna_rx = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); | 31 | let antenna_rx = Output::new(p.P1_05.degrade(), Level::Low, OutputDrive::Standard); |
| 32 | let antenna_tx = Output::new(p.P1_07, Level::Low, OutputDrive::Standard); | 32 | let antenna_tx = Output::new(p.P1_07.degrade(), Level::Low, OutputDrive::Standard); |
| 33 | 33 | ||
| 34 | match Sx126xRadio::new(spim, cs, reset, antenna_rx, antenna_tx, dio1, busy, false).await { | 34 | match Sx126xRadio::new(spim, cs, reset, antenna_rx, antenna_tx, dio1, busy, false).await { |
| 35 | Ok(r) => r, | 35 | Ok(r) => r, |
diff --git a/examples/nrf/src/bin/lora_p2p_sense.rs b/examples/nrf/src/bin/lora_p2p_sense.rs index 3c6bb8767..405a8403f 100644 --- a/examples/nrf/src/bin/lora_p2p_sense.rs +++ b/examples/nrf/src/bin/lora_p2p_sense.rs | |||
| @@ -97,12 +97,12 @@ async fn main(spawner: Spawner) { | |||
| 97 | let irq = interrupt::take!(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1); | 97 | let irq = interrupt::take!(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1); |
| 98 | let spim = spim::Spim::new(p.TWISPI1, irq, p.P1_11, p.P1_13, p.P1_12, spi_config); | 98 | let spim = spim::Spim::new(p.TWISPI1, irq, p.P1_11, p.P1_13, p.P1_12, spi_config); |
| 99 | 99 | ||
| 100 | let cs = Output::new(p.P1_10, Level::High, OutputDrive::Standard); | 100 | let cs = Output::new(p.P1_10.degrade(), Level::High, OutputDrive::Standard); |
| 101 | let reset = Output::new(p.P1_06, Level::High, OutputDrive::Standard); | 101 | let reset = Output::new(p.P1_06.degrade(), Level::High, OutputDrive::Standard); |
| 102 | let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); | 102 | let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); |
| 103 | let busy = Input::new(p.P1_14.degrade(), Pull::Down); | 103 | let busy = Input::new(p.P1_14.degrade(), Pull::Down); |
| 104 | let antenna_rx = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); | 104 | let antenna_rx = Output::new(p.P1_05.degrade(), Level::Low, OutputDrive::Standard); |
| 105 | let antenna_tx = Output::new(p.P1_07, Level::Low, OutputDrive::Standard); | 105 | let antenna_tx = Output::new(p.P1_07.degrade(), Level::Low, OutputDrive::Standard); |
| 106 | 106 | ||
| 107 | match Sx126xRadio::new(spim, cs, reset, antenna_rx, antenna_tx, dio1, busy, false).await { | 107 | match Sx126xRadio::new(spim, cs, reset, antenna_rx, antenna_tx, dio1, busy, false).await { |
| 108 | Ok(r) => r, | 108 | Ok(r) => r, |
