센서보드 RF IRQ 테스트 중

Fork of stm-spirit1-rf-driver by ST

Files at this revision

API Documentation at this revision

Comitter:
Wolfgang Betz
Date:
Fri Dec 02 10:51:18 2016 +0100
Parent:
41:ebaceefad0de
Child:
43:a512f909514a
Commit message:
Double check for IRQ sources

Changed in this revision

source/SimpleSpirit1.cpp Show annotated file Show diff for this revision Revisions of this file
source/libs/spirit1/SPIRIT1_Library/Inc/SPIRIT_Irq.h Show annotated file Show diff for this revision Revisions of this file
--- a/source/SimpleSpirit1.cpp	Wed Nov 30 11:58:18 2016 +0100
+++ b/source/SimpleSpirit1.cpp	Fri Dec 02 10:51:18 2016 +0100
@@ -448,6 +448,7 @@
 #ifdef DEBUG_IRQ
 		uint32_t *tmp = (uint32_t*)&x_irq_status;
 		debug("\n\r%s (%d): irq=%x", __func__, __LINE__, *tmp);
+		debug_if(!((*tmp) & (IRQ_RX_FIFO_ERROR_MASK | IRQ_RX_DATA_DISC_MASK)), "\n\rAssert failed in: %s (%d)", __func__, __LINE__);
 #endif
 		rx_timeout_handler();
 		if(_spirit_tx_started) {
@@ -467,6 +468,7 @@
 #ifdef DEBUG_IRQ
 		uint32_t *tmp = (uint32_t*)&x_irq_status;
 		debug("\n\r%s (%d): irq=%x", __func__, __LINE__, *tmp);
+		debug_if(!((*tmp) & IRQ_TX_FIFO_ERROR_MASK), "\n\rAssert failed in: %s (%d)", __func__, __LINE__);
 #endif
 		csma_ca_state(S_DISABLE); // disable CSMA/CA
 		if(_spirit_tx_started) {
@@ -484,7 +486,9 @@
 	/* The IRQ_TX_DATA_SENT notifies the packet received. Puts the SPIRIT1 in RX */
 	if(x_irq_status.IRQ_TX_DATA_SENT) {
 #ifdef DEBUG_IRQ
+		uint32_t *tmp = (uint32_t*)&x_irq_status;
 		debug_if(!_spirit_tx_started, "\n\rAssert failed in: %s (%d)\n\r", __func__, __LINE__);
+		debug_if(!((*tmp) & IRQ_TX_DATA_SENT_MASK), "\n\rAssert failed in: %s (%d)", __func__, __LINE__);
 #endif
 
 		_spirit_tx_started = false;
@@ -497,6 +501,10 @@
 
 	/* RX FIFO almost full */
 	if(x_irq_status.IRQ_RX_FIFO_ALMOST_FULL) {
+#ifdef DEBUG_IRQ
+		uint32_t *tmp = (uint32_t*)&x_irq_status;
+		debug_if(!((*tmp) & IRQ_RX_FIFO_ALMOST_FULL_MASK), "\n\rAssert failed in: %s (%d)", __func__, __LINE__);
+#endif
 		uint8_t fifo_available = linear_fifo_read_num_elements_rx_fifo();
 		unsigned int remaining = MAX_PACKET_LEN - _spirit_rx_pos;
 		if(fifo_available > remaining) {
@@ -517,6 +525,10 @@
 
 	/* The IRQ_RX_DATA_READY notifies a new packet arrived */
 	if(x_irq_status.IRQ_RX_DATA_READY) {
+#ifdef DEBUG_IRQ
+		uint32_t *tmp = (uint32_t*)&x_irq_status;
+		debug_if(!((*tmp) & IRQ_RX_DATA_READY_MASK), "\n\rAssert failed in: %s (%d)", __func__, __LINE__);
+#endif
 		_is_receiving = false; // Finished receiving
 		stop_rx_timeout();
 
@@ -547,6 +559,10 @@
 
 	/* The IRQ_VALID_SYNC is used to notify a new packet is coming */
 	if(x_irq_status.IRQ_VALID_SYNC) {
+#ifdef DEBUG_IRQ
+		uint32_t *tmp = (uint32_t*)&x_irq_status;
+		debug_if(!((*tmp) & IRQ_VALID_SYNC_MASK), "\n\rAssert failed in: %s (%d)", __func__, __LINE__);
+#endif
 		/* 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.
--- a/source/libs/spirit1/SPIRIT1_Library/Inc/SPIRIT_Irq.h	Wed Nov 30 11:58:18 2016 +0100
+++ b/source/libs/spirit1/SPIRIT1_Library/Inc/SPIRIT_Irq.h	Fri Dec 02 10:51:18 2016 +0100
@@ -179,7 +179,7 @@
 	  SpiritFlagStatus  IRQ_RX_START_TIME:1;            /*!< IRQ: only for debug; RX circuitry startup time; see TX_START_COUNTER */
 	  SpiritFlagStatus  IRQ_RX_TIMEOUT:1;               /*!< IRQ: RX operation timeout */
 	  SpiritFlagStatus  IRQ_AES_END:1;                  /*!< IRQ: AES End of operation */
-	  SpiritFlagStatus  :1;                             /*!< Reserved bit */
+	  SpiritFlagStatus  reserved:1;                     /*!< Reserved bit */
 
 	  SpiritFlagStatus  IRQ_READY:1;                    /*!< IRQ: READY state */
 	  SpiritFlagStatus  IRQ_STANDBY_DELAYED:1;          /*!< IRQ: STANDBY state after MCU_CK_CONF_CLOCK_TAIL_X clock cycles */
@@ -210,6 +210,14 @@
 
 } SpiritIrqs;
 
+// betzw: uint32_t masks
+#define IRQ_RX_FIFO_ALMOST_FULL_MASK	(0x00040000) /* (1<<17) */
+#define IRQ_VALID_SYNC_MASK				(0x00200000) /* (1<<21) */
+#define IRQ_RX_DATA_READY_MASK			(0x01000000) /* (1<<24) */
+#define IRQ_RX_DATA_DISC_MASK			(0x02000000) /* (1<<25) */
+#define IRQ_TX_DATA_SENT_MASK			(0x04000000) /* (1<<26) */
+#define IRQ_TX_FIFO_ERROR_MASK			(0x20000000) /* (1<<29) */
+#define IRQ_RX_FIFO_ERROR_MASK			(0x40000000) /* (1<<30) */
 
 /**
  * @brief  IRQ list enumeration for SPIRIT. This enumeration type can be used to address a