Skip to content

Commit a8fef8f

Browse files
Kimmo Vaisanenkivaisan
authored andcommitted
Remove product specific variables and target flags
Since variant detection is using ant_switch pin, it is now only used if that pin has been connected. Otherwise generic variant code is used.
1 parent c5ee522 commit a8fef8f

File tree

3 files changed

+39
-47
lines changed

3 files changed

+39
-47
lines changed

SX1272/SX1272_LoRaRadio.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ SPDX-License-Identifier: BSD-3-Clause
6161

6262

6363
enum RadioVariant {
64-
SX1272MB2XAS = 0,
64+
SX1272UNDEFINED = 0,
65+
SX1272MB2XAS,
6566
SX1272MB1DCS
6667
};
6768

@@ -1369,15 +1370,13 @@ void SX1272_LoRaRadio::default_antenna_switch_ctrls()
13691370
*/
13701371
uint8_t SX1272_LoRaRadio::get_pa_conf_reg()
13711372
{
1372-
1373-
#if defined(TARGET_MTS_MDOT_F411RE) || defined(TARGET_XDOT_L151CC) || defined(TARGET_MTB_MTS_XDOT)
1374-
return RF_PACONFIG_PASELECT_PABOOST;
1375-
#endif
1376-
if (radio_variant == SX1272MB1DCS) {
1373+
if (radio_variant == SX1272UNDEFINED) {
1374+
return RF_PACONFIG_PASELECT_PABOOST;
1375+
} else if (radio_variant == SX1272MB1DCS) {
13771376
return RF_PACONFIG_PASELECT_PABOOST;
1377+
} else {
1378+
return RF_PACONFIG_PASELECT_RFO;
13781379
}
1379-
1380-
return RF_PACONFIG_PASELECT_RFO;
13811380
}
13821381

13831382
/**
@@ -1488,15 +1487,19 @@ void SX1272_LoRaRadio::setup_registers()
14881487
*/
14891488
void SX1272_LoRaRadio::set_sx1272_variant_type()
14901489
{
1491-
_ant_switch.input();
1492-
wait_ms(1);
1493-
if (_ant_switch == 1) {
1494-
radio_variant = SX1272MB1DCS;
1490+
if (_rf_ctrls.ant_switch != NC){
1491+
_ant_switch.input();
1492+
wait_ms(1);
1493+
if (_ant_switch == 1) {
1494+
radio_variant = SX1272MB1DCS;
1495+
} else {
1496+
radio_variant = SX1272MB2XAS;
1497+
}
1498+
_ant_switch.output();
1499+
wait_ms(1);
14951500
} else {
1496-
radio_variant = SX1272MB2XAS;
1501+
radio_variant = SX1272UNDEFINED;
14971502
}
1498-
_ant_switch.output();
1499-
wait_ms(1);
15001503
}
15011504

15021505
/**

SX1276/SX1276_LoRaRadio.cpp

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ static const fsk_bw_t fsk_bandwidths[] =
146146
static const radio_registers_t radio_reg_init[] = RADIO_INIT_REGISTERS_VALUE;
147147

148148
enum RadioVariant {
149-
SX1276MB1LAS = 0,
149+
SX1276UNDEFINED = 0,
150+
SX1276MB1LAS,
150151
SX1276MB1MAS
151152
};
152153

@@ -206,13 +207,6 @@ SX1276_LoRaRadio::SX1276_LoRaRadio(PinName spi_mosi,
206207

207208
_radio_events = NULL;
208209

209-
// Detect Murata based on pin configuration
210-
if (pwr_amp_ctl != NC && txctl != NC && rxctl != NC && tcxo != NC) {
211-
is_murata = true;
212-
} else {
213-
is_murata = false;
214-
}
215-
216210
if (tcxo != NC) {
217211
_tcxo = 1;
218212
}
@@ -259,10 +253,8 @@ void SX1276_LoRaRadio::init_radio(radio_events_t *events)
259253
// Reset the radio transceiver
260254
radio_reset();
261255

262-
if (!is_murata) {
263-
// Setup radio variant type
264-
set_sx1276_variant_type();
265-
}
256+
// Setup radio variant type
257+
set_sx1276_variant_type();
266258

267259
// setup SPI frequency
268260
// default is 8MHz although, configurable through
@@ -1356,15 +1348,19 @@ void SX1276_LoRaRadio::set_modem(uint8_t modem )
13561348
*/
13571349
void SX1276_LoRaRadio::set_sx1276_variant_type()
13581350
{
1359-
_ant_switch.input();
1360-
wait_ms(1);
1361-
if (_ant_switch == 1) {
1362-
radio_variant = SX1276MB1LAS;
1351+
if (_rf_ctrls.ant_switch != NC) {
1352+
_ant_switch.input();
1353+
wait_ms(1);
1354+
if (_ant_switch == 1) {
1355+
radio_variant = SX1276MB1LAS;
1356+
} else {
1357+
radio_variant = SX1276MB1MAS;
1358+
}
1359+
_ant_switch.output();
1360+
wait_ms(1);
13631361
} else {
1364-
radio_variant = SX1276MB1MAS;
1362+
radio_variant = SX1276UNDEFINED;
13651363
}
1366-
_ant_switch.output();
1367-
wait_ms(1);
13681364
}
13691365

13701366
/**
@@ -1472,19 +1468,17 @@ uint8_t SX1276_LoRaRadio::get_fsk_bw_reg_val(uint32_t bandwidth)
14721468

14731469
uint8_t SX1276_LoRaRadio::get_pa_conf_reg(uint32_t channel)
14741470
{
1475-
#if TARGET_MTB_ADV_WISE_1510
1476-
return RF_PACONFIG_PASELECT_PABOOST;
1477-
#else
1478-
if (channel > RF_MID_BAND_THRESH) {
1479-
if (radio_variant == SX1276MB1LAS || is_murata) {
1471+
if (radio_variant == SX1276UNDEFINED) {
1472+
return RF_PACONFIG_PASELECT_PABOOST;
1473+
} else if (channel > RF_MID_BAND_THRESH) {
1474+
if (radio_variant == SX1276MB1LAS) {
14801475
return RF_PACONFIG_PASELECT_PABOOST;
14811476
} else {
14821477
return RF_PACONFIG_PASELECT_RFO;
14831478
}
14841479
} else {
14851480
return RF_PACONFIG_PASELECT_RFO;
14861481
}
1487-
#endif
14881482
}
14891483

14901484
/**
@@ -1719,17 +1713,15 @@ void SX1276_LoRaRadio::set_antenna_switch(uint8_t mode)
17191713
if (_rf_ctrls.txctl != NC && _rf_ctrls.rxctl != NC) {
17201714
// module is in transmit mode and tx/rx submodule control
17211715
// pins are connected
1722-
if (is_murata)
1723-
{
1716+
if (_rf_ctrls.pwr_amp_ctl != NC) {
17241717
if (read_register(REG_PACONFIG) & RF_PACONFIG_PASELECT_PABOOST) {
17251718
_pwr_amp_ctl = 1;
17261719
_txctl = 0;
17271720
} else {
17281721
_pwr_amp_ctl = 0;
17291722
_txctl = 1;
17301723
}
1731-
} else
1732-
{
1724+
} else {
17331725
_txctl = 1;
17341726
}
17351727
_rxctl = 0;

SX1276/SX1276_LoRaRadio.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,6 @@ class SX1276_LoRaRadio: public LoRaRadio {
390390
// Access protection
391391
PlatformMutex mutex;
392392

393-
// Murata board
394-
bool is_murata;
395-
396393
// helper functions
397394
void setup_registers();
398395
void default_antenna_switch_ctrls();

0 commit comments

Comments
 (0)