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

Dependents:   DISCO_IOT-wifi_client

Fork of stm-spirit1-rf-driver by ST

Files at this revision

API Documentation at this revision

Comitter:
Wolfgang Betz
Date:
Thu Nov 24 08:47:27 2016 +0100
Parent:
38:5deec3ab2025
Child:
40:343254875d89
Commit message:
Treat RX/TX race condition in favor of TX

Changed in this revision

source/NanostackRfPhySpirit1.cpp Show annotated file Show diff for this revision Revisions of this file
source/SimpleSpirit1.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/source/NanostackRfPhySpirit1.cpp	Wed Nov 23 07:00:33 2016 +0100
+++ b/source/NanostackRfPhySpirit1.cpp	Thu Nov 24 08:47:27 2016 +0100
@@ -841,7 +841,7 @@
     /*Type of RF PHY is SubGHz*/
     device_driver.link_type = PHY_LINK_15_4_SUBGHZ_TYPE;
 
-    /*Maximum size of payload is 255*/
+    /*Maximum size of payload*/
     device_driver.phy_MTU = MAX_PACKET_LEN;
 
     /*No header in PHY*/
--- a/source/SimpleSpirit1.cpp	Wed Nov 23 07:00:33 2016 +0100
+++ b/source/SimpleSpirit1.cpp	Thu Nov 24 08:47:27 2016 +0100
@@ -563,12 +563,20 @@
 
 	/* The IRQ_VALID_SYNC is used to notify a new packet is coming */
 	if(x_irq_status.IRQ_VALID_SYNC) {
-		_is_receiving = true;
-		_spirit_rx_err = false;
-		CLEAR_RXBUF();
+		/* betzw - NOTE: there is a race condition between Spirit1 receiving packets and
+		 *               the MCU trying to send a packet, which gets resolved in favor of
+		 *               sending.
+		 */
+		if(_spirit_tx_started) {
 #ifdef DEBUG_IRQ
-		debug_if(_spirit_tx_started, "\n\rAssert failed in: %s (%d)\n\r", __func__, __LINE__);
+			uint32_t *tmp = (uint32_t*)&x_irq_status;
+			debug("\n\r%s (%d): irq=%x", __func__, __LINE__, *tmp);
 #endif
-		start_rx_timeout();
+		} else {
+			_is_receiving = true;
+			_spirit_rx_err = false;
+			CLEAR_RXBUF();
+			start_rx_timeout();
+		}
 	}
 }