Example Program for EVAL-AD7606

Dependencies:   platform_drivers

Revision:
3:83b3133f544a
Parent:
1:819ac9aa5667
Child:
6:32de160dce43
--- a/app/ad7606_data_capture.c	Mon Oct 05 09:39:06 2020 +0000
+++ b/app/ad7606_data_capture.c	Fri Oct 16 21:37:35 2020 +0530
@@ -37,6 +37,13 @@
 /* Max size of the acquisition buffer (in terms of samples) */
 #define DATA_BUFFER_SIZE		(8192)
 
+/* Timeout count to avoid stuck into potential infinite loop while checking
+ * for new data into an acquisition buffer. The actual timeout factor is determined
+ * through 'sampling_frequency' attribute, but this period here makes sure
+ * we are not stuck into a loop forever, in case data capture interrupted
+ * or failed in between */
+#define BUF_READ_TIMEOUT	(5000000)
+
 /******************************************************************************/
 /********************** Variables and User Defined Data Types *****************/
 /******************************************************************************/
@@ -189,7 +196,7 @@
 				      size_t samples_to_read)
 {
 	int32_t buff_rd_wr_indx_offset; 			// Offset b/w buffer read and write indexes
-	uint32_t timeout = 5000000; 				// To avoid IIO data request timeout
+	uint32_t timeout = BUF_READ_TIMEOUT;  		// Buffer new data read timeout count
 	size_t bytes = samples_to_read * BYTES_PER_SAMPLE;
 
 	/* Copy the bytes into buffer provided there is enough offset b/w read and write counts.