Prototype RF driver for STM Sub-1 GHz RF expansion board based on the SPSGRF-868 module for STM32 Nucleo.

Prototype RF Driver for STM Sub-1 GHz RF Expansion Boards based on the SPSGRF-868 and SPSGRF-915 Modules for STM32 Nucleo

Currently supported boards:

Note, in order to use expansion board X-NUCLEO-IDS01A4 in mbed you need to perform the following HW modifications on the board:

  • Unmount resistor R4
  • Mount resistor R7

Furthermore, on some Nucleo development boards (e.g. the NUCLEO_F429ZI), in order to be able to use Ethernet together with these Sub-1 GHz RF expansion boards, you need to compile this driver with macro SPIRIT1_SPI_MOSI=PB_5 defined, while the development board typically requires some HW modification as e.g. described here!

This driver can be used together with the 6LoWPAN stack (a.k.a. Nanostack).

Committer:
Seppo Takalo
Date:
Thu Jan 18 13:29:40 2018 +0200
Revision:
76:f4f990741baf
Parent:
68:247fd6e0ab66
Child:
78:65de72417cd3
Skip compilation if FEATURE_NANOSTACK is not enabled

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Seppo Takalo 76:f4f990741baf 1 #include "NanostackRfPhySpirit1.h"
Seppo Takalo 76:f4f990741baf 2
Seppo Takalo 76:f4f990741baf 3 #ifdef MBED_CONF_NANOSTACK_CONFIGURATION
Wolfgang Betz 61:0e6aa2ea086f 4 #if MBED_CONF_RTOS_PRESENT
Wolfgang Betz 61:0e6aa2ea086f 5
Wolfgang Betz 38:5deec3ab2025 6 #include "SimpleSpirit1.h"
Wolfgang Betz 38:5deec3ab2025 7 #include "nanostack/platform/arm_hal_phy.h"
Wolfgang Betz 38:5deec3ab2025 8 #include "platform/arm_hal_interrupt.h"
Wolfgang Betz 38:5deec3ab2025 9
Wolfgang Betz 38:5deec3ab2025 10 #include "mbed_trace.h"
Wolfgang Betz 38:5deec3ab2025 11 #define TRACE_GROUP "SPIRIT"
Wolfgang Betz 38:5deec3ab2025 12
Wolfgang Betz 59:5dbfc9faf1c5 13 /* Define beyond macro if you want to perform heavy debug tracing (includes tracing in IRQ context) */
Wolfgang Betz 38:5deec3ab2025 14 // #define HEAVY_TRACING
Wolfgang Betz 38:5deec3ab2025 15
Wolfgang Betz 38:5deec3ab2025 16 static phy_device_driver_s device_driver;
Wolfgang Betz 38:5deec3ab2025 17 static int8_t rf_radio_driver_id = -1;
Wolfgang Betz 38:5deec3ab2025 18
Wolfgang Betz 38:5deec3ab2025 19 const phy_rf_channel_configuration_s phy_subghz = {868000000, 1000000, 250000, 11, M_GFSK};
Wolfgang Betz 38:5deec3ab2025 20
Wolfgang Betz 38:5deec3ab2025 21 static phy_device_channel_page_s phy_channel_pages[] = {
Wolfgang Betz 62:44ab5af08199 22 {CHANNEL_PAGE_2, &phy_subghz},
Wolfgang Betz 62:44ab5af08199 23 {CHANNEL_PAGE_0, NULL}
Wolfgang Betz 38:5deec3ab2025 24 };
Wolfgang Betz 38:5deec3ab2025 25
Wolfgang Betz 38:5deec3ab2025 26 static uint8_t tx_sequence = 0xff;
Wolfgang Betz 38:5deec3ab2025 27 static uint8_t mac_tx_handle = 0;
Wolfgang Betz 38:5deec3ab2025 28
Wolfgang Betz 38:5deec3ab2025 29 static SimpleSpirit1 *rf_device = NULL;
Wolfgang Betz 38:5deec3ab2025 30 static uint8_t rf_rx_buf[MAX_PACKET_LEN];
Wolfgang Betz 38:5deec3ab2025 31
Wolfgang Betz 38:5deec3ab2025 32 static uint16_t stored_short_adr;
Wolfgang Betz 38:5deec3ab2025 33 static uint16_t stored_pan_id;
Wolfgang Betz 52:053dbc4b570f 34 static uint8_t stored_mac_address[8] = MBED_CONF_SPIRIT1_MAC_ADDRESS;
Wolfgang Betz 38:5deec3ab2025 35
Wolfgang Betz 38:5deec3ab2025 36 #define RF_SIG_ACK_NEEDED (1<<0)
Wolfgang Betz 53:b036a3a850e6 37 #define RF_SIG_CB_TX_DONE (1<<1)
Wolfgang Betz 53:b036a3a850e6 38 #define RF_SIG_CB_RX_RCVD (1<<2)
Wolfgang Betz 38:5deec3ab2025 39 static Thread rf_ack_sender(osPriorityRealtime);
Wolfgang Betz 38:5deec3ab2025 40 static volatile uint8_t rf_rx_sequence;
Wolfgang Betz 38:5deec3ab2025 41 static volatile bool rf_ack_sent = false;
Wolfgang Betz 64:28ef790e4ef7 42 static volatile bool expecting_ack = false;
Wolfgang Betz 65:a16f0064110a 43 static volatile bool need_ack = false;
Wolfgang Betz 38:5deec3ab2025 44
Wolfgang Betz 38:5deec3ab2025 45 /* MAC frame helper macros */
Wolfgang Betz 38:5deec3ab2025 46 #define MAC_FCF_FRAME_TYPE_MASK 0x0007
Wolfgang Betz 38:5deec3ab2025 47 #define MAC_FCF_FRAME_TYPE_SHIFT 0
Wolfgang Betz 38:5deec3ab2025 48 #define MAC_FCF_SECURITY_BIT_MASK 0x0008
Wolfgang Betz 38:5deec3ab2025 49 #define MAC_FCF_SECURITY_BIT_SHIFT 3
Wolfgang Betz 38:5deec3ab2025 50 #define MAC_FCF_PENDING_BIT_MASK 0x0010
Wolfgang Betz 38:5deec3ab2025 51 #define MAC_FCF_PENDING_BIT_SHIFT 4
Wolfgang Betz 38:5deec3ab2025 52 #define MAC_FCF_ACK_REQ_BIT_MASK 0x0020
Wolfgang Betz 38:5deec3ab2025 53 #define MAC_FCF_ACK_REQ_BIT_SHIFT 5
Wolfgang Betz 38:5deec3ab2025 54 #define MAC_FCF_INTRA_PANID_MASK 0x0040
Wolfgang Betz 38:5deec3ab2025 55 #define MAC_FCF_INTRA_PANID_SHIFT 6
Wolfgang Betz 38:5deec3ab2025 56 #define MAC_FCF_DST_ADDR_MASK 0x0c00
Wolfgang Betz 38:5deec3ab2025 57 #define MAC_FCF_DST_ADDR_SHIFT 10
Wolfgang Betz 38:5deec3ab2025 58 #define MAC_FCF_VERSION_MASK 0x3000
Wolfgang Betz 38:5deec3ab2025 59 #define MAC_FCF_VERSION_SHIFT 12
Wolfgang Betz 38:5deec3ab2025 60 #define MAC_FCF_SRC_ADDR_MASK 0xc000
Wolfgang Betz 38:5deec3ab2025 61 #define MAC_FCF_SRC_ADDR_SHIFT 14
Wolfgang Betz 38:5deec3ab2025 62
Wolfgang Betz 38:5deec3ab2025 63 /* MAC supported frame types */
Wolfgang Betz 38:5deec3ab2025 64 #define FC_BEACON_FRAME 0x00
Wolfgang Betz 38:5deec3ab2025 65 #define FC_DATA_FRAME 0x01
Wolfgang Betz 38:5deec3ab2025 66 #define FC_ACK_FRAME 0x02
Wolfgang Betz 38:5deec3ab2025 67 #define FC_CMD_FRAME 0x03
Wolfgang Betz 38:5deec3ab2025 68
Wolfgang Betz 68:247fd6e0ab66 69 static inline void rf_if_lock(void)
Wolfgang Betz 38:5deec3ab2025 70 {
Wolfgang Betz 38:5deec3ab2025 71 platform_enter_critical();
Wolfgang Betz 38:5deec3ab2025 72 }
Wolfgang Betz 38:5deec3ab2025 73
Wolfgang Betz 68:247fd6e0ab66 74 static inline void rf_if_unlock(void)
Wolfgang Betz 38:5deec3ab2025 75 {
Wolfgang Betz 38:5deec3ab2025 76 platform_exit_critical();
Wolfgang Betz 38:5deec3ab2025 77 }
Wolfgang Betz 38:5deec3ab2025 78
Wolfgang Betz 38:5deec3ab2025 79 static inline uint16_t rf_read_16_bit(uint8_t *data_ptr) { // little-endian
Wolfgang Betz 53:b036a3a850e6 80 uint16_t ret;
Wolfgang Betz 38:5deec3ab2025 81
Wolfgang Betz 53:b036a3a850e6 82 ret = ((uint16_t)data_ptr[0]) + (((uint16_t)data_ptr[1]) << 8);
Wolfgang Betz 53:b036a3a850e6 83 return ret;
Wolfgang Betz 38:5deec3ab2025 84 }
Wolfgang Betz 38:5deec3ab2025 85
Wolfgang Betz 38:5deec3ab2025 86 /* Note: we are in IRQ context */
Wolfgang Betz 53:b036a3a850e6 87 static inline void rf_send_signal(int32_t signal) {
Wolfgang Betz 53:b036a3a850e6 88 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 89 tr_info("%s (%d): %d", __func__, __LINE__, signal);
Wolfgang Betz 53:b036a3a850e6 90 #endif
Wolfgang Betz 53:b036a3a850e6 91 rf_ack_sender.signal_set(signal);
Wolfgang Betz 53:b036a3a850e6 92 }
Wolfgang Betz 53:b036a3a850e6 93
Wolfgang Betz 64:28ef790e4ef7 94 static volatile phy_link_tx_status_e phy_status;
Wolfgang Betz 53:b036a3a850e6 95 /* Note: we are in IRQ context */
Wolfgang Betz 38:5deec3ab2025 96 static void rf_handle_ack(uint8_t seq_number)
Wolfgang Betz 38:5deec3ab2025 97 {
Wolfgang Betz 38:5deec3ab2025 98 /*Received ACK sequence must be equal with transmitted packet sequence*/
Wolfgang Betz 38:5deec3ab2025 99 if(tx_sequence == seq_number)
Wolfgang Betz 38:5deec3ab2025 100 {
Wolfgang Betz 38:5deec3ab2025 101 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 102 tr_info("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 103 #endif
Wolfgang Betz 38:5deec3ab2025 104
Wolfgang Betz 62:44ab5af08199 105 /*Call PHY TX Done API*/
Wolfgang Betz 62:44ab5af08199 106 if(device_driver.phy_tx_done_cb){
Wolfgang Betz 62:44ab5af08199 107 phy_status = PHY_LINK_TX_DONE;
Wolfgang Betz 62:44ab5af08199 108 rf_send_signal(RF_SIG_CB_TX_DONE);
Wolfgang Betz 62:44ab5af08199 109 }
Wolfgang Betz 38:5deec3ab2025 110 } else {
Wolfgang Betz 38:5deec3ab2025 111 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 112 tr_info("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 113 #endif
Wolfgang Betz 64:28ef790e4ef7 114
Wolfgang Betz 64:28ef790e4ef7 115 /*Call PHY TX Done API*/
Wolfgang Betz 64:28ef790e4ef7 116 if(device_driver.phy_tx_done_cb){
Wolfgang Betz 64:28ef790e4ef7 117 phy_status = PHY_LINK_TX_FAIL;
Wolfgang Betz 64:28ef790e4ef7 118 rf_send_signal(RF_SIG_CB_TX_DONE);
Wolfgang Betz 64:28ef790e4ef7 119 }
Wolfgang Betz 38:5deec3ab2025 120 }
Wolfgang Betz 38:5deec3ab2025 121 }
Wolfgang Betz 38:5deec3ab2025 122
Wolfgang Betz 38:5deec3ab2025 123 /* Note: we are in IRQ context */
Wolfgang Betz 38:5deec3ab2025 124 static inline bool rf_check_mac_address(uint8_t *dest) {
Wolfgang Betz 53:b036a3a850e6 125 for(int i = 0; i < 8; i++) {
Wolfgang Betz 63:d7530f62ed93 126 if(dest[i] != stored_mac_address[7-i]) {
Wolfgang Betz 63:d7530f62ed93 127 #ifdef HEAVY_TRACING
Wolfgang Betz 63:d7530f62ed93 128 tr_debug("%s (%d): i=%d, dest=%x, stored=%x",
Wolfgang Betz 63:d7530f62ed93 129 __func__, __LINE__,
Wolfgang Betz 63:d7530f62ed93 130 i, dest[i], stored_mac_address[7-i]);
Wolfgang Betz 63:d7530f62ed93 131 #endif
Wolfgang Betz 63:d7530f62ed93 132 return false;
Wolfgang Betz 63:d7530f62ed93 133 }
Wolfgang Betz 53:b036a3a850e6 134 }
Wolfgang Betz 53:b036a3a850e6 135 return true;
Wolfgang Betz 38:5deec3ab2025 136 }
Wolfgang Betz 38:5deec3ab2025 137
Wolfgang Betz 38:5deec3ab2025 138 /* Note: we are in IRQ context */
Wolfgang Betz 38:5deec3ab2025 139 /* Returns true if packet should be accepted */
Wolfgang Betz 38:5deec3ab2025 140 static bool rf_check_destination(int len, uint8_t *ack_requested) {
Wolfgang Betz 53:b036a3a850e6 141 uint8_t frame_type;
Wolfgang Betz 53:b036a3a850e6 142 uint16_t dst_pan_id;
Wolfgang Betz 53:b036a3a850e6 143 uint16_t dst_short_adr;
Wolfgang Betz 53:b036a3a850e6 144 uint8_t dst_addr_mode = 0x0; /*0x00 = no address 0x01 = reserved 0x02 = 16-bit short address 0x03 = 64-bit extended address */
Wolfgang Betz 53:b036a3a850e6 145 uint8_t src_addr_mode = 0x0; /*0x00 = no address 0x01 = reserved 0x02 = 16-bit short address 0x03 = 64-bit extended address */
Wolfgang Betz 53:b036a3a850e6 146 uint8_t min_size = 3; // FCF & SeqNr
Wolfgang Betz 53:b036a3a850e6 147 bool ret = false;
Wolfgang Betz 53:b036a3a850e6 148 #if defined(HEAVY_TRACING)
Wolfgang Betz 53:b036a3a850e6 149 bool panid_compr = false;
Wolfgang Betz 38:5deec3ab2025 150 #endif
Wolfgang Betz 38:5deec3ab2025 151
Wolfgang Betz 53:b036a3a850e6 152 if(len < 3) {
Wolfgang Betz 62:44ab5af08199 153 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 62:44ab5af08199 154 return false;
Wolfgang Betz 53:b036a3a850e6 155 }
Wolfgang Betz 38:5deec3ab2025 156
Wolfgang Betz 53:b036a3a850e6 157 uint16_t fcf = rf_read_16_bit(rf_rx_buf);
Wolfgang Betz 53:b036a3a850e6 158 frame_type = ((fcf & MAC_FCF_FRAME_TYPE_MASK) >> MAC_FCF_FRAME_TYPE_SHIFT);
Wolfgang Betz 53:b036a3a850e6 159 (*ack_requested) = ((fcf & MAC_FCF_ACK_REQ_BIT_MASK) >> MAC_FCF_ACK_REQ_BIT_SHIFT);
Wolfgang Betz 53:b036a3a850e6 160 dst_addr_mode = ((fcf & MAC_FCF_DST_ADDR_MASK) >> MAC_FCF_DST_ADDR_SHIFT);
Wolfgang Betz 53:b036a3a850e6 161 src_addr_mode = ((fcf & MAC_FCF_SRC_ADDR_MASK) >> MAC_FCF_SRC_ADDR_SHIFT);
Wolfgang Betz 53:b036a3a850e6 162 #if defined(HEAVY_TRACING)
Wolfgang Betz 53:b036a3a850e6 163 panid_compr = ((fcf & MAC_FCF_INTRA_PANID_MASK) >> MAC_FCF_INTRA_PANID_SHIFT);
Wolfgang Betz 38:5deec3ab2025 164 #endif
Wolfgang Betz 38:5deec3ab2025 165
Wolfgang Betz 38:5deec3ab2025 166 #ifdef HEAVY_TRACING
Wolfgang Betz 53:b036a3a850e6 167 tr_info("%s (%d): len=%d, ftype=%x, snr=%x, ack=%d, dst=%x, src=%x, intra=%d", __func__, __LINE__, len, frame_type,
Wolfgang Betz 62:44ab5af08199 168 rf_rx_buf[2], (*ack_requested), dst_addr_mode, src_addr_mode, panid_compr);
Wolfgang Betz 38:5deec3ab2025 169 #endif
Wolfgang Betz 38:5deec3ab2025 170
Wolfgang Betz 53:b036a3a850e6 171 if(frame_type == FC_ACK_FRAME) { // betzw: we support up to two different forms of ACK frames!
Wolfgang Betz 62:44ab5af08199 172 if((len == 3) && (dst_addr_mode == 0x0) && (src_addr_mode == 0x0)) {
Wolfgang Betz 62:44ab5af08199 173 ret = true;
Wolfgang Betz 62:44ab5af08199 174 }
Wolfgang Betz 38:5deec3ab2025 175
Wolfgang Betz 38:5deec3ab2025 176 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 177 tr_info("%s (%d): ret=%d", __func__, __LINE__, ret);
Wolfgang Betz 53:b036a3a850e6 178 #endif
Wolfgang Betz 62:44ab5af08199 179 (*ack_requested) = 0; // Never acknowledge ACK frames
Wolfgang Betz 62:44ab5af08199 180 return ret;
Wolfgang Betz 53:b036a3a850e6 181 }
Wolfgang Betz 53:b036a3a850e6 182
Wolfgang Betz 53:b036a3a850e6 183 switch(dst_addr_mode) {
Wolfgang Betz 62:44ab5af08199 184 case 0x00:
Wolfgang Betz 62:44ab5af08199 185 ret = true; // no check possible;
Wolfgang Betz 62:44ab5af08199 186 break;
Wolfgang Betz 63:d7530f62ed93 187
Wolfgang Betz 62:44ab5af08199 188 case 0x02:
Wolfgang Betz 62:44ab5af08199 189 min_size += 4; // pan id + short dest adr
Wolfgang Betz 53:b036a3a850e6 190
Wolfgang Betz 62:44ab5af08199 191 if(len < 5) {
Wolfgang Betz 53:b036a3a850e6 192 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 193 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 53:b036a3a850e6 194 #endif
Wolfgang Betz 62:44ab5af08199 195 return false;
Wolfgang Betz 62:44ab5af08199 196 }
Wolfgang Betz 53:b036a3a850e6 197
Wolfgang Betz 62:44ab5af08199 198 dst_pan_id = rf_read_16_bit(&rf_rx_buf[3]);
Wolfgang Betz 63:d7530f62ed93 199 if((dst_pan_id != stored_pan_id) && (dst_pan_id != 0xFFFF)) {
Wolfgang Betz 53:b036a3a850e6 200 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 201 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 53:b036a3a850e6 202 #endif
Wolfgang Betz 63:d7530f62ed93 203 return false;
Wolfgang Betz 62:44ab5af08199 204 }
Wolfgang Betz 53:b036a3a850e6 205
Wolfgang Betz 62:44ab5af08199 206 if(len < 7) {
Wolfgang Betz 53:b036a3a850e6 207 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 208 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 53:b036a3a850e6 209 #endif
Wolfgang Betz 62:44ab5af08199 210 return false;
Wolfgang Betz 62:44ab5af08199 211 }
Wolfgang Betz 53:b036a3a850e6 212
Wolfgang Betz 62:44ab5af08199 213 dst_short_adr = rf_read_16_bit(&rf_rx_buf[5]);
Wolfgang Betz 63:d7530f62ed93 214 if((dst_short_adr != stored_short_adr) && (dst_short_adr != 0xFFFF)) {
Wolfgang Betz 53:b036a3a850e6 215 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 216 tr_debug("%s (%d): %d!=%d", __func__, __LINE__, dst_short_adr, stored_short_adr);
Wolfgang Betz 53:b036a3a850e6 217 #endif
Wolfgang Betz 63:d7530f62ed93 218 return false;
Wolfgang Betz 62:44ab5af08199 219 }
Wolfgang Betz 63:d7530f62ed93 220
Wolfgang Betz 63:d7530f62ed93 221 ret = true;
Wolfgang Betz 62:44ab5af08199 222 break;
Wolfgang Betz 63:d7530f62ed93 223
Wolfgang Betz 62:44ab5af08199 224 case 0x03:
Wolfgang Betz 62:44ab5af08199 225 min_size += 10; // pan id + dest mac addr
Wolfgang Betz 53:b036a3a850e6 226
Wolfgang Betz 62:44ab5af08199 227 if(len < 5) {
Wolfgang Betz 53:b036a3a850e6 228 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 229 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 53:b036a3a850e6 230 #endif
Wolfgang Betz 62:44ab5af08199 231 return false;
Wolfgang Betz 62:44ab5af08199 232 }
Wolfgang Betz 53:b036a3a850e6 233
Wolfgang Betz 62:44ab5af08199 234 dst_pan_id = rf_read_16_bit(&rf_rx_buf[3]);
Wolfgang Betz 63:d7530f62ed93 235 if((dst_pan_id != stored_pan_id) && (dst_pan_id != 0xFFFF)) {
Wolfgang Betz 53:b036a3a850e6 236 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 237 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 53:b036a3a850e6 238 #endif
Wolfgang Betz 63:d7530f62ed93 239 return false;
Wolfgang Betz 62:44ab5af08199 240 }
Wolfgang Betz 53:b036a3a850e6 241
Wolfgang Betz 62:44ab5af08199 242 if(len < 13) {
Wolfgang Betz 53:b036a3a850e6 243 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 244 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 53:b036a3a850e6 245 #endif
Wolfgang Betz 62:44ab5af08199 246 return false;
Wolfgang Betz 62:44ab5af08199 247 }
Wolfgang Betz 53:b036a3a850e6 248
Wolfgang Betz 62:44ab5af08199 249 ret = rf_check_mac_address(&rf_rx_buf[5]);
Wolfgang Betz 63:d7530f62ed93 250
Wolfgang Betz 63:d7530f62ed93 251 if(!ret) {
Wolfgang Betz 63:d7530f62ed93 252 #ifdef HEAVY_TRACING
Wolfgang Betz 63:d7530f62ed93 253 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 63:d7530f62ed93 254 #endif
Wolfgang Betz 63:d7530f62ed93 255 return false;
Wolfgang Betz 63:d7530f62ed93 256 }
Wolfgang Betz 63:d7530f62ed93 257
Wolfgang Betz 62:44ab5af08199 258 break;
Wolfgang Betz 63:d7530f62ed93 259
Wolfgang Betz 62:44ab5af08199 260 default:
Wolfgang Betz 62:44ab5af08199 261 /* not supported */
Wolfgang Betz 53:b036a3a850e6 262 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 263 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 53:b036a3a850e6 264 #endif
Wolfgang Betz 62:44ab5af08199 265 return false;
Wolfgang Betz 53:b036a3a850e6 266 }
Wolfgang Betz 53:b036a3a850e6 267
Wolfgang Betz 53:b036a3a850e6 268 if(ret && (*ack_requested)) {
Wolfgang Betz 62:44ab5af08199 269 rf_rx_sequence = rf_rx_buf[2];
Wolfgang Betz 53:b036a3a850e6 270 }
Wolfgang Betz 53:b036a3a850e6 271
Wolfgang Betz 53:b036a3a850e6 272 #ifdef HEAVY_TRACING
Wolfgang Betz 53:b036a3a850e6 273 tr_info("%s (%d), ret=%d, ack=%d", __func__, __LINE__, ret, (*ack_requested));
Wolfgang Betz 53:b036a3a850e6 274 #endif
Wolfgang Betz 53:b036a3a850e6 275 return ret;
Wolfgang Betz 38:5deec3ab2025 276 }
Wolfgang Betz 38:5deec3ab2025 277
Wolfgang Betz 53:b036a3a850e6 278 static uint16_t rf_buffer_len = 0;
Wolfgang Betz 53:b036a3a850e6 279 static uint8_t rf_sqi;
Wolfgang Betz 53:b036a3a850e6 280 static int8_t rf_rssi;
Wolfgang Betz 38:5deec3ab2025 281 /* Note: we are in IRQ context */
Wolfgang Betz 38:5deec3ab2025 282 static inline void rf_handle_rx_end(void)
Wolfgang Betz 38:5deec3ab2025 283 {
Wolfgang Betz 38:5deec3ab2025 284 uint8_t ack_requested = 0;
Wolfgang Betz 38:5deec3ab2025 285
Wolfgang Betz 38:5deec3ab2025 286 /* Get received data */
Wolfgang Betz 38:5deec3ab2025 287 rf_buffer_len = rf_device->read(rf_rx_buf, MAX_PACKET_LEN);
Wolfgang Betz 38:5deec3ab2025 288 if(!rf_buffer_len)
Wolfgang Betz 62:44ab5af08199 289 return;
Wolfgang Betz 38:5deec3ab2025 290
Wolfgang Betz 38:5deec3ab2025 291 #ifdef HEAVY_TRACING
Wolfgang Betz 53:b036a3a850e6 292 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 293 #endif
Wolfgang Betz 38:5deec3ab2025 294
Wolfgang Betz 53:b036a3a850e6 295 /* Check if packet should be accepted */
Wolfgang Betz 38:5deec3ab2025 296 if(!rf_check_destination(rf_buffer_len, &ack_requested)) {
Wolfgang Betz 38:5deec3ab2025 297 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 298 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 299 #endif
Wolfgang Betz 62:44ab5af08199 300 return;
Wolfgang Betz 38:5deec3ab2025 301 }
Wolfgang Betz 38:5deec3ab2025 302
Wolfgang Betz 38:5deec3ab2025 303 /* If waiting for ACK, check here if the packet is an ACK to a message previously sent */
Wolfgang Betz 64:28ef790e4ef7 304 if(expecting_ack) {
Wolfgang Betz 64:28ef790e4ef7 305 uint16_t fcf = rf_read_16_bit(rf_rx_buf);
Wolfgang Betz 64:28ef790e4ef7 306 expecting_ack = false;
Wolfgang Betz 64:28ef790e4ef7 307
Wolfgang Betz 64:28ef790e4ef7 308 if(((fcf & MAC_FCF_FRAME_TYPE_MASK) >> MAC_FCF_FRAME_TYPE_SHIFT) == FC_ACK_FRAME) {
Wolfgang Betz 64:28ef790e4ef7 309 /*Send sequence number in ACK handler*/
Wolfgang Betz 38:5deec3ab2025 310 #ifdef HEAVY_TRACING
Wolfgang Betz 64:28ef790e4ef7 311 tr_debug("%s (%d), len=%u", __func__, __LINE__, (unsigned int)rf_buffer_len);
Wolfgang Betz 38:5deec3ab2025 312 #endif
Wolfgang Betz 64:28ef790e4ef7 313 rf_handle_ack(rf_rx_buf[2]);
Wolfgang Betz 64:28ef790e4ef7 314 return;
Wolfgang Betz 64:28ef790e4ef7 315 } else {
Wolfgang Betz 64:28ef790e4ef7 316 /*Call PHY TX Done API*/
Wolfgang Betz 64:28ef790e4ef7 317 if(device_driver.phy_tx_done_cb){
Wolfgang Betz 64:28ef790e4ef7 318 phy_status = PHY_LINK_TX_FAIL;
Wolfgang Betz 64:28ef790e4ef7 319 rf_send_signal(RF_SIG_CB_TX_DONE);
Wolfgang Betz 64:28ef790e4ef7 320 }
Wolfgang Betz 64:28ef790e4ef7 321 }
Wolfgang Betz 38:5deec3ab2025 322 }
Wolfgang Betz 38:5deec3ab2025 323
Wolfgang Betz 38:5deec3ab2025 324 /* Kick off ACK sending */
Wolfgang Betz 38:5deec3ab2025 325 if(ack_requested) {
Wolfgang Betz 38:5deec3ab2025 326 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 327 tr_debug("%s (%d), len=%u", __func__, __LINE__, (unsigned int)rf_buffer_len);
Wolfgang Betz 38:5deec3ab2025 328 #endif
Wolfgang Betz 62:44ab5af08199 329 rf_send_signal(RF_SIG_ACK_NEEDED);
Wolfgang Betz 38:5deec3ab2025 330 }
Wolfgang Betz 38:5deec3ab2025 331
Wolfgang Betz 38:5deec3ab2025 332 /* Get link information */
Wolfgang Betz 38:5deec3ab2025 333 rf_rssi = (int8_t)rf_device->get_last_rssi_dbm();
Wolfgang Betz 38:5deec3ab2025 334 rf_sqi = (uint8_t)rf_device->get_last_sqi(); // use SQI as link quality
Wolfgang Betz 38:5deec3ab2025 335
Wolfgang Betz 38:5deec3ab2025 336 /* Note: Checksum of the packet must be checked and removed before entering here */
Wolfgang Betz 38:5deec3ab2025 337 /* TODO - betzw: what to do? */
Wolfgang Betz 38:5deec3ab2025 338
Wolfgang Betz 38:5deec3ab2025 339 #ifdef HEAVY_TRACING
Wolfgang Betz 53:b036a3a850e6 340 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 341 #endif
Wolfgang Betz 38:5deec3ab2025 342
Wolfgang Betz 53:b036a3a850e6 343 /* Send received data and link information to the network stack */
Wolfgang Betz 38:5deec3ab2025 344 if( device_driver.phy_rx_cb ){
Wolfgang Betz 62:44ab5af08199 345 rf_send_signal(RF_SIG_CB_RX_RCVD);
Wolfgang Betz 38:5deec3ab2025 346 }
Wolfgang Betz 38:5deec3ab2025 347 }
Wolfgang Betz 38:5deec3ab2025 348
Wolfgang Betz 38:5deec3ab2025 349 /* Note: we are in IRQ context */
Wolfgang Betz 38:5deec3ab2025 350 static inline void rf_handle_tx_end(void)
Wolfgang Betz 38:5deec3ab2025 351 {
Wolfgang Betz 38:5deec3ab2025 352 /* Check if this is an ACK sending which is still pending */
Wolfgang Betz 53:b036a3a850e6 353 if(rf_ack_sent) {
Wolfgang Betz 62:44ab5af08199 354 rf_ack_sent = false;
Wolfgang Betz 38:5deec3ab2025 355 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 356 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 357 #endif
Wolfgang Betz 62:44ab5af08199 358 return; // no need to inform stack
Wolfgang Betz 53:b036a3a850e6 359 }
Wolfgang Betz 38:5deec3ab2025 360
Wolfgang Betz 65:a16f0064110a 361 /* Transform `need_ack` in `expecting_ack` */
Wolfgang Betz 65:a16f0064110a 362 if(need_ack) {
Wolfgang Betz 65:a16f0064110a 363 need_ack = false;
Wolfgang Betz 65:a16f0064110a 364 expecting_ack = true;
Wolfgang Betz 65:a16f0064110a 365 }
Wolfgang Betz 65:a16f0064110a 366
Wolfgang Betz 38:5deec3ab2025 367 /*Call PHY TX Done API*/
Wolfgang Betz 38:5deec3ab2025 368 if(device_driver.phy_tx_done_cb){
Wolfgang Betz 65:a16f0064110a 369 phy_status = PHY_LINK_TX_SUCCESS;
Wolfgang Betz 62:44ab5af08199 370 rf_send_signal(RF_SIG_CB_TX_DONE);
Wolfgang Betz 38:5deec3ab2025 371 }
Wolfgang Betz 38:5deec3ab2025 372 }
Wolfgang Betz 38:5deec3ab2025 373
Wolfgang Betz 68:247fd6e0ab66 374 /* Note: we might be in IRQ context */
Wolfgang Betz 68:247fd6e0ab66 375 static inline void rf_handle_tx_err(phy_link_tx_status_e phy_val = PHY_LINK_TX_FAIL) {
Wolfgang Betz 38:5deec3ab2025 376 /*Call PHY TX Done API*/
Wolfgang Betz 38:5deec3ab2025 377 if(device_driver.phy_tx_done_cb){
Wolfgang Betz 65:a16f0064110a 378 need_ack = false;
Wolfgang Betz 68:247fd6e0ab66 379 phy_status = phy_val;
Wolfgang Betz 62:44ab5af08199 380 rf_send_signal(RF_SIG_CB_TX_DONE);
Wolfgang Betz 38:5deec3ab2025 381 }
Wolfgang Betz 38:5deec3ab2025 382 }
Wolfgang Betz 38:5deec3ab2025 383
Wolfgang Betz 38:5deec3ab2025 384 /* Note: we are in IRQ context */
Wolfgang Betz 38:5deec3ab2025 385 static void rf_callback_func(int event) {
Wolfgang Betz 53:b036a3a850e6 386 switch(event) {
Wolfgang Betz 62:44ab5af08199 387 case SimpleSpirit1::RX_DONE:
Wolfgang Betz 62:44ab5af08199 388 rf_handle_rx_end();
Wolfgang Betz 62:44ab5af08199 389 break;
Wolfgang Betz 62:44ab5af08199 390 case SimpleSpirit1::TX_DONE:
Wolfgang Betz 62:44ab5af08199 391 rf_handle_tx_end();
Wolfgang Betz 62:44ab5af08199 392 break;
Wolfgang Betz 62:44ab5af08199 393 case SimpleSpirit1::TX_ERR:
Wolfgang Betz 38:5deec3ab2025 394 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 395 tr_debug("%s (%d): TX_ERR!!!", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 396 #endif
Wolfgang Betz 62:44ab5af08199 397 rf_handle_tx_err();
Wolfgang Betz 62:44ab5af08199 398 break;
Wolfgang Betz 53:b036a3a850e6 399 }
Wolfgang Betz 38:5deec3ab2025 400 }
Wolfgang Betz 38:5deec3ab2025 401
Wolfgang Betz 68:247fd6e0ab66 402 static int8_t rf_trigger_send(uint8_t *data_ptr, uint16_t data_length, uint8_t tx_handle, data_protocol_e data_protocol)
Wolfgang Betz 68:247fd6e0ab66 403 {
Wolfgang Betz 68:247fd6e0ab66 404 #ifndef NDEBUG
Wolfgang Betz 68:247fd6e0ab66 405 debug_if(!(data_length >= 3), "\r\nassert failed in: %s (%d)\r\n", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 406 #endif
Wolfgang Betz 68:247fd6e0ab66 407
Wolfgang Betz 68:247fd6e0ab66 408 /* Give 'rf_ack_sender' a better chance to run */
Wolfgang Betz 68:247fd6e0ab66 409 Thread::yield();
Wolfgang Betz 68:247fd6e0ab66 410
Wolfgang Betz 68:247fd6e0ab66 411 /* Get Lock */
Wolfgang Betz 68:247fd6e0ab66 412 rf_if_lock();
Wolfgang Betz 68:247fd6e0ab66 413
Wolfgang Betz 68:247fd6e0ab66 414 /*Check if transmitter is busy*/
Wolfgang Betz 68:247fd6e0ab66 415 if(rf_device->is_receiving()) { /* betzw - WAS: (rf_device->channel_clear() != 0)), do NOT use this but rather study and enable automatic CCA */
Wolfgang Betz 68:247fd6e0ab66 416 #ifdef HEAVY_TRACING
Wolfgang Betz 68:247fd6e0ab66 417 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 418 #endif
Wolfgang Betz 68:247fd6e0ab66 419
Wolfgang Betz 68:247fd6e0ab66 420 /* Release Lock */
Wolfgang Betz 68:247fd6e0ab66 421 rf_if_unlock();
Wolfgang Betz 68:247fd6e0ab66 422
Wolfgang Betz 68:247fd6e0ab66 423 /*Return busy*/
Wolfgang Betz 68:247fd6e0ab66 424 return -1;
Wolfgang Betz 68:247fd6e0ab66 425 } else {
Wolfgang Betz 68:247fd6e0ab66 426 uint16_t fcf = rf_read_16_bit(data_ptr);
Wolfgang Betz 68:247fd6e0ab66 427
Wolfgang Betz 68:247fd6e0ab66 428 /*Check if transmitted data needs to be acked*/
Wolfgang Betz 68:247fd6e0ab66 429 if((fcf & MAC_FCF_ACK_REQ_BIT_MASK) >> MAC_FCF_ACK_REQ_BIT_SHIFT)
Wolfgang Betz 68:247fd6e0ab66 430 need_ack = true;
Wolfgang Betz 68:247fd6e0ab66 431 else
Wolfgang Betz 68:247fd6e0ab66 432 need_ack = false;
Wolfgang Betz 68:247fd6e0ab66 433
Wolfgang Betz 68:247fd6e0ab66 434 /*Store the sequence number for ACK handling*/
Wolfgang Betz 68:247fd6e0ab66 435 tx_sequence = *(data_ptr + 2);
Wolfgang Betz 68:247fd6e0ab66 436
Wolfgang Betz 68:247fd6e0ab66 437 /*Store TX handle*/
Wolfgang Betz 68:247fd6e0ab66 438 mac_tx_handle = tx_handle;
Wolfgang Betz 68:247fd6e0ab66 439
Wolfgang Betz 68:247fd6e0ab66 440 #ifdef HEAVY_TRACING
Wolfgang Betz 68:247fd6e0ab66 441 tr_info("%s (%d), len=%d, tx_handle=%x, tx_seq=%x, need_ack=%d (%x:%x, %x:%x, %x:%x, %x:%x)", __func__, __LINE__,
Wolfgang Betz 68:247fd6e0ab66 442 data_length, tx_handle, tx_sequence, need_ack,
Wolfgang Betz 68:247fd6e0ab66 443 data_ptr[3], data_ptr[4], data_ptr[5], data_ptr[6],
Wolfgang Betz 68:247fd6e0ab66 444 data_ptr[7], data_ptr[8], data_ptr[9], data_ptr[10]);
Wolfgang Betz 68:247fd6e0ab66 445 #endif
Wolfgang Betz 68:247fd6e0ab66 446
Wolfgang Betz 68:247fd6e0ab66 447 /*Send the packet*/
Wolfgang Betz 68:247fd6e0ab66 448 int ret = rf_device->send(data_ptr, data_length);
Wolfgang Betz 68:247fd6e0ab66 449 if(ret != RADIO_TX_OK) {
Wolfgang Betz 68:247fd6e0ab66 450 rf_handle_tx_err(PHY_LINK_CCA_FAIL);
Wolfgang Betz 68:247fd6e0ab66 451 }
Wolfgang Betz 68:247fd6e0ab66 452
Wolfgang Betz 68:247fd6e0ab66 453 /* Release Lock */
Wolfgang Betz 68:247fd6e0ab66 454 rf_if_unlock();
Wolfgang Betz 68:247fd6e0ab66 455 }
Wolfgang Betz 68:247fd6e0ab66 456
Wolfgang Betz 68:247fd6e0ab66 457 /*Return success*/
Wolfgang Betz 68:247fd6e0ab66 458 return 0;
Wolfgang Betz 68:247fd6e0ab66 459 }
Wolfgang Betz 68:247fd6e0ab66 460
Wolfgang Betz 68:247fd6e0ab66 461 static int8_t rf_interface_state_control(phy_interface_state_e new_state, uint8_t rf_channel)
Wolfgang Betz 68:247fd6e0ab66 462 {
Wolfgang Betz 68:247fd6e0ab66 463 int8_t ret_val = 0;
Wolfgang Betz 68:247fd6e0ab66 464 switch (new_state)
Wolfgang Betz 68:247fd6e0ab66 465 {
Wolfgang Betz 68:247fd6e0ab66 466 /*Reset PHY driver and set to idle*/
Wolfgang Betz 68:247fd6e0ab66 467 case PHY_INTERFACE_RESET:
Wolfgang Betz 68:247fd6e0ab66 468 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 469 rf_device->reset_board();
Wolfgang Betz 68:247fd6e0ab66 470 break;
Wolfgang Betz 68:247fd6e0ab66 471 /*Disable PHY Interface driver*/
Wolfgang Betz 68:247fd6e0ab66 472 case PHY_INTERFACE_DOWN:
Wolfgang Betz 68:247fd6e0ab66 473 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 474 ret_val = rf_device->off();
Wolfgang Betz 68:247fd6e0ab66 475 if(ret_val != 0) ret_val = -1;
Wolfgang Betz 68:247fd6e0ab66 476 break;
Wolfgang Betz 68:247fd6e0ab66 477 /*Enable PHY Interface driver*/
Wolfgang Betz 68:247fd6e0ab66 478 case PHY_INTERFACE_UP:
Wolfgang Betz 68:247fd6e0ab66 479 ret_val = rf_device->on();
Wolfgang Betz 68:247fd6e0ab66 480 if(ret_val != 0) {
Wolfgang Betz 68:247fd6e0ab66 481 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 482 ret_val = -1;
Wolfgang Betz 68:247fd6e0ab66 483 break;
Wolfgang Betz 68:247fd6e0ab66 484 }
Wolfgang Betz 68:247fd6e0ab66 485 tr_debug("%s (%d) - channel: %d", __func__, __LINE__, (int)rf_channel);
Wolfgang Betz 68:247fd6e0ab66 486 rf_device->set_channel(rf_channel);
Wolfgang Betz 68:247fd6e0ab66 487 break;
Wolfgang Betz 68:247fd6e0ab66 488 /*Enable wireless interface ED scan mode*/
Wolfgang Betz 68:247fd6e0ab66 489 case PHY_INTERFACE_RX_ENERGY_STATE:
Wolfgang Betz 68:247fd6e0ab66 490 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 491 break;
Wolfgang Betz 68:247fd6e0ab66 492 /*Enable Sniffer state*/
Wolfgang Betz 68:247fd6e0ab66 493 case PHY_INTERFACE_SNIFFER_STATE:
Wolfgang Betz 68:247fd6e0ab66 494 // TODO - if we really need this - WAS: rf_setup_sniffer(rf_channel);
Wolfgang Betz 68:247fd6e0ab66 495 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 496 ret_val = -1;
Wolfgang Betz 68:247fd6e0ab66 497 break;
Wolfgang Betz 68:247fd6e0ab66 498 default:
Wolfgang Betz 68:247fd6e0ab66 499 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 500 break;
Wolfgang Betz 68:247fd6e0ab66 501 }
Wolfgang Betz 68:247fd6e0ab66 502 return ret_val;
Wolfgang Betz 68:247fd6e0ab66 503 }
Wolfgang Betz 68:247fd6e0ab66 504
Wolfgang Betz 68:247fd6e0ab66 505 static int8_t rf_extension(phy_extension_type_e extension_type, uint8_t *data_ptr)
Wolfgang Betz 68:247fd6e0ab66 506 {
Wolfgang Betz 68:247fd6e0ab66 507 switch (extension_type)
Wolfgang Betz 68:247fd6e0ab66 508 {
Wolfgang Betz 68:247fd6e0ab66 509 /*Control MAC pending bit for Indirect data transmission*/
Wolfgang Betz 68:247fd6e0ab66 510 case PHY_EXTENSION_CTRL_PENDING_BIT:
Wolfgang Betz 68:247fd6e0ab66 511 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 512 break;
Wolfgang Betz 68:247fd6e0ab66 513
Wolfgang Betz 68:247fd6e0ab66 514 /*Return frame pending status*/
Wolfgang Betz 68:247fd6e0ab66 515 case PHY_EXTENSION_READ_LAST_ACK_PENDING_STATUS:
Wolfgang Betz 68:247fd6e0ab66 516 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 517 *data_ptr = 0;
Wolfgang Betz 68:247fd6e0ab66 518 break;
Wolfgang Betz 68:247fd6e0ab66 519
Wolfgang Betz 68:247fd6e0ab66 520 /*Set channel, used for setting channel for energy scan*/
Wolfgang Betz 68:247fd6e0ab66 521 case PHY_EXTENSION_SET_CHANNEL:
Wolfgang Betz 68:247fd6e0ab66 522 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 523 break;
Wolfgang Betz 68:247fd6e0ab66 524
Wolfgang Betz 68:247fd6e0ab66 525 /*Read energy on the channel*/
Wolfgang Betz 68:247fd6e0ab66 526 case PHY_EXTENSION_READ_CHANNEL_ENERGY:
Wolfgang Betz 68:247fd6e0ab66 527 // TODO: *data_ptr = rf_get_channel_energy();
Wolfgang Betz 68:247fd6e0ab66 528 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 529 *data_ptr = (int8_t)rf_device->get_last_rssi_dbm();
Wolfgang Betz 68:247fd6e0ab66 530 break;
Wolfgang Betz 68:247fd6e0ab66 531
Wolfgang Betz 68:247fd6e0ab66 532 /*Read status of the link*/
Wolfgang Betz 68:247fd6e0ab66 533 case PHY_EXTENSION_READ_LINK_STATUS:
Wolfgang Betz 68:247fd6e0ab66 534 // TODO: *data_ptr = rf_get_link_status();
Wolfgang Betz 68:247fd6e0ab66 535 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 536 *data_ptr = rf_device->get_last_sqi(); // use SQI as link quality
Wolfgang Betz 68:247fd6e0ab66 537 break;
Wolfgang Betz 68:247fd6e0ab66 538
Wolfgang Betz 68:247fd6e0ab66 539 default:
Wolfgang Betz 68:247fd6e0ab66 540 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 68:247fd6e0ab66 541 break;
Wolfgang Betz 68:247fd6e0ab66 542 }
Wolfgang Betz 68:247fd6e0ab66 543 return 0;
Wolfgang Betz 68:247fd6e0ab66 544 }
Wolfgang Betz 68:247fd6e0ab66 545
Wolfgang Betz 68:247fd6e0ab66 546 static inline void rf_set_mac_address(uint8_t *ptr) {
Wolfgang Betz 68:247fd6e0ab66 547 tr_debug("%s (%d), adr0=%x, adr1=%x, adr2=%x, adr3=%x, adr4=%x, adr5=%x, adr6=%x, adr7=%x",
Wolfgang Betz 68:247fd6e0ab66 548 __func__, __LINE__,
Wolfgang Betz 68:247fd6e0ab66 549 ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]);
Wolfgang Betz 68:247fd6e0ab66 550 for(int i = 0; i < 8; i++) {
Wolfgang Betz 68:247fd6e0ab66 551 stored_mac_address[i] = ptr[i];
Wolfgang Betz 68:247fd6e0ab66 552 }
Wolfgang Betz 68:247fd6e0ab66 553 }
Wolfgang Betz 68:247fd6e0ab66 554
Wolfgang Betz 68:247fd6e0ab66 555 static inline void rf_get_mac_address(uint8_t *ptr) {
Wolfgang Betz 68:247fd6e0ab66 556 for(int i = 0; i < 8; i++) {
Wolfgang Betz 68:247fd6e0ab66 557 ptr[i] = stored_mac_address[i];
Wolfgang Betz 68:247fd6e0ab66 558 }
Wolfgang Betz 68:247fd6e0ab66 559 tr_debug("%s (%d), adr0=%x, adr1=%x, adr2=%x, adr3=%x, adr4=%x, adr5=%x, adr6=%x, adr7=%x",
Wolfgang Betz 68:247fd6e0ab66 560 __func__, __LINE__,
Wolfgang Betz 68:247fd6e0ab66 561 ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]);
Wolfgang Betz 68:247fd6e0ab66 562 }
Wolfgang Betz 68:247fd6e0ab66 563
Wolfgang Betz 68:247fd6e0ab66 564 static inline void rf_set_short_adr(uint8_t *ptr) {
Wolfgang Betz 68:247fd6e0ab66 565 stored_short_adr = (ptr[0] << 8) + ptr[1]; // big-endian
Wolfgang Betz 68:247fd6e0ab66 566 tr_debug("%s (%d), adr0=%x, adr1=%x, val=%d",
Wolfgang Betz 68:247fd6e0ab66 567 __func__, __LINE__,
Wolfgang Betz 68:247fd6e0ab66 568 ptr[0], ptr[1], stored_short_adr);
Wolfgang Betz 68:247fd6e0ab66 569 }
Wolfgang Betz 68:247fd6e0ab66 570
Wolfgang Betz 68:247fd6e0ab66 571 static inline void rf_set_pan_id(uint8_t *ptr) {
Wolfgang Betz 68:247fd6e0ab66 572 stored_pan_id = (ptr[0] << 8) + ptr[1]; // big-endian
Wolfgang Betz 68:247fd6e0ab66 573 tr_debug("%s (%d), adr0=%x, adr1=%x, val=%d",
Wolfgang Betz 68:247fd6e0ab66 574 __func__, __LINE__,
Wolfgang Betz 68:247fd6e0ab66 575 ptr[0], ptr[1], stored_pan_id);
Wolfgang Betz 68:247fd6e0ab66 576 }
Wolfgang Betz 68:247fd6e0ab66 577
Wolfgang Betz 68:247fd6e0ab66 578 static int8_t rf_address_write(phy_address_type_e address_type, uint8_t *address_ptr)
Wolfgang Betz 68:247fd6e0ab66 579 {
Wolfgang Betz 68:247fd6e0ab66 580 switch (address_type)
Wolfgang Betz 68:247fd6e0ab66 581 {
Wolfgang Betz 68:247fd6e0ab66 582 /*Set 48-bit address*/
Wolfgang Betz 68:247fd6e0ab66 583 case PHY_MAC_48BIT:
Wolfgang Betz 68:247fd6e0ab66 584 /* Not used in this example */
Wolfgang Betz 68:247fd6e0ab66 585 // betzw - WAS: rf_set_mac_48bit(address_ptr);
Wolfgang Betz 68:247fd6e0ab66 586 break;
Wolfgang Betz 68:247fd6e0ab66 587 /*Set 64-bit address*/
Wolfgang Betz 68:247fd6e0ab66 588 case PHY_MAC_64BIT:
Wolfgang Betz 68:247fd6e0ab66 589 rf_set_mac_address(address_ptr);
Wolfgang Betz 68:247fd6e0ab66 590 break;
Wolfgang Betz 68:247fd6e0ab66 591 /*Set 16-bit address*/
Wolfgang Betz 68:247fd6e0ab66 592 case PHY_MAC_16BIT:
Wolfgang Betz 68:247fd6e0ab66 593 rf_set_short_adr(address_ptr);
Wolfgang Betz 68:247fd6e0ab66 594 break;
Wolfgang Betz 68:247fd6e0ab66 595 /*Set PAN Id*/
Wolfgang Betz 68:247fd6e0ab66 596 case PHY_MAC_PANID:
Wolfgang Betz 68:247fd6e0ab66 597 rf_set_pan_id(address_ptr);
Wolfgang Betz 68:247fd6e0ab66 598 break;
Wolfgang Betz 68:247fd6e0ab66 599 }
Wolfgang Betz 68:247fd6e0ab66 600
Wolfgang Betz 68:247fd6e0ab66 601 return 0;
Wolfgang Betz 68:247fd6e0ab66 602 }
Wolfgang Betz 68:247fd6e0ab66 603
Wolfgang Betz 38:5deec3ab2025 604 static void rf_ack_loop(void) {
Wolfgang Betz 53:b036a3a850e6 605 static uint16_t buffer[2] = {
Wolfgang Betz 62:44ab5af08199 606 (FC_ACK_FRAME << MAC_FCF_FRAME_TYPE_SHIFT),
Wolfgang Betz 62:44ab5af08199 607 0x0
Wolfgang Betz 53:b036a3a850e6 608 };
Wolfgang Betz 53:b036a3a850e6 609
Wolfgang Betz 53:b036a3a850e6 610 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 611
Wolfgang Betz 53:b036a3a850e6 612 do {
Wolfgang Betz 62:44ab5af08199 613 /* Wait for signal */
Wolfgang Betz 62:44ab5af08199 614 osEvent event = rf_ack_sender.signal_wait(0);
Wolfgang Betz 38:5deec3ab2025 615
Wolfgang Betz 62:44ab5af08199 616 if(event.status != osEventSignal) {
Wolfgang Betz 53:b036a3a850e6 617 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 618 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 53:b036a3a850e6 619 #endif
Wolfgang Betz 62:44ab5af08199 620 continue;
Wolfgang Betz 62:44ab5af08199 621 }
Wolfgang Betz 53:b036a3a850e6 622
Wolfgang Betz 62:44ab5af08199 623 int32_t signals = event.value.signals;
Wolfgang Betz 38:5deec3ab2025 624
Wolfgang Betz 38:5deec3ab2025 625 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 626 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 627 #endif
Wolfgang Betz 38:5deec3ab2025 628
Wolfgang Betz 62:44ab5af08199 629 /* Get Lock */
Wolfgang Betz 62:44ab5af08199 630 rf_if_lock();
Wolfgang Betz 53:b036a3a850e6 631
Wolfgang Betz 62:44ab5af08199 632 if(signals & RF_SIG_ACK_NEEDED) {
Wolfgang Betz 53:b036a3a850e6 633 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 634 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 53:b036a3a850e6 635 #endif
Wolfgang Betz 53:b036a3a850e6 636
Wolfgang Betz 62:44ab5af08199 637 /* Prepare payload */
Wolfgang Betz 62:44ab5af08199 638 uint8_t *ptr = (uint8_t*)&buffer[1];
Wolfgang Betz 62:44ab5af08199 639 ptr[0] = rf_rx_sequence; // Sequence number
Wolfgang Betz 38:5deec3ab2025 640
Wolfgang Betz 62:44ab5af08199 641 /* Wait for device not receiving */
Wolfgang Betz 62:44ab5af08199 642 while(rf_device->is_receiving()) {
Wolfgang Betz 53:b036a3a850e6 643 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 644 tr_info("%s (%d)", __func__, __LINE__);
Wolfgang Betz 53:b036a3a850e6 645 #endif
Wolfgang Betz 62:44ab5af08199 646 wait_us(10);
Wolfgang Betz 62:44ab5af08199 647 }
Wolfgang Betz 53:b036a3a850e6 648
Wolfgang Betz 53:b036a3a850e6 649 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 650 tr_debug("%s (%d), hdr=%x, nr=%x", __func__, __LINE__, buffer[0], ptr[0]);
Wolfgang Betz 53:b036a3a850e6 651 #endif
Wolfgang Betz 53:b036a3a850e6 652
Wolfgang Betz 62:44ab5af08199 653 /* Set information that we have sent an ACK */
Wolfgang Betz 62:44ab5af08199 654 rf_ack_sent = true;
Wolfgang Betz 53:b036a3a850e6 655
Wolfgang Betz 62:44ab5af08199 656 /*Send the packet*/
Wolfgang Betz 64:28ef790e4ef7 657 rf_device->send((uint8_t*)buffer, 3, false);
Wolfgang Betz 53:b036a3a850e6 658
Wolfgang Betz 58:4208689e447e 659 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 660 tr_debug("%s (%d), hdr=%x, nr=%x", __func__, __LINE__, buffer[0], ptr[0]);
Wolfgang Betz 58:4208689e447e 661 #endif
Wolfgang Betz 62:44ab5af08199 662 }
Wolfgang Betz 53:b036a3a850e6 663
Wolfgang Betz 62:44ab5af08199 664 if(signals & RF_SIG_CB_TX_DONE) {
Wolfgang Betz 68:247fd6e0ab66 665 device_driver.phy_tx_done_cb(rf_radio_driver_id, mac_tx_handle, phy_status,
Wolfgang Betz 68:247fd6e0ab66 666 (phy_status == PHY_LINK_CCA_FAIL) ? 0xFF : 0, 0);
Wolfgang Betz 38:5deec3ab2025 667 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 668 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 669 #endif
Wolfgang Betz 62:44ab5af08199 670 }
Wolfgang Betz 38:5deec3ab2025 671
Wolfgang Betz 62:44ab5af08199 672 if(signals & RF_SIG_CB_RX_RCVD) {
Wolfgang Betz 62:44ab5af08199 673 device_driver.phy_rx_cb(rf_rx_buf, rf_buffer_len, rf_sqi, rf_rssi, rf_radio_driver_id);
Wolfgang Betz 38:5deec3ab2025 674 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 675 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 676 #endif
Wolfgang Betz 62:44ab5af08199 677 }
Wolfgang Betz 38:5deec3ab2025 678
Wolfgang Betz 62:44ab5af08199 679 /* Release Lock */
Wolfgang Betz 62:44ab5af08199 680 rf_if_unlock();
Wolfgang Betz 38:5deec3ab2025 681
Wolfgang Betz 38:5deec3ab2025 682 #ifdef HEAVY_TRACING
Wolfgang Betz 62:44ab5af08199 683 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 684 #endif
Wolfgang Betz 53:b036a3a850e6 685 } while(true);
Wolfgang Betz 38:5deec3ab2025 686 }
Wolfgang Betz 38:5deec3ab2025 687
Wolfgang Betz 38:5deec3ab2025 688 void NanostackRfPhySpirit1::rf_init(void) {
Wolfgang Betz 38:5deec3ab2025 689 #ifndef NDEBUG
Wolfgang Betz 53:b036a3a850e6 690 osStatus ret;
Wolfgang Betz 38:5deec3ab2025 691 #endif
Wolfgang Betz 38:5deec3ab2025 692
Wolfgang Betz 53:b036a3a850e6 693 if(rf_device == NULL) {
Wolfgang Betz 62:44ab5af08199 694 rf_device = &SimpleSpirit1::CreateInstance(_spi_mosi, _spi_miso, _spi_sclk, _dev_irq, _dev_cs, _dev_sdn, _brd_led);
Wolfgang Betz 62:44ab5af08199 695 rf_device->attach_irq_callback(rf_callback_func);
Wolfgang Betz 38:5deec3ab2025 696
Wolfgang Betz 38:5deec3ab2025 697 #ifndef NDEBUG
Wolfgang Betz 62:44ab5af08199 698 ret =
Wolfgang Betz 38:5deec3ab2025 699 #endif
Wolfgang Betz 62:44ab5af08199 700 rf_ack_sender.start(rf_ack_loop);
Wolfgang Betz 38:5deec3ab2025 701
Wolfgang Betz 38:5deec3ab2025 702 #ifndef NDEBUG
Wolfgang Betz 68:247fd6e0ab66 703 debug_if(!(ret == osOK), "\r\nassert failed in: %s (%d)\r\n", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 704 #endif
Wolfgang Betz 53:b036a3a850e6 705 }
Wolfgang Betz 38:5deec3ab2025 706 }
Wolfgang Betz 38:5deec3ab2025 707
Wolfgang Betz 38:5deec3ab2025 708 NanostackRfPhySpirit1::NanostackRfPhySpirit1(PinName spi_mosi, PinName spi_miso, PinName spi_sclk,
Wolfgang Betz 62:44ab5af08199 709 PinName dev_irq, PinName dev_cs, PinName dev_sdn, PinName brd_led) :
Wolfgang Betz 63:d7530f62ed93 710 _spi_mosi(spi_mosi),
Wolfgang Betz 63:d7530f62ed93 711 _spi_miso(spi_miso),
Wolfgang Betz 63:d7530f62ed93 712 _spi_sclk(spi_sclk),
Wolfgang Betz 63:d7530f62ed93 713 _dev_irq(dev_irq),
Wolfgang Betz 63:d7530f62ed93 714 _dev_cs(dev_cs),
Wolfgang Betz 63:d7530f62ed93 715 _dev_sdn(dev_sdn),
Wolfgang Betz 63:d7530f62ed93 716 _brd_led(brd_led)
Wolfgang Betz 38:5deec3ab2025 717 {
Wolfgang Betz 53:b036a3a850e6 718 /* Nothing to do */
Wolfgang Betz 53:b036a3a850e6 719 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 720 }
Wolfgang Betz 38:5deec3ab2025 721
Wolfgang Betz 38:5deec3ab2025 722 NanostackRfPhySpirit1::~NanostackRfPhySpirit1()
Wolfgang Betz 38:5deec3ab2025 723 {
Wolfgang Betz 53:b036a3a850e6 724 /* Nothing to do */
Wolfgang Betz 53:b036a3a850e6 725 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 726 }
Wolfgang Betz 38:5deec3ab2025 727
Wolfgang Betz 38:5deec3ab2025 728 int8_t NanostackRfPhySpirit1::rf_register()
Wolfgang Betz 38:5deec3ab2025 729 {
Wolfgang Betz 53:b036a3a850e6 730 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 731
Wolfgang Betz 53:b036a3a850e6 732 /* Get Lock */
Wolfgang Betz 53:b036a3a850e6 733 rf_if_lock();
Wolfgang Betz 38:5deec3ab2025 734
Wolfgang Betz 38:5deec3ab2025 735 /* Do some initialization */
Wolfgang Betz 38:5deec3ab2025 736 rf_init();
Wolfgang Betz 38:5deec3ab2025 737
Wolfgang Betz 38:5deec3ab2025 738 /* Set pointer to MAC address */
Wolfgang Betz 38:5deec3ab2025 739 device_driver.PHY_MAC = stored_mac_address;
Wolfgang Betz 38:5deec3ab2025 740
Wolfgang Betz 38:5deec3ab2025 741 /* Set driver Name */
Wolfgang Betz 38:5deec3ab2025 742 device_driver.driver_description = (char*)"Spirit1 Sub-GHz RF";
Wolfgang Betz 38:5deec3ab2025 743
Wolfgang Betz 38:5deec3ab2025 744 /*Type of RF PHY is SubGHz*/
Wolfgang Betz 38:5deec3ab2025 745 device_driver.link_type = PHY_LINK_15_4_SUBGHZ_TYPE;
Wolfgang Betz 38:5deec3ab2025 746
Wolfgang Betz 39:75481c4c6655 747 /*Maximum size of payload*/
Wolfgang Betz 38:5deec3ab2025 748 device_driver.phy_MTU = MAX_PACKET_LEN;
Wolfgang Betz 38:5deec3ab2025 749
Wolfgang Betz 38:5deec3ab2025 750 /*No header in PHY*/
Wolfgang Betz 38:5deec3ab2025 751 device_driver.phy_header_length = 0;
Wolfgang Betz 38:5deec3ab2025 752
Wolfgang Betz 38:5deec3ab2025 753 /*No tail in PHY*/
Wolfgang Betz 38:5deec3ab2025 754 device_driver.phy_tail_length = 0;
Wolfgang Betz 38:5deec3ab2025 755
Wolfgang Betz 38:5deec3ab2025 756 /*Set up driver functions*/
Wolfgang Betz 38:5deec3ab2025 757 device_driver.address_write = &rf_address_write;
Wolfgang Betz 38:5deec3ab2025 758 device_driver.extension = &rf_extension;
Wolfgang Betz 38:5deec3ab2025 759 device_driver.state_control = &rf_interface_state_control;
Wolfgang Betz 38:5deec3ab2025 760 device_driver.tx = &rf_trigger_send;
Wolfgang Betz 38:5deec3ab2025 761
Wolfgang Betz 38:5deec3ab2025 762 /*Set supported channel pages*/
Wolfgang Betz 38:5deec3ab2025 763 device_driver.phy_channel_pages = phy_channel_pages;
Wolfgang Betz 38:5deec3ab2025 764
Wolfgang Betz 38:5deec3ab2025 765 //Nullify rx/tx callbacks
Wolfgang Betz 38:5deec3ab2025 766 device_driver.phy_rx_cb = NULL;
Wolfgang Betz 38:5deec3ab2025 767 device_driver.phy_tx_done_cb = NULL;
Wolfgang Betz 38:5deec3ab2025 768 device_driver.arm_net_virtual_rx_cb = NULL;
Wolfgang Betz 38:5deec3ab2025 769 device_driver.arm_net_virtual_tx_cb = NULL;
Wolfgang Betz 38:5deec3ab2025 770
Wolfgang Betz 38:5deec3ab2025 771 /*Register device driver*/
Wolfgang Betz 38:5deec3ab2025 772 rf_radio_driver_id = arm_net_phy_register(&device_driver);
Wolfgang Betz 38:5deec3ab2025 773
Wolfgang Betz 53:b036a3a850e6 774 /* Release Lock */
Wolfgang Betz 53:b036a3a850e6 775 rf_if_unlock();
Wolfgang Betz 38:5deec3ab2025 776
Wolfgang Betz 53:b036a3a850e6 777 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 778 return rf_radio_driver_id;
Wolfgang Betz 38:5deec3ab2025 779 }
Wolfgang Betz 38:5deec3ab2025 780
Wolfgang Betz 38:5deec3ab2025 781 void NanostackRfPhySpirit1::rf_unregister()
Wolfgang Betz 38:5deec3ab2025 782 {
Wolfgang Betz 53:b036a3a850e6 783 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 784
Wolfgang Betz 53:b036a3a850e6 785 /* Get Lock */
Wolfgang Betz 53:b036a3a850e6 786 rf_if_lock();
Wolfgang Betz 38:5deec3ab2025 787
Wolfgang Betz 38:5deec3ab2025 788 if (rf_radio_driver_id >= 0) {
Wolfgang Betz 38:5deec3ab2025 789 arm_net_phy_unregister(rf_radio_driver_id);
Wolfgang Betz 38:5deec3ab2025 790 rf_radio_driver_id = -1;
Wolfgang Betz 38:5deec3ab2025 791 }
Wolfgang Betz 38:5deec3ab2025 792
Wolfgang Betz 53:b036a3a850e6 793 /* Release Lock */
Wolfgang Betz 53:b036a3a850e6 794 rf_if_unlock();
Wolfgang Betz 38:5deec3ab2025 795 }
Wolfgang Betz 38:5deec3ab2025 796
Wolfgang Betz 38:5deec3ab2025 797 void NanostackRfPhySpirit1::get_mac_address(uint8_t *mac)
Wolfgang Betz 38:5deec3ab2025 798 {
Wolfgang Betz 53:b036a3a850e6 799 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 800
Wolfgang Betz 53:b036a3a850e6 801 /* Get Lock */
Wolfgang Betz 53:b036a3a850e6 802 rf_if_lock();
Wolfgang Betz 38:5deec3ab2025 803
Wolfgang Betz 53:b036a3a850e6 804 if(rf_radio_driver_id >= 0) {
Wolfgang Betz 62:44ab5af08199 805 rf_get_mac_address(mac);
Wolfgang Betz 53:b036a3a850e6 806 } else {
Wolfgang Betz 38:5deec3ab2025 807 error("NanostackRfPhySpirit1 must be registered to read mac address");
Wolfgang Betz 53:b036a3a850e6 808 }
Wolfgang Betz 38:5deec3ab2025 809
Wolfgang Betz 53:b036a3a850e6 810 /* Release Lock */
Wolfgang Betz 53:b036a3a850e6 811 rf_if_unlock();
Wolfgang Betz 38:5deec3ab2025 812 }
Wolfgang Betz 38:5deec3ab2025 813
Wolfgang Betz 38:5deec3ab2025 814 void NanostackRfPhySpirit1::set_mac_address(uint8_t *mac)
Wolfgang Betz 38:5deec3ab2025 815 {
Wolfgang Betz 53:b036a3a850e6 816 tr_debug("%s (%d)", __func__, __LINE__);
Wolfgang Betz 38:5deec3ab2025 817
Wolfgang Betz 53:b036a3a850e6 818 /* Get Lock */
Wolfgang Betz 53:b036a3a850e6 819 rf_if_lock();
Wolfgang Betz 38:5deec3ab2025 820
Wolfgang Betz 53:b036a3a850e6 821 if(rf_radio_driver_id < 0) {
Wolfgang Betz 62:44ab5af08199 822 rf_set_mac_address(mac);
Wolfgang Betz 53:b036a3a850e6 823 } else {
Wolfgang Betz 38:5deec3ab2025 824 error("NanostackRfPhySpirit1 cannot change mac address when running");
Wolfgang Betz 53:b036a3a850e6 825 }
Wolfgang Betz 38:5deec3ab2025 826
Wolfgang Betz 53:b036a3a850e6 827 /* Release Lock */
Wolfgang Betz 53:b036a3a850e6 828 rf_if_unlock();
Wolfgang Betz 38:5deec3ab2025 829 }
Wolfgang Betz 61:0e6aa2ea086f 830
Wolfgang Betz 61:0e6aa2ea086f 831 #endif /* MBED_CONF_RTOS_PRESENT */
Seppo Takalo 76:f4f990741baf 832 #endif /* MBED_CONF_NANOSTACK_CONFIGURATION */