IRPyro API unit test console
Functions for single and multiple sensor configurations in a Unit test format
IRPyro_UT_HL.c
Go to the documentation of this file.
1 /**
2 ******************************************************************************
3 * @file IRPyro_UT_HL.c
4 * @author _KEMET, Ltd
5 * @date March 2018
6 * @version Release 1.0.6
7 * @copyright (c) 2018 _KEMET, Ltd
8 * @brief High Level Unit Testing module
9 ******************************************************************************
10  @attention <h2><center>&copy; COPYRIGHT 2018 _KEMET, Ltd</center></h2>
11 
12  @verbatim
13  Copyright (c) 2018, _KEMET, Ltd
14  All rights reserved.
15 
16  THIS SOFTWARE IS PROVIDED BY _KEMET, Ltd ''AS IS'' AND ANY
17  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  DISCLAIMED. IN NO EVENT SHALL _KEMET, Ltd BE LIABLE FOR ANY
20  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  @endverbatim
27 ******************************************************************************
28 */
29 /* Includes ------------------------------------------------------------------*/
30 #include "IRPyro_UT.h"
31 void test01(void);
32 void test02(void);
33 void test03(void);
34 void test04(void);
35 void test05(void);
36 void test06(void);
37 void test07(void);
38 void test08(void);
39 void test09(void);
40 void test10(void);
41 void test11(void);
42 void test12(void);
43 void test13(void);
44 void test14(void);
45 void test15(void);
46 void test16(void);
47 /** @defgroup IRPyroAPI_UnitTest_HL High level unit test module
48  * @brief Configure the IRPyro sensors to test and calls the functions defined in IRPyroUT.c
49  * @{
50  */
51 /** @defgroup UT_01_IRPyro Main function
52  * @brief Calls the product verification plan units
53  * Each function validates a point of the product verification plan
54  * @note Refer to PSVP017 (product verification specification) document on the engineering section.
55  * @{
56  */
57 /**
58  * @brief unit testing main program.
59  */
60 int main()
61 {
62  /*-------------------------- board setup ---------------------------------*/
63  Micro_controller_template_init();
64  // turn off all CS lines
66  /*-------------------------- start test ----------------------------------*/
67  /*Single Sensor Test */
68 // test01(); // 01 Initialize a single device for INTERRUPT CONFIGURATION
69 // test02(); // 02 Initialize a single device for POLLED CONFIGURATION
70 // test03(); // 03 Initialize a single device for DAISY CHAIN CONFIGURATION
71 // test07(); // 07 READ DATA FROM A SINGLE SENSOR and detect frames missing with the sensor CONFIGURED FOR INTERRUPT. <<---------- single sensor performance test
72 // test08(); // 08 READ DATA FROM A SINGLE SENSOR and detect frames missing with the sensor CONFIGURED FOR POLLED
73 // ==== test09(); // 09 READ DATA FROM A SINGLE SENSOR and detect frames missing with the sensor CONFIGURED FOR DAISY CHAIN
74 // test14(); // 14 Change sensor POWER CONFIGURATION
75 // test15(); // 15 Configure sensor WAKE UP EVENT, SEND TO SLEEP, DETECT WAKE UP
76 // test16(); // 16 Change PARAMETERS on the fly
77 
78  /*Multiple Sensor Test */
79 // test04(); // 04 Initialize multiple devices for INTERRUPT CONFIGURATION
80 // test05(); // 05 Initialize multiple devices for POLLED CONFIGURATION
81 // test06(); // 06 Initialize multiple devices for DAISY CHAIN CONFIGURATION
82 // test10(); // 10 READ DATA FROM MULTIPLE SENSORS and detect frames missing with the sensors CONFIGURED FOR INTERRUPT. <<---------- multiple sensor performance test
83 // test11(); // 11 READ DATA FROM MULTIPLE SENSORS and detect frames missing with the sensors CONFIGURED FOR POLLED
84 // test12(); // 12 READ DATA FROM MULTIPLE SENSORS and detect frames missing with the sensors CONFIGURED FOR DAISY CHAIN
85 }
86 /** end of main program
87  * @}
88  */
89 /** @defgroup ver_plan Verification plan functions
90  * @brief each function configures the required data structures to pass to the
91  * unit test functions
92  * @{
93  */
94 /**
95  * @brief Data structure for single device with INTERRUPT enabled is defined, sent to the IRPyro sensor and then read back again.
96  */
97 void test01(void)
98 {
99  /*------------------ Memory allocation, initialization-------------------*/
100  IRPyro_sensor_device_type IRPyro_single_sensor = {0}; // Instance of sensor
101  /*-------------------Physical Location ----------------------------------*/
102  IRPyro_single_sensor.INT_Port = 1;
103  IRPyro_single_sensor.CS_Port = 2;
104  IRPyro_single_sensor.CS_Pin = 1;
105  IRPyro_single_sensor.INT_Pin = 4;
106  /*-------------------Test configuration ---------------------------------*/
107  IRPyro_single_sensor.read_mode = 0; // INTERRUPT CONFIGURATION
108  IRPyro_single_sensor.address = 0x08; // I2C address to configure
109  IRPyro_single_sensor.number_of_active_channels = 1; // configures channel 2 for streaming
110  /*-------------------------- board setup ---------------------------------*/
112  UART_PutString(USART2, (uint8_t*)"01 Initialize a single device for INTERRUPT CONFIGURATION \n\n");
113  ut01_single_sensor_init(&IRPyro_single_sensor);
114 }
115 /**
116  * @brief Data structure for single device with POLLED CONFIGURATION enabled is defined, sent to the IRPyro sensor and then read back again.
117  */
118 void test02(void)
119 {
120  /*------------------ Memory allocation, initialization-------------------*/
121  IRPyro_sensor_device_type IRPyro_single_sensor = {0}; // Instance of sensor
122  /*-------------------Physical Location ----------------------------------*/
123  IRPyro_single_sensor.INT_Port = 1;
124  IRPyro_single_sensor.CS_Port = 2;
125  IRPyro_single_sensor.CS_Pin = 1;
126  IRPyro_single_sensor.INT_Pin = 4;
127  /*-------------------Test configuration ---------------------------------*/
128  IRPyro_single_sensor.read_mode = 1; // POLLED CONFIGURATION
129  IRPyro_single_sensor.address = 0x08; // I2C address to configure
130  IRPyro_single_sensor.number_of_active_channels = 1; // configures channel 2 for streaming
131  /*-------------------------- board setup ---------------------------------*/
133  UART_PutString(USART2, (uint8_t*)"02 Initialize a single device for POLLED CONFIGURATION \n");
134  ut01_single_sensor_init(&IRPyro_single_sensor);
135 }
136 /**
137  * @brief Data structure for single device with DAISY CHAIN CONFIGURATION enabled is defined, sent to the IRPyro sensor and then read back again.
138  */
139 void test03(void)
140 {
141  /*------------------ Memory allocation, initialization-------------------*/
142  IRPyro_sensor_device_type IRPyro_single_sensor = {0}; // Instance of sensor
143  /*-------------------Physical Location ----------------------------------*/
144  IRPyro_single_sensor.INT_Port = 1;
145  IRPyro_single_sensor.CS_Port = 2;
146  IRPyro_single_sensor.CS_Pin = 1;
147  IRPyro_single_sensor.INT_Pin = 4;
148  /*-------------------Test configuration ---------------------------------*/
149  IRPyro_single_sensor.read_mode = 2; // DAISY CHAIN CONFIGURATION
150  IRPyro_single_sensor.address = 0x08; // I2C address to configure
151  IRPyro_single_sensor.number_of_active_channels = 1; // configures channel 2 for streaming
152  /*-------------------------- board setup ---------------------------------*/
154  UART_PutString(USART2, (uint8_t*)"03 Initialize a single device for DAISY CHAIN CONFIGURATION \n");
155  ut01_single_sensor_init(&IRPyro_single_sensor);
156 }
157 /**
158  * @brief A list of IRPyro devices is declared, all the devices interrupt enabled. The data structure is sent to the physical sensors, and then read back again.
159  */
160 void test04(void)
161 {
162  /*------------------- Memory allocation, initialization ------------------*/
163  IRPyro_devices IRPyro_device = {0};
164  /*----------------------- --- CONFIGURATION ----- -----------------------*/
165  AFE_reg_type IRPyro_AFE_configuration =
166  {
167  .CLK_OUT = CLK_DISABLE,
168  .INT = INT_ENABLE
169  };
170  /*----------------- ADDRESSES ------------*/
171  /* Assuming four sensors on an IRPyro Break out board or demo board*/
172  IRPyro_device[0].INT_Port = 1;
173  IRPyro_device[0].CS_Port = 2;
174  IRPyro_device[0].CS_Pin = 1;
175  IRPyro_device[0].INT_Pin = 4;
176  IRPyro_device[0].address = 0x70;
177 
178  IRPyro_device[1].CS_Port = 2;
179  IRPyro_device[1].INT_Port = 1;
180  IRPyro_device[1].CS_Pin = 5;
181  IRPyro_device[1].INT_Pin = 5;
182  IRPyro_device[1].address = 0x69;
183 
184  IRPyro_device[2].CS_Port = 2;
185  IRPyro_device[2].INT_Port = 1;
186  IRPyro_device[2].CS_Pin = 4;
187  IRPyro_device[2].INT_Pin = 6;
188  IRPyro_device[2].address = 0x68;
189 
190  IRPyro_device[3].CS_Port = 2;
191  IRPyro_device[3].INT_Port = 1;
192  IRPyro_device[3].CS_Pin = 3;
193  IRPyro_device[3].INT_Pin = 7;
194  IRPyro_device[3].address = 0x67;
195 
196  /*----------------- CONFIGURATION ------------*/
197  IRPyro_device[0].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
198  IRPyro_device[0].read_mode = 0;
199  IRPyro_device[0].number_of_active_channels = 1; // configures channel 2 for streaming
200  IRPyro_device[1].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
201  IRPyro_device[1].read_mode = 0;
202  IRPyro_device[1].number_of_active_channels = 1; // configures channel 2 for streaming
203  IRPyro_device[2].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
204  IRPyro_device[2].read_mode = 0;
205  IRPyro_device[2].number_of_active_channels = 1; // configures channel 2 for streaming
206  IRPyro_device[3].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
207  IRPyro_device[3].read_mode = 0;
208  IRPyro_device[3].number_of_active_channels = 1; // configures channel 2 for streaming
210  UART_PutString(USART2, (uint8_t*)"04 Initialize multiple devices for INTERRUPT CONFIGURATION\n");
211  ut02_multiple_sensor_init(IRPyro_device, 4);
212 }
213 /**
214  * @brief A list of IRPyro devices is declared, all the devices with the interrupt disabled. The data structure is sent to the physical sensors, and then read back again.
215  */
216 void test05(void)
217 {
218  /*------------------- Memory allocation, initialization ------------------*/
219  IRPyro_devices IRPyro_device = {0};
220  /*----------------------- --- CONFIGURATION ----- -----------------------*/
221  AFE_reg_type IRPyro_AFE_configuration =
222  {
223  .CLK_OUT = CLK_DISABLE,
224  .INT = INT_DISABLE
225  };
226  /*----------------- ADDRESSES ------------*/
227  /* Assuming four sensors on an IRPyro Break out board or demo board*/
228  IRPyro_device[0].INT_Port = 1;
229  IRPyro_device[0].CS_Port = 2;
230  IRPyro_device[0].CS_Pin = 1;
231  IRPyro_device[0].INT_Pin = 4;
232  IRPyro_device[0].address = 0x70;
233 
234  IRPyro_device[1].CS_Port = 2;
235  IRPyro_device[1].INT_Port = 1;
236  IRPyro_device[1].CS_Pin = 5;
237  IRPyro_device[1].INT_Pin = 5;
238  IRPyro_device[1].address = 0x69;
239 
240  IRPyro_device[2].CS_Port = 2;
241  IRPyro_device[2].INT_Port = 1;
242  IRPyro_device[2].CS_Pin = 4;
243  IRPyro_device[2].INT_Pin = 6;
244  IRPyro_device[2].address = 0x68;
245 
246  IRPyro_device[3].CS_Port = 2;
247  IRPyro_device[3].INT_Port = 1;
248  IRPyro_device[3].CS_Pin = 3;
249  IRPyro_device[3].INT_Pin = 7;
250  IRPyro_device[3].address = 0x67;
251 
252  /*----------------- CONFIGURATION ------------*/
253  IRPyro_device[0].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
254  IRPyro_device[0].read_mode = 1;
255  IRPyro_device[0].number_of_active_channels = 1; // configures channel 2 for streaming
256  IRPyro_device[1].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
257  IRPyro_device[1].read_mode = 1;
258  IRPyro_device[1].number_of_active_channels = 1; // configures channel 2 for streaming
259  IRPyro_device[2].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
260  IRPyro_device[2].read_mode = 1;
261  IRPyro_device[2].number_of_active_channels = 1; // configures channel 2 for streaming
262  IRPyro_device[3].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
263  IRPyro_device[3].read_mode = 1;
264  IRPyro_device[3].number_of_active_channels = 1; // configures channel 2 for streaming
266  UART_PutString(USART2, (uint8_t*)"05 Initialize multiple devices for POLLED CONFIGURATION \n");
267  ut02_multiple_sensor_init(IRPyro_device, 4);
268 }
269 /**
270  * @brief A list of IRPyro devices is declared, all the devices are defined with
271 the SYNC bit enabled. The data structure is sent to the physical sensors, and
272 then read back again.
273  */
274 void test06(void)
275 {
276  /*------------------- Memory allocation, initialization ------------------*/
277  IRPyro_devices IRPyro_device = {0};
278  /*----------------------- --- CONFIGURATION ----- -----------------------*/
279  AFE_reg_type IRPyro_AFE_configuration =
280  {
281  .CLK_OUT = CLK_DISABLE,
282  .INT = INT_ENABLE
283  };
284  /*----------------- ADDRESSES ------------*/
285  /* Assuming four sensors on an IRPyro Break out board or demo board*/
286  IRPyro_device[0].INT_Port = 1;
287  IRPyro_device[0].CS_Port = 2;
288  IRPyro_device[0].CS_Pin = 1;
289  IRPyro_device[0].INT_Pin = 4;
290  IRPyro_device[0].address = 0x70;
291 
292  IRPyro_device[1].CS_Port = 2;
293  IRPyro_device[1].INT_Port = 1;
294  IRPyro_device[1].CS_Pin = 5;
295  IRPyro_device[1].INT_Pin = 5;
296  IRPyro_device[1].address = 0x69;
297 
298  IRPyro_device[2].CS_Port = 2;
299  IRPyro_device[2].INT_Port = 1;
300  IRPyro_device[2].CS_Pin = 4;
301  IRPyro_device[2].INT_Pin = 6;
302  IRPyro_device[2].address = 0x68;
303 
304  IRPyro_device[3].CS_Port = 2;
305  IRPyro_device[3].INT_Port = 1;
306  IRPyro_device[3].CS_Pin = 3;
307  IRPyro_device[3].INT_Pin = 7;
308  IRPyro_device[3].address = 0x67;
309 
310  /*----------------- CONFIGURATION ------------*/
311  IRPyro_device[0].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
312  IRPyro_device[0].read_mode = 2;
313  IRPyro_device[0].number_of_active_channels = 1; // configures channel 2 for streaming
314  IRPyro_device[1].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
315  IRPyro_device[1].read_mode = 2;
316  IRPyro_device[1].number_of_active_channels = 1; // configures channel 2 for streaming
317  IRPyro_device[2].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
318  IRPyro_device[2].read_mode = 2;
319  IRPyro_device[2].number_of_active_channels = 1; // configures channel 2 for streaming
320  IRPyro_device[3].AFE_register = IRPyro_AFE_configuration; // MASTER, INT, CLK DISABLED
321  IRPyro_device[3].read_mode = 2;
322  IRPyro_device[3].number_of_active_channels = 1; // configures channel 2 for streaming
324  UART_PutString(USART2, (uint8_t*)"06 Initialize multiple devices for DAISY CHAIN CONFIGURATION\n");
325  ut02_multiple_sensor_init(IRPyro_device, 4);
326 }
327 /**
328  * @brief With the data structure defined in 9.1.1.1 an IRPyro sensor is configured.
329  * One hour of data is read from the sensor. Each frame counter received is compared
330  * with the previous. A missing frame is detected when both numbers are NOT CONSECUTIVE.
331  * This event is counted.
332  */
333 void test07(void)
334 {
335  /*------------------ Memory allocation, initialization-------------------*/
336  IRPyro_sensor_device_type IRPyro_single_sensor = {0}; // Instance of sensor
337  /*-------------------Physical Location ----------------------------------*/
338  IRPyro_single_sensor.INT_Port = 1;
339  IRPyro_single_sensor.CS_Port = 2;
340  IRPyro_single_sensor.CS_Pin = 1;
341  IRPyro_single_sensor.INT_Pin = 4;
342  /*-------------------Test configuration ---------------------------------*/
343  IRPyro_single_sensor.read_mode = 1; // Polled mode reading
344  IRPyro_single_sensor.address = 0x08; // I2C address to configure
345  IRPyro_single_sensor.number_of_active_channels = 4; // configures channel 2 for streaming
346  /*-------------------------- board setup ---------------------------------*/
348  UART_PutString(USART2, (uint8_t*)"07 READ DATA FROM A SINGLE SENSOR and detect frames missing with the sensor CONFIGURED FOR INTERRUPT.\n");
349  ut03_single_sensor_read(&IRPyro_single_sensor);
350 }
351 /**
352  * @brief With the data structure defined in 9.1.1.2 an IRPyro sensor is configured.
353  * One hour of data is read from the sensor. Each frame counter received is compared
354  * with the previous. A missing frame is detected when both numbers are NOT CONSECUTIVE.
355  * This event is counted.
356  */
357 void test08(void)
358 {
359  /*------------------ Memory allocation, initialization-------------------*/
360  IRPyro_sensor_device_type IRPyro_single_sensor = {0}; // Instance of sensor
361  /*-------------------Physical Location ----------------------------------*/
362  IRPyro_single_sensor.INT_Port = 1;
363  IRPyro_single_sensor.CS_Port = 2;
364  IRPyro_single_sensor.CS_Pin = 1;
365  IRPyro_single_sensor.INT_Pin = 4;
366  /*-------------------Test configuration ---------------------------------*/
367  IRPyro_single_sensor.read_mode = 1; // Polled mode reading
368  IRPyro_single_sensor.address = 0x08; // I2C address to configure
369  IRPyro_single_sensor.number_of_active_channels = 1; // configures channel 2 for streaming
370  /*-------------------------- board setup ---------------------------------*/
372  UART_PutString(USART2, (uint8_t*)"08 READ DATA FROM A SINGLE SENSOR and detect frames missing with the sensor CONFIGURED FOR POLLED\n");
373  ut03_single_sensor_read(&IRPyro_single_sensor);
374 }
375 /**
376  * @brief With the data structure defined in 9.1.1.3 an IRPyro sensor is configured.
377  * One hour of data is read from the sensor. Each frame counter received is compared
378  * with the previous. A missing frame is detected when both numbers are NOT CONSECUTIVE.
379  * This event is counted.
380  */
381 void test09(void)
382 {
383  /*------------------- Memory allocation, initialization ------------------*/
384  IRPyro_devices IRPyro_device = {0};
385  /*----------------------- --- CONFIGURATION ----- -----------------------*/
386  AFE_reg_type IRPyro_AFE_configuration =
387  {
388  .CLK_OUT = CLK_ENABLE,
389  .INT = INT_ENABLE
390  };
391  AFE_reg_type IRPyro_AFE_Slave =
392  {
393  .SYNC = SLAVE,
394  };
395 
396  /*----------------- ADDRESSES ------------*/
397  /* Assuming four sensors on an IRPyro Break out board or demo board*/
398  IRPyro_device[0].INT_Port = 1;
399  IRPyro_device[0].CS_Port = 2;
400  IRPyro_device[0].CS_Pin = 1;
401  IRPyro_device[0].INT_Pin = 4;
402  IRPyro_device[0].address = 0x70;
403 
404  IRPyro_device[1].CS_Port = 2;
405  IRPyro_device[1].INT_Port = 1;
406  IRPyro_device[1].CS_Pin = 5;
407  IRPyro_device[1].INT_Pin = 5;
408  IRPyro_device[1].address = 0x69;
409  /*----------------- CONFIGURATION ------------*/
410  IRPyro_device[0].AFE_register = IRPyro_AFE_configuration; // MASTER
411  IRPyro_device[0].read_mode = 0;
412  IRPyro_device[0].number_of_active_channels = 1;
413  IRPyro_device[1].AFE_register = IRPyro_AFE_Slave; // SLAVE
414  IRPyro_device[1].read_mode = 2;
415  IRPyro_device[1].number_of_active_channels = 1;
416  /*-------------------------- board setup ---------------------------------*/
418  UART_PutString(USART2, (uint8_t*)"09 READ DATA FROM A SINGLE SENSOR and detect frames missing with the sensor CONFIGURED FOR DAISY CHAIN\n");
419  ut04_multiple_sensor_read(IRPyro_device, 2);
420 }
421 /**
422  * @brief With the data structure defined in 9.1.2.1 a four IRPyro sensors are
423  * configured. One hour of data is read from the sensors. Each frame counter received
424  * is compared with the previous. A missing frame is detected when both numbers are
425  * NOT CONSECUTIVE. This event is counted.
426  */
427 void test10(void)
428 {
429  /*------------------- Memory allocation, initialization ------------------*/
430  IRPyro_devices IRPyro_device = {0};
431  /*----------------------- --- CONFIGURATION ----- -----------------------*/
432  AFE_reg_type IRPyro_AFE_Master =
433  {
434  .S7_S0 = 0, // Sets the sampling rate to 1,000 samples per second.
435  .LP = LOW_POWER_DISABLE, // Low power sets the sampling rate to 166 samples per second.
436  .HP = HP_DISABLE, // High pass filter enabled
437  .C_LP = LOW_PASS_180, // Low pass filter set at 180Hz
438  .CLK_OUT = CLK_ENABLE, // Clock output enabled to synchronize other IRPyro sensors
439  .SYNC = MASTER, // IRPyro set as Master issues the synchronization to SLAVE
440  .TEMP = 0, //
441  .INT = INT_ENABLE // IRPyro indicates data ready enable
442  };
443  AFE_reg_type IRPyro_AFE_Slave =
444  {
445  .S7_S0 = 0, // Sets the sampling rate to 1,000 samples per second.
446  .LP = LOW_POWER_DISABLE, // Low power sets the sampling rate to 166 samples per second.
447  .HP = HP_DISABLE, // High pass filter enabled
448  .C_LP = LOW_PASS_180, // Low pass filter set at 180Hz
449  .CLK_OUT = CLK_DISABLE, // Clock output enabled to synchronize other IRPyro sensors
450  .SYNC = SLAVE, // IRPyro set as Slave receives the synchronization from MASTER
451  .TEMP = 0, //
452  .INT = INT_ENABLE // IRPyro indicates data ready enable
453  };
454  /*----------------- ADDRESSES ------------*/
455  /* Assuming four sensors on an IRPyro Break out board or demo board*/
456  IRPyro_device[0].INT_Port = 1;
457  IRPyro_device[0].CS_Port = 2;
458  IRPyro_device[0].CS_Pin = 1;
459  IRPyro_device[0].INT_Pin = 4;
460  IRPyro_device[0].address = 0x0A;
461 
462  IRPyro_device[1].CS_Port = 2;
463  IRPyro_device[1].INT_Port = 1;
464  IRPyro_device[1].CS_Pin = 5;
465  IRPyro_device[1].INT_Pin = 5;
466  IRPyro_device[1].address = 0x0B;
467 
468  IRPyro_device[2].CS_Port = 2;
469  IRPyro_device[2].INT_Port = 1;
470  IRPyro_device[2].CS_Pin = 4;
471  IRPyro_device[2].INT_Pin = 6;
472  IRPyro_device[2].address = 0x0C;
473 
474  IRPyro_device[3].CS_Port = 2;
475  IRPyro_device[3].INT_Port = 1;
476  IRPyro_device[3].CS_Pin = 3;
477  IRPyro_device[3].INT_Pin = 7;
478  IRPyro_device[3].address = 0x0D;
479 
480  /*----------------- CONFIGURATION ------------*/
481  IRPyro_device[0].AFE_register = IRPyro_AFE_Master; // MASTER, INT, CLK DISABLED
482  IRPyro_device[0].read_mode = 0;
483  IRPyro_device[0].number_of_active_channels = 1;
484 
485  IRPyro_device[1].AFE_register = IRPyro_AFE_Slave; // MASTER, INT, CLK DISABLED
486  IRPyro_device[1].read_mode = 0;
487  IRPyro_device[1].number_of_active_channels = 1;
488 
489  IRPyro_device[2].AFE_register = IRPyro_AFE_Slave; // MASTER, INT, CLK DISABLED
490  IRPyro_device[2].read_mode = 0;
491  IRPyro_device[2].number_of_active_channels = 1;
492 
493  IRPyro_device[3].AFE_register = IRPyro_AFE_Slave; // MASTER, INT, CLK DISABLED
494  IRPyro_device[3].read_mode = 0;
495  IRPyro_device[3].number_of_active_channels = 1;
496 
497  UART_PutString(USART2, (uint8_t*)"10 READ DATA FROM MULTIPLE SENSORS and detect frames missing with the sensors CONFIGURED FOR INTERRUPT\n");
499  ut04_multiple_sensor_read(IRPyro_device, 4);
500 
501 }
502 /**
503  * @brief With the data structure defined in 9.1.2.2 a four IRPyro sensors are
504 configured. One hour of data is read from the sensors. Each frame counter received
505 is compared with the previous. A missing frame is detected when both numbers are
506 NOT CONSECUTIVE. This event is counted.
507  */
508 void test11(void)
509 {
510 
511  /*------------------- Memory allocation, initialization ------------------*/
512  IRPyro_devices IRPyro_device = {0};
513  /*----------------------- --- CONFIGURATION ----- -----------------------*/
514  AFE_reg_type IRPyro_AFE_Master =
515  {
516  .S7_S0 = 0,
517  .LP = LOW_POWER_DISABLE,
518  .HP = HP_DISABLE,
519  .C_LP = LOW_PASS_180,
520  .CLK_OUT = CLK_ENABLE,
521  .SYNC = MASTER,
522  .TEMP = 0,
523  .INT = INT_DISABLE
524  };
525  AFE_reg_type IRPyro_AFE_Slave =
526  {
527  .S7_S0 = 0,
528  .LP = LOW_POWER_DISABLE,
529  .HP = HP_DISABLE,
530  .C_LP = LOW_PASS_180,
531  .CLK_OUT = CLK_DISABLE,
532  .SYNC = SLAVE,
533  .TEMP = 0,
534  .INT = INT_DISABLE
535  };
536  /*----------------- ADDRESSES ------------*/
537  /* Assuming four sensors on an IRPyro Break out board or demo board*/
538  IRPyro_device[0].INT_Port = 1;
539  IRPyro_device[0].CS_Port = 2;
540  IRPyro_device[0].CS_Pin = 1;
541  IRPyro_device[0].INT_Pin = 4;
542  IRPyro_device[0].address = 0x70;
543 
544  IRPyro_device[1].CS_Port = 2;
545  IRPyro_device[1].INT_Port = 1;
546  IRPyro_device[1].CS_Pin = 5;
547  IRPyro_device[1].INT_Pin = 5;
548  IRPyro_device[1].address = 0x69;
549 
550  IRPyro_device[2].CS_Port = 2;
551  IRPyro_device[2].INT_Port = 1;
552  IRPyro_device[2].CS_Pin = 4;
553  IRPyro_device[2].INT_Pin = 6;
554  IRPyro_device[2].address = 0x68;
555 
556  IRPyro_device[3].CS_Port = 2;
557  IRPyro_device[3].INT_Port = 1;
558  IRPyro_device[3].CS_Pin = 3;
559  IRPyro_device[3].INT_Pin = 7;
560  IRPyro_device[3].address = 0x67;
561 
562  /*----------------- CONFIGURATION ------------*/
563  IRPyro_device[0].AFE_register = IRPyro_AFE_Master; // MASTER, INT, CLK DISABLED
564  IRPyro_device[0].read_mode = 1;
565  IRPyro_device[0].number_of_active_channels = 1;
566 
567  IRPyro_device[1].AFE_register = IRPyro_AFE_Slave; // MASTER, INT, CLK DISABLED
568  IRPyro_device[1].read_mode = 1;
569  IRPyro_device[1].number_of_active_channels = 1;
570 
571  IRPyro_device[2].AFE_register = IRPyro_AFE_Slave; // MASTER, INT, CLK DISABLED
572  IRPyro_device[2].read_mode = 1;
573  IRPyro_device[2].number_of_active_channels = 1;
574 
575  IRPyro_device[3].AFE_register = IRPyro_AFE_Slave; // MASTER, INT, CLK DISABLED
576  IRPyro_device[3].read_mode = 1;
577  IRPyro_device[3].number_of_active_channels = 1;
578 
580  UART_PutString(USART2, (uint8_t*)"11 READ DATA FROM MULTIPLE SENSORS and detect frames missing with the sensors CONFIGURED FOR POLLED\n");
581  ut04_multiple_sensor_read(IRPyro_device, 4);
582 }
583 /**
584  * @brief With the data structure defined in 9.1.2.3 a four IRPyro sensors are
585 configured. One hour of data is read from the sensors. Each frame counter received
586 is compared with the previous. A missing frame is detected when both numbers are
587 NOT CONSECUTIVE. This event is counted.
588  */
589 void test12(void)
590 {
591 
592  /*------------------- Memory allocation, initialization ------------------*/
593  IRPyro_devices IRPyro_device = {0};
594  /*----------------------- --- CONFIGURATION ----- -----------------------*/
595  AFE_reg_type IRPyro_AFE_Master =
596  {
597  .S7_S0 = 0,
598  .LP = LOW_POWER_DISABLE,
599  .HP = HP_DISABLE,
600  .C_LP = LOW_PASS_180,
601  .CLK_OUT = CLK_ENABLE,
602  .SYNC = MASTER,
603  .TEMP = 0,
604  .INT = INT_ENABLE
605  };
606  AFE_reg_type IRPyro_AFE_Slave =
607  {
608  .S7_S0 = 0,
609  .LP = LOW_POWER_DISABLE,
610  .HP = HP_DISABLE,
611  .C_LP = LOW_PASS_180,
612  .CLK_OUT = CLK_DISABLE,
613  .SYNC = SLAVE,
614  .TEMP = 0,
615  .INT = INT_ENABLE
616  };
617  /*----------------- ADDRESSES ------------*/
618  /* Assuming four sensors on an IRPyro Break out board or demo board*/
619  IRPyro_device[0].INT_Port = 1;
620  IRPyro_device[0].CS_Port = 2;
621  IRPyro_device[0].CS_Pin = 1;
622  IRPyro_device[0].INT_Pin = 4;
623  IRPyro_device[0].address = 0x70;
624 
625  IRPyro_device[1].CS_Port = 2;
626  IRPyro_device[1].INT_Port = 1;
627  IRPyro_device[1].CS_Pin = 5;
628  IRPyro_device[1].INT_Pin = 5;
629  IRPyro_device[1].address = 0x69;
630 
631  IRPyro_device[2].CS_Port = 2;
632  IRPyro_device[2].INT_Port = 1;
633  IRPyro_device[2].CS_Pin = 4;
634  IRPyro_device[2].INT_Pin = 6;
635  IRPyro_device[2].address = 0x68;
636 
637  IRPyro_device[3].CS_Port = 2;
638  IRPyro_device[3].INT_Port = 1;
639  IRPyro_device[3].CS_Pin = 3;
640  IRPyro_device[3].INT_Pin = 7;
641  IRPyro_device[3].address = 0x67;
642 
643  /*----------------- CONFIGURATION ------------*/
644  IRPyro_device[0].AFE_register = IRPyro_AFE_Master; // MASTER, INT, CLK DISABLED
645  IRPyro_device[0].read_mode = 0;
646  IRPyro_device[0].number_of_active_channels = 1;
647 
648  IRPyro_device[1].AFE_register = IRPyro_AFE_Slave; // MASTER, INT, CLK DISABLED
649  IRPyro_device[1].read_mode = 0;
650  IRPyro_device[1].number_of_active_channels = 1;
651 
652  IRPyro_device[2].AFE_register = IRPyro_AFE_Slave; // MASTER, INT, CLK DISABLED
653  IRPyro_device[2].read_mode = 0;
654  IRPyro_device[2].number_of_active_channels = 1;
655 
656  IRPyro_device[3].AFE_register = IRPyro_AFE_Slave; // MASTER, INT, CLK DISABLED
657  IRPyro_device[3].read_mode = 0;
658  IRPyro_device[3].number_of_active_channels = 1;
659 
661  UART_PutString(USART2, (uint8_t*)"12 READ DATA FROM MULTIPLE SENSORS and detect frames missing with the sensors CONFIGURED FOR DAISY CHAIN\n");
662  ut04_multiple_sensor_read(IRPyro_device, 4);
663 }
664 /**
665  * @brief With the data structure defined in 9.1.1.1 an IRPyro sensor is configured.
666 The following API commands are issued: sampling_rate_set, sampling_rate_get, high_pass_set,
667 high_pass_get, low_pass_set, low_pass_get, gain_set, and gain_get, power_off.
668 A sample of readings is taken and the behaviour of the sensor is observed.
669  */
670 void test14(void)
671 {
672  /*------------------ Memory allocation, initialization-------------------*/
673  IRPyro_sensor_device_type IRPyro_single_sensor = {0}; // Instance of sensor
674  /*-------------------Physical Location ----------------------------------*/
675  IRPyro_single_sensor.INT_Port = 1;
676  IRPyro_single_sensor.CS_Port = 2;
677  IRPyro_single_sensor.CS_Pin = 1;
678  IRPyro_single_sensor.INT_Pin = 4;
679  /*-------------------Test configuration ---------------------------------*/
680  IRPyro_single_sensor.read_mode = 2; // DAISY CHAIN CONFIGURATION
681  IRPyro_single_sensor.address = 0x08; // I2C address to configure
682  IRPyro_single_sensor.number_of_active_channels = 1; // configures channel 2 for streaming
683  /*-------------------------- board setup ---------------------------------*/
685  UART_PutString(USART2, (uint8_t*)"14 Change sensor POWER CONFIGURATION\n");
686  ut06_IOCTL02(&IRPyro_single_sensor);
687 }
688 /**
689  * @brief With the data structure defined in 9.1.1.1 an IRPyro sensor is configured.
690 The following API commands are issued: power_sleep, and power_wakeup. A sample of
691 readings is taken and the behavior of the sensor is observed.
692  */
693 void test15(void)
694 {
695 // wake command response
696  /* the sensor is configured to sleep and on a wake up event alerts the MCU and
697  data is read a more elaborate scenario is putting the MCU to sleep and the
698  sensor wakes the device up */
699  /*------------------ Memory allocation, initialization-------------------*/
700  IRPyro_sensor_device_type IRPyro_single_sensor = {0}; // Instance of sensor
701  /*-------------------Physical Location ----------------------------------*/
702  IRPyro_single_sensor.INT_Port = 1;
703  IRPyro_single_sensor.CS_Port = 2;
704  IRPyro_single_sensor.CS_Pin = 1;
705  IRPyro_single_sensor.INT_Pin = 4;
706  /*-------------------Test configuration ---------------------------------*/
707  IRPyro_single_sensor.read_mode = 2; // DAISY CHAIN CONFIGURATION
708  IRPyro_single_sensor.address = 0x70; // I2C address to configure
709  IRPyro_single_sensor.number_of_active_channels = 1; // configures channel 2 for streaming
710  /*------------------- Wake up event definition -------------------------*/
711  IRPyro_single_sensor.WUP_register.UHT = MAX_WUP_THRESHOLD;
712  IRPyro_single_sensor.WUP_register.ULT = SAFE_WUP_THRESHOLD;
713  IRPyro_single_sensor.WUP_register.LHT = MIN_WUP_THRESHOLD;
714  IRPyro_single_sensor.WUP_register.LLT = MIN_WUP_THRESHOLD;
715  IRPyro_single_sensor.WUP_register.WT_Threshold = DEFAULT_NO_EVENTS;
716  IRPyro_single_sensor.WUP_register.DP0_DP2 = SEL_CH_2;
717  IRPyro_single_sensor.WUP_register.CH0_CH2 = SEL_CH_2;
718  IRPyro_single_sensor.WUP_register.ST = SLEEP_MODE_ONE_CH; // Single channel selected
719  /*-------------------------- board setup --------------------------------*/
721  UART_PutString(USART2, (uint8_t*)"15 Configure sensor WAKE UP EVENT, SEND TO SLEEP, DETECT WAKE UP \n");
722  ut_wake_up_event(&IRPyro_single_sensor);
723 }
724 /**
725  * @brief With the data structure defined in 9.1.1.1 an IRPyro sensor is configured.
726 The following API commands are issued: power_off, power_normal, and power_low. A
727 sample of readings is taken and the behavior of the sensor is observed.
728  */
729 void test16(void)
730 {
731  /*------------------ Memory allocation, initialization-------------------*/
732  IRPyro_sensor_device_type IRPyro_single_sensor = {0}; // Instance of sensor
733  /*-------------------Physical Location ----------------------------------*/
734  IRPyro_single_sensor.INT_Port = 1;
735  IRPyro_single_sensor.CS_Port = 2;
736  IRPyro_single_sensor.CS_Pin = 1;
737  IRPyro_single_sensor.INT_Pin = 4;
738  /*-------------------Test configuration ---------------------------------*/
739  IRPyro_single_sensor.read_mode = 2; // DAISY CHAIN CONFIGURATION
740  IRPyro_single_sensor.address = 0x08; // I2C address to configure
741  IRPyro_single_sensor.number_of_active_channels = 1; // configures channel 2 for streaming
742  /*-------------------------- board setup ---------------------------------*/
744  UART_PutString(USART2, (uint8_t*)"16 Change PARAMETERS on the fly\n");
745  ut06_IOCTL01(&IRPyro_single_sensor);
746 }
747 /** end of Verification plan functions
748  * @}
749  */
750 /** end of High Level Unit Test module
751  * @}
752  */
753 /* ********** Copyright (c) 2018 _KEMET, Ltd. **********END OF FILE************/
uint8_t ut02_multiple_sensor_init(IRPyro_devices this_list, uint8_t list_size)
Definition: IRPyro_UT.c:121
Unit Testing module.
void test10(void)
With the data structure defined in 9.1.2.1 a four IRPyro sensors are configured. One hour of data is ...
Definition: IRPyro_UT_HL.c:427
void test12(void)
With the data structure defined in 9.1.2.3 a four IRPyro sensors are configured. One hour of data is ...
Definition: IRPyro_UT_HL.c:589
uint8_t ut03_single_sensor_read(IRPyro_sensor_device_type *IRPyro_test_Sensor)
Definition: IRPyro_UT.c:165
uint8_t ut01_single_sensor_init(IRPyro_sensor_device_type *IRPyro_test_Sensor)
Definition: IRPyro_UT.c:65
uint8_t ut_wake_up_event(IRPyro_sensor_device_type *IRPyro_test_Sensor)
Wake up event.
Definition: IRPyro_UT.c:336
void IRPyro_demo_board(uint8_t value)
Changes the state of all the CS lines as used on the IRPyro backplane board.
Definition: IRPyro_UT.c:619
uint8_t ut06_IOCTL02(IRPyro_sensor_device_type *IRPyro_test_Sensor)
Definition: IRPyro_UT.c:417
void test06(void)
A list of IRPyro devices is declared, all the devices are defined with the SYNC bit enabled...
Definition: IRPyro_UT_HL.c:274
void test04(void)
A list of IRPyro devices is declared, all the devices interrupt enabled. The data structure is sent t...
Definition: IRPyro_UT_HL.c:160
void test09(void)
With the data structure defined in 9.1.1.3 an IRPyro sensor is configured. One hour of data is read f...
Definition: IRPyro_UT_HL.c:381
void test11(void)
With the data structure defined in 9.1.2.2 a four IRPyro sensors are configured. One hour of data is ...
Definition: IRPyro_UT_HL.c:508
void test01(void)
Data structure for single device with INTERRUPT enabled is defined, sent to the IRPyro sensor and the...
Definition: IRPyro_UT_HL.c:97
void test14(void)
With the data structure defined in 9.1.1.1 an IRPyro sensor is configured. The following API commands...
Definition: IRPyro_UT_HL.c:670
uint8_t ut06_IOCTL01(IRPyro_sensor_device_type *IRPyro_test_Sensor)
Test of IOCTL functions.
Definition: IRPyro_UT.c:269
int main()
unit testing main program.
Definition: IRPyro_UT_HL.c:60
void test16(void)
With the data structure defined in 9.1.1.1 an IRPyro sensor is configured. The following API commands...
Definition: IRPyro_UT_HL.c:729
void test02(void)
Data structure for single device with POLLED CONFIGURATION enabled is defined, sent to the IRPyro sen...
Definition: IRPyro_UT_HL.c:118
void test15(void)
With the data structure defined in 9.1.1.1 an IRPyro sensor is configured. The following API commands...
Definition: IRPyro_UT_HL.c:693
void test05(void)
A list of IRPyro devices is declared, all the devices with the interrupt disabled. The data structure is sent to the physical sensors, and then read back again.
Definition: IRPyro_UT_HL.c:216
void test13(void)
void test08(void)
With the data structure defined in 9.1.1.2 an IRPyro sensor is configured. One hour of data is read f...
Definition: IRPyro_UT_HL.c:357
void test03(void)
Data structure for single device with DAISY CHAIN CONFIGURATION enabled is defined, sent to the IRPyro sensor and then read back again.
Definition: IRPyro_UT_HL.c:139
void test07(void)
With the data structure defined in 9.1.1.1 an IRPyro sensor is configured. One hour of data is read f...
Definition: IRPyro_UT_HL.c:333
uint8_t ut04_multiple_sensor_read(IRPyro_devices this_list, uint8_t list_size)
Definition: IRPyro_UT.c:211