Skip to content

Commit 72fa02d

Browse files
authored
Merge pull request #13079 from artokin/nanostack_release_12_3_0
[feature-wisun] Nanostack release v12.3.0
2 parents 5daad96 + 5f4ae1f commit 72fa02d

File tree

70 files changed

+1149
-978
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1149
-978
lines changed

components/802.15.4_RF/atmel-rf-driver/atmel-rf-driver/NanostackRfPhyAtmel.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,16 @@
7070
#if !defined(TEST_PIN_SPARE_2)
7171
#define TEST_PIN_SPARE_2 D8
7272
#endif
73+
#if !defined(SE2435L_CSD)
74+
#define SE2435L_CSD D2
75+
#endif
76+
#if !defined(SE2435L_ANT_SEL)
77+
#define SE2435L_ANT_SEL D8
78+
#endif
7379

7480
class RFBits;
7581
class TestPins;
82+
class Se2435Pins;
7683

7784
class NanostackRfPhyAtmel : public NanostackRfPhy {
7885
public:
@@ -86,10 +93,13 @@ class NanostackRfPhyAtmel : public NanostackRfPhy {
8693
virtual void set_mac_address(uint8_t *mac);
8794

8895
private:
96+
#if !defined(DISABLE_AT24MAC)
8997
AT24Mac _mac;
98+
#endif
9099
uint8_t _mac_addr[8];
91100
RFBits *_rf;
92101
TestPins *_test_pins;
102+
Se2435Pins *_se2435_pa_pins;
93103
bool _mac_set;
94104

95105
const PinName _spi_mosi;

components/802.15.4_RF/atmel-rf-driver/source/AT86RF215Reg.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern "C" {
2626
#define RF24_IRQS 0x01
2727
#define BBC0_IRQS 0x02
2828
#define BBC1_IRQS 0x03
29+
#define RF_AUXS 0x01
2930
#define RF_CFG 0x06
3031
#define RF_IQIFC1 0x0B
3132
#define RF_PN 0x0D
@@ -47,6 +48,8 @@ extern "C" {
4748
#define RF_EDV 0x10
4849
#define RF_TXCUTC 0x12
4950
#define RF_TXDFE 0x13
51+
#define RF_PAC 0x14
52+
#define RF_PADFE 0x16
5053
#define BBC_IRQM 0x00
5154
#define BBC_PC 0x01
5255
#define BBC_RXFLL 0x04
@@ -85,6 +88,20 @@ extern "C" {
8588
#define BBC1_FBRXS 0x3000
8689
#define BBC1_FBTXS 0x3800
8790

91+
// RF_AUXS
92+
#define EXTLNABYP (1 << 7)
93+
#define AGCMAP 0x60
94+
#define AGCMAP_2 (2 << 5)
95+
#define AVEN (1 << 3)
96+
97+
// RF_PAC
98+
#define TXPWR 0x1F
99+
#define TXPWR_11 (11 << 0)
100+
101+
// RF_PADFE
102+
#define PADFE 0xC0
103+
#define RF_FEMODE3 (3 << 6)
104+
88105
// RF_AGCC
89106
#define AGCI (1 << 6)
90107
#define AVGS 0x30
@@ -95,7 +112,6 @@ extern "C" {
95112
#define TGT_1 (1 << 5)
96113
#define TGT_3 (3 << 5)
97114

98-
99115
// RF_RXBWC
100116
#define BW 0x0F
101117
#define RF_BW2000KHZ_IF2000KHZ (11 << 0)

components/802.15.4_RF/atmel-rf-driver/source/AT86RFReg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern "C" {
4848
#define PART_AT86RF212 0x07
4949
#define PART_AT86RF233 0x0B
5050
#define PART_AT86RF215 0x34
51+
#define PART_AT86RF215M 0x36
5152
#define VERSION_AT86RF212 0x01
5253
#define VERSION_AT86RF212B 0x03
5354

components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAT86RF215.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "platform/mbed_wait_api.h"
2424
#include "nanostack/platform/arm_hal_phy.h"
2525
#include "NanostackRfPhyAtmel.h"
26+
#include "AT86RFReg.h"
2627
#include "AT86RF215Reg.h"
2728
#include "mbed_trace.h"
2829
#include "common_functions.h"
@@ -165,6 +166,7 @@ using namespace rtos;
165166
#include "rfbits.h"
166167
static RFBits *rf;
167168
static TestPins *test_pins;
169+
static Se2435Pins *se2435_pa_pins = NULL;
168170

169171
#define MAC_FRAME_TYPE_MASK 0x07
170172
#define MAC_TYPE_ACK (2)
@@ -464,6 +466,18 @@ static void rf_init_registers(rf_modules_e module)
464466
rf_write_rf_register_field(RF_AGCS, module, TGT, TGT_3);
465467
}
466468
}
469+
if (se2435_pa_pins) {
470+
// Wakeup SE2435L
471+
se2435_pa_pins->CSD = 1;
472+
// Antenna port selection: (0 - port 1, 1 - port 2)
473+
se2435_pa_pins->ANT_SEL = 0;
474+
// Enable external front end with configuration 3
475+
rf_write_rf_register_field(RF_PADFE, module, PADFE, RF_FEMODE3);
476+
// Output power at 900MHz: 0 dBm with FSK/QPSK, less than -5 dBm with OFDM
477+
rf_write_rf_register_field(RF_PAC, module, TXPWR, TXPWR_11);
478+
}
479+
// Enable analog voltage regulator
480+
rf_write_rf_register_field(RF_AUXS, module, AVEN, AVEN);
467481
// Disable filtering FCS
468482
rf_write_bbc_register_field(BBC_PC, module, FCSFE, 0);
469483
// Set channel spacing
@@ -1189,10 +1203,28 @@ int RFBits::init_215_driver(RFBits *_rf, TestPins *_test_pins, const uint8_t mac
11891203
test_pins = _test_pins;
11901204
irq_thread_215.start(mbed::callback(this, &RFBits::rf_irq_task));
11911205
rf->spi.frequency(25000000);
1206+
/* Atmel AT86RF215 Device Family datasheet:
1207+
* Errata #9: RF215M device has a wrong part number
1208+
* Description:
1209+
* The RF215M device part number is 0x34 instead of 0x36 (register RF_PN.PN).
1210+
*/
1211+
#if !defined(HAVE_AT86RF215M)
11921212
*rf_part_num = rf_read_common_register(RF_PN);
1213+
#else
1214+
*rf_part_num = PART_AT86RF215M;
1215+
// AT86RF215M is Sub-GHz only transceiver. Change default settings.
1216+
rf_module = RF_09;
1217+
mac_mode = IEEE_802_15_4G_2012;
1218+
#endif
11931219
rf_version_num = rf_read_common_register(RF_VN);
11941220
tr_info("RF version number: %x", rf_version_num);
11951221
return rf_device_register(mac);
11961222
}
11971223

1224+
int RFBits::init_se2435_pa(Se2435Pins *_se2435_pa_pins)
1225+
{
1226+
se2435_pa_pins = _se2435_pa_pins;
1227+
return 0;
1228+
}
1229+
11981230
#endif // MBED_CONF_NANOSTACK_CONFIGURATION && DEVICE_SPI && DEVICE_INTERRUPTIN && defined(MBED_CONF_RTOS_PRESENT)

components/802.15.4_RF/atmel-rf-driver/source/NanostackRfPhyAtmel.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,15 @@ TestPins::TestPins(PinName test_pin_1, PinName test_pin_2, PinName test_pin_3, P
275275
{
276276
}
277277

278+
Se2435Pins::Se2435Pins(PinName csd_pin, PinName ant_sel_pin)
279+
: CSD(csd_pin),
280+
ANT_SEL(ant_sel_pin)
281+
{
282+
}
283+
278284
static RFBits *rf;
279285
static TestPins *test_pins;
286+
static Se2435Pins *se2435_pa_pins;
280287
static uint8_t rf_part_num = 0;
281288
/*TODO: RSSI Base value setting*/
282289
static int8_t rf_rssi_base_val = -91;
@@ -2168,14 +2175,21 @@ static uint8_t rf_scale_lqi(int8_t rssi)
21682175
NanostackRfPhyAtmel::NanostackRfPhyAtmel(PinName spi_mosi, PinName spi_miso,
21692176
PinName spi_sclk, PinName spi_cs, PinName spi_rst, PinName spi_slp, PinName spi_irq,
21702177
PinName i2c_sda, PinName i2c_scl)
2171-
: _mac(i2c_sda, i2c_scl), _mac_addr(), _rf(NULL), _test_pins(NULL), _mac_set(false),
2172-
_spi_mosi(spi_mosi), _spi_miso(spi_miso), _spi_sclk(spi_sclk),
2173-
_spi_cs(spi_cs), _spi_rst(spi_rst), _spi_slp(spi_slp), _spi_irq(spi_irq)
2178+
:
2179+
#if !defined(DISABLE_AT24MAC)
2180+
_mac(i2c_sda, i2c_scl),
2181+
#endif
2182+
_mac_addr(), _rf(NULL), _test_pins(NULL), _se2435_pa_pins(NULL), _mac_set(false),
2183+
_spi_mosi(spi_mosi), _spi_miso(spi_miso), _spi_sclk(spi_sclk),
2184+
_spi_cs(spi_cs), _spi_rst(spi_rst), _spi_slp(spi_slp), _spi_irq(spi_irq)
21742185
{
21752186
_rf = new RFBits(_spi_mosi, _spi_miso, _spi_sclk, _spi_cs, _spi_rst, _spi_slp, _spi_irq);
21762187
#ifdef TEST_GPIOS_ENABLED
21772188
_test_pins = new TestPins(TEST_PIN_TX, TEST_PIN_RX, TEST_PIN_CSMA, TEST_PIN_SPARE_1, TEST_PIN_SPARE_2);
21782189
#endif
2190+
#ifdef SE2435L_PA
2191+
_se2435_pa_pins = new Se2435Pins(SE2435L_CSD, SE2435L_ANT_SEL);
2192+
#endif
21792193
}
21802194

21812195
NanostackRfPhyAtmel::~NanostackRfPhyAtmel()
@@ -2200,19 +2214,29 @@ int8_t NanostackRfPhyAtmel::rf_register()
22002214
// Read the mac address if it hasn't been set by a user
22012215
rf = _rf;
22022216
test_pins = _test_pins;
2217+
se2435_pa_pins = _se2435_pa_pins;
22032218
if (!_mac_set) {
2219+
// Unless AT24MAC is available, using randomly generated MAC address
2220+
#if !defined(DISABLE_AT24MAC)
22042221
int ret = _mac.read_eui64((void *)_mac_addr);
22052222
if (ret < 0) {
22062223
rf = NULL;
22072224
rf_if_unlock();
22082225
return -1;
22092226
}
2227+
#else
2228+
randLIB_seed_random();
2229+
randLIB_get_n_bytes_random(_mac_addr, 8);
2230+
_mac_addr[0] |= 2; //Set Local Bit
2231+
_mac_addr[0] &= ~1; //Clear multicast bit
2232+
#endif
22102233
}
22112234
/*Reset RF module*/
22122235
rf_if_reset_radio();
22132236
rf_part_num = rf_if_read_part_num();
22142237
int8_t radio_id = -1;
22152238
if (rf_part_num != PART_AT86RF231 && rf_part_num != PART_AT86RF233 && rf_part_num != PART_AT86RF212) {
2239+
rf->init_se2435_pa(_se2435_pa_pins);
22162240
// Register RF type 215. Jumps to AT86RF215 driver.
22172241
radio_id = rf->init_215_driver(_rf, _test_pins, _mac_addr, &rf_part_num);
22182242
} else {

components/802.15.4_RF/atmel-rf-driver/source/rfbits.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class RFBits {
5151
Timeout cca_timer;
5252
Timer tx_timer;
5353
int init_215_driver(RFBits *_rf, TestPins *_test_pins, const uint8_t mac[8], uint8_t *rf_part_num);
54+
int init_se2435_pa(Se2435Pins *_se2435_pa_pins);
5455
#ifdef MBED_CONF_RTOS_PRESENT
5556
Thread irq_thread;
5657
Thread irq_thread_215;
@@ -70,4 +71,11 @@ class TestPins {
7071
DigitalOut TEST5;
7172
};
7273

74+
class Se2435Pins {
75+
public:
76+
Se2435Pins(PinName csd_pin, PinName ant_sel_pin);
77+
DigitalOut CSD;
78+
DigitalOut ANT_SEL;
79+
};
80+
7381
#endif /* RFBITS_H_ */
Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,73 @@
11
{
22
"name": "s2lp",
33
"config": {
4+
"SPI_SDI": {
5+
"help": "SPI_SDI pin for SPI connection. D11 assumed, needs to be set/overwritten otherwise",
6+
"value": null
7+
},
8+
"SPI_SDO": {
9+
"help": "SPI_SDO pin for SPI connection. D12 assumed, needs to be set/overwritten otherwise",
10+
"value": null
11+
},
12+
"SPI_SCLK": {
13+
"help": "SPI_SCLK pin for SPI connection, D13 assumed, needs to be set/overwritten otherwise",
14+
"value": null
15+
},
16+
"SPI_CS": {
17+
"help": "SPI_CS pin for SPI connection, A1 assumed, needs to be set/overwritten otherwise",
18+
"value": null
19+
},
20+
"SPI_SDN": {
21+
"help": "SPI_SDN pin for SPI connection, D7 assumed, needs to be set/overwritten otherwise",
22+
"value": null
23+
},
24+
"TEST_PIN_TX": {
25+
"help": "TEST_PIN_TX pin for serial connection, D6 assumed, needs to be set/overwritten otherwise",
26+
"value": null
27+
},
28+
"TEST_PIN_RX": {
29+
"help": "TEST_PIN_RX pin for serial connection, D5 assumed, needs to be set/overwritten otherwise",
30+
"value": null
31+
},
32+
"TEST_PIN_CSMA": {
33+
"help": "TEST_PIN_CSMA pin for CSMA, D4 assumed, needs to be set/overwritten otherwise",
34+
"value": null
35+
},
36+
"TEST_PIN_SPARE_1": {
37+
"help": "TEST_PIN_SPARE_1 pin for testing, D2 assumed, needs to be set/overwritten otherwise",
38+
"value": null
39+
},
40+
"TEST_PIN_SPARE_2": {
41+
"help": "TEST_PIN_SPARE_2 pin for testing, D8 assumed, needs to be set/overwritten otherwise",
42+
"value": null
43+
},
44+
"SPI_GPIO0": {
45+
"help": "SPI_GPIO0 pin for GPIO testing, A0 assumed, needs to be set/overwritten otherwise",
46+
"value": null
47+
},
48+
"SPI_GPIO1": {
49+
"help": "SPI_GPIO1 pin for GPIO testing, A2 assumed, needs to be set/overwritten otherwise",
50+
"value": null
51+
},
52+
"SPI_GPIO2": {
53+
"help": "SPI_GPIO2 pin for GPIO testing, A3 assumed, needs to be set/overwritten otherwise",
54+
"value": null
55+
},
56+
"SPI_GPIO3": {
57+
"help": "SPI_GPIO3 pin for GPIO testing, A5 assumed, needs to be set/overwritten otherwise",
58+
"value": null
59+
},
60+
"I2C_SDA": {
61+
"help": "I2C_SDA pin for I2C SDA, null assumed, needs to be set/overwritten otherwise",
62+
"value": null
63+
},
64+
"I2C_SCL": {
65+
"help": "I2C_SCL pin for I2C SCL, null assumed, needs to be set/overwritten otherwise",
66+
"value": null
67+
},
468
"provide-default": {
569
"help": "Provide default NanostackRfpy. [true/false]",
670
"value": false
7-
},
8-
"target_overrides": {
9-
"MTB_STM_S2LP": {
10-
"s2lp.provide-default": true
11-
},
12-
"MTB_STM_S2LP_CT": {
13-
"s2lp.provide-default": true
14-
}
1571
}
1672
}
1773
}

0 commit comments

Comments
 (0)