Hardware Abstraction Layer, permitting any LoRa application to use any LoRa radio chip
Dependents: alarm_slave alarm_master lora_p2p lorawan1v1 ... more
radio chip selection
Radio chip driver is not included, allowing choice of radio device.
If you're using SX1272 or SX1276, then import sx127x driver into your program.
if you're using SX1261 or SX1262, then import sx126x driver into your program.
if you're using SX1280, then import sx1280 driver into your program.
if you're using LR1110, then import LR1110 driver into your program.
If you're using NAmote72 or Murata discovery, then you must import only sx127x driver.
If you're using Type1SJ select target DISCO_L072CZ_LRWAN1
and import sx126x driver into your program.
Pin assigned to arduino LoRa radio shield form-factor
- SX1272 shield.
- SX1276 shield.
- SX126x kit with color touch screen, or sx126x radio-only shield.
- Exceptions with their own pin assignments: NAMote-72 and Murata discovery board.
- TODO: pin assign XDOT.
Diff: TARGET_DISCO_L072CZ_LRWAN1/radio_typeABZ.cpp
- Revision:
- 5:ab124d3842a8
- Parent:
- 0:9c052ff8dd6a
- Child:
- 18:78c5e644d37a
diff -r 57080d572494 -r ab124d3842a8 TARGET_DISCO_L072CZ_LRWAN1/radio_typeABZ.cpp --- 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) {