@@ -487,6 +487,16 @@ static void rf_device_unregister(void)
487
487
}
488
488
}
489
489
490
+ /*
491
+ * \brief Function wraps thread signals to only send when thread is active
492
+ *
493
+ */
494
+ static void rf_thread_signal (osThreadId id, int32_t signal) {
495
+ if (id != NULL ) {
496
+ osSignalSet (id, signal);
497
+ }
498
+ }
499
+
490
500
/*
491
501
* \brief Function starts the CCA process before starting data transmission and copies the data to RF TX FIFO.
492
502
*
@@ -899,7 +909,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
899
909
*/
900
910
case RAIL_EVENT_RSSI_AVERAGE_DONE_SHIFT:
901
911
#ifdef MBED_CONF_RTOS_PRESENT
902
- osSignalSet (rf_thread_id, SL_RSSI_DONE);
912
+ rf_thread_signal (rf_thread_id, SL_RSSI_DONE);
903
913
#else
904
914
SL_DEBUG_PRINT (" RSSI done (%d)\n " , RAIL_GetAverageRssi (gRailHandle ));
905
915
#endif
@@ -913,7 +923,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
913
923
if (waiting_for_ack) {
914
924
waiting_for_ack = false ;
915
925
#ifdef MBED_CONF_RTOS_PRESENT
916
- osSignalSet (rf_thread_id, SL_ACK_TIMEOUT);
926
+ rf_thread_signal (rf_thread_id, SL_ACK_TIMEOUT);
917
927
#else
918
928
device_driver.phy_tx_done_cb ( rf_radio_driver_id,
919
929
current_tx_handle,
@@ -930,7 +940,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
930
940
*/
931
941
case RAIL_EVENT_RX_FIFO_ALMOST_FULL_SHIFT:
932
942
#ifdef MBED_CONF_RTOS_PRESENT
933
- osSignalSet (rf_thread_id, SL_RXFIFO_ERR);
943
+ rf_thread_signal (rf_thread_id, SL_RXFIFO_ERR);
934
944
#else
935
945
SL_DEBUG_PRINT (" RX near full (%d)\n " , RAIL_GetRxFifoBytesAvailable (gRailHandle ));
936
946
#endif
@@ -995,7 +1005,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
995
1005
last_ack_pending_bit = (packetBuffer[2 +1 ] & (1 << 4 )) != 0 ;
996
1006
/* Tell the stack we got an ACK */
997
1007
#ifdef MBED_CONF_RTOS_PRESENT
998
- osSignalSet (rf_thread_id, SL_ACK_RECV | (last_ack_pending_bit ? SL_ACK_PEND : 0 ));
1008
+ rf_thread_signal (rf_thread_id, SL_ACK_RECV | (last_ack_pending_bit ? SL_ACK_PEND : 0 ));
999
1009
#else
1000
1010
SL_DEBUG_PRINT (" rACK\n " );
1001
1011
device_driver.phy_tx_done_cb ( rf_radio_driver_id,
@@ -1023,10 +1033,10 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
1023
1033
if (((rx_queue_head + 1 ) % RF_QUEUE_SIZE) != rx_queue_tail) {
1024
1034
rx_queue[rx_queue_head] = (void *)packetBuffer;
1025
1035
rx_queue_head = (rx_queue_head + 1 ) % RF_QUEUE_SIZE;
1026
- osSignalSet (rf_thread_id, SL_RX_DONE);
1036
+ rf_thread_signal (rf_thread_id, SL_RX_DONE);
1027
1037
} else {
1028
1038
free (packetBuffer);
1029
- osSignalSet (rf_thread_id, SL_QUEUE_FULL);
1039
+ rf_thread_signal (rf_thread_id, SL_QUEUE_FULL);
1030
1040
}
1031
1041
#else
1032
1042
SL_DEBUG_PRINT (" rPKT %d\n " , rxPacket[2 ] - 2 );
@@ -1117,7 +1127,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
1117
1127
*/
1118
1128
case RAIL_EVENT_TX_FIFO_ALMOST_EMPTY_SHIFT:
1119
1129
#ifdef MBED_CONF_RTOS_PRESENT
1120
- osSignalSet (rf_thread_id, SL_TXFIFO_ERR);
1130
+ rf_thread_signal (rf_thread_id, SL_TXFIFO_ERR);
1121
1131
#else
1122
1132
SL_DEBUG_PRINT (" TX near empty (%d)\n " , spaceAvailable);
1123
1133
#endif
@@ -1131,7 +1141,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
1131
1141
*/
1132
1142
case RAIL_EVENT_TX_PACKET_SENT_SHIFT:
1133
1143
#ifdef MBED_CONF_RTOS_PRESENT
1134
- osSignalSet (rf_thread_id, SL_TX_DONE);
1144
+ rf_thread_signal (rf_thread_id, SL_TX_DONE);
1135
1145
#else
1136
1146
if (device_driver.phy_tx_done_cb != NULL ) {
1137
1147
device_driver.phy_tx_done_cb ( rf_radio_driver_id,
@@ -1158,7 +1168,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
1158
1168
/* Occurs when a TX is aborted by the user */
1159
1169
case RAIL_EVENT_TX_ABORTED_SHIFT:
1160
1170
#ifdef MBED_CONF_RTOS_PRESENT
1161
- osSignalSet (rf_thread_id, SL_TX_TIMEOUT);
1171
+ rf_thread_signal (rf_thread_id, SL_TX_TIMEOUT);
1162
1172
#else
1163
1173
device_driver.phy_tx_done_cb (rf_radio_driver_id,
1164
1174
current_tx_handle,
@@ -1175,7 +1185,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
1175
1185
/* Occurs when a TX is blocked by something like PTA or RHO */
1176
1186
case RAIL_EVENT_TX_BLOCKED_SHIFT:
1177
1187
#ifdef MBED_CONF_RTOS_PRESENT
1178
- osSignalSet (rf_thread_id, SL_TX_TIMEOUT);
1188
+ rf_thread_signal (rf_thread_id, SL_TX_TIMEOUT);
1179
1189
#else
1180
1190
device_driver.phy_tx_done_cb (rf_radio_driver_id,
1181
1191
current_tx_handle,
@@ -1192,7 +1202,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
1192
1202
/* Occurs when the TX buffer underflows */
1193
1203
case RAIL_EVENT_TX_UNDERFLOW_SHIFT:
1194
1204
#ifdef MBED_CONF_RTOS_PRESENT
1195
- osSignalSet (rf_thread_id, SL_TX_TIMEOUT);
1205
+ rf_thread_signal (rf_thread_id, SL_TX_TIMEOUT);
1196
1206
#else
1197
1207
device_driver.phy_tx_done_cb (rf_radio_driver_id,
1198
1208
current_tx_handle,
@@ -1212,7 +1222,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
1212
1222
/* Occurs when CCA/CSMA/LBT fails */
1213
1223
case RAIL_EVENT_TX_CHANNEL_BUSY_SHIFT:
1214
1224
#ifdef MBED_CONF_RTOS_PRESENT
1215
- osSignalSet (rf_thread_id, SL_TX_TIMEOUT);
1225
+ rf_thread_signal (rf_thread_id, SL_TX_TIMEOUT);
1216
1226
#else
1217
1227
device_driver.phy_tx_done_cb (rf_radio_driver_id,
1218
1228
current_tx_handle,
@@ -1252,7 +1262,7 @@ static void radioEventHandler(RAIL_Handle_t railHandle,
1252
1262
*/
1253
1263
case RAIL_EVENT_CAL_NEEDED_SHIFT:
1254
1264
#ifdef MBED_CONF_RTOS_PRESENT
1255
- osSignalSet (rf_thread_id, SL_CAL_REQ);
1265
+ rf_thread_signal (rf_thread_id, SL_CAL_REQ);
1256
1266
#else
1257
1267
SL_DEBUG_PRINT (" !!!! Calling for calibration\n " );
1258
1268
#endif
0 commit comments