1
Diff: TARGET_DISCO_L072CZ_LRWAN1/radio_typeABZ.cpp
- Revision:
- 5:ab124d3842a8
- Parent:
- 0:9c052ff8dd6a
- Child:
- 18:78c5e644d37a
--- a/TARGET_DISCO_L072CZ_LRWAN1/radio_typeABZ.cpp Mon Aug 20 14:07:47 2018 -0700 +++ b/TARGET_DISCO_L072CZ_LRWAN1/radio_typeABZ.cpp Sun Nov 25 17:12:03 2018 -0800 @@ -2,7 +2,8 @@ #define SSA_BOARD 1 -SPI spi(PA_7, PA_6, PB_3); // mosi, miso, sclk +#include "SPIu.h" +SPIu spi(PA_7, PA_6, PB_3); // mosi, miso, sclk // dio0, dio1, nss, spi, rst SX127x Radio::radio(PB_4, PB_1, PA_15, spi, PC_0); // sx1276 arduino shield SX127x_lora Radio::lora(radio); @@ -44,6 +45,18 @@ Radio::set_tx_dbm(int8_t dbm) { RegPdsTrim1_t pds_trim; + unsigned v = radio.read_reg(REG_PATEST_SX1276); + + if (dbm == PA_OFF_DBM) { + /* for bench testing: prevent overloading receiving station (very low TX power) */ + v &= ~0x20; // turn off pu_regpa_n: disable PA + radio.write_reg(REG_PATEST_SX1276, v); + return; + } else if ((v & 0x20) == 0) { + v |= 0x20; // turn on pu_regpa_n: enable PA + radio.write_reg(REG_PATEST_SX1276, v); + } + pds_trim.octet = radio.read_reg(REG_PDSTRIM1_SX1276); if (dbm > 13) {