IRPyro API  (sKEMLIB1)
Collection of routines and data structures covering the functionality of the IRPyro sensor
IRPyro_API_multi_device_layer.c
Go to the documentation of this file.
1 /**
2 ******************************************************************************
3 * @file IRPyro_API_multi_device_layer.c
4 * @author _KEMET Ltd.
5 * @date March 2018
6 * @version Release 1.0.6
7 * @copyright (c) 2018 _KEMET, Ltd
8 * @brief IRPyro Application interface functions implementation
9 *
10 * @verbatim
11  ===============================================================================
12  ##### How to use this driver #####
13  ===============================================================================
14  [..]
15  (#) Make sure that IRPyro_LIST_SIZE is big enough for your list
16  (#) Declare an IRPyro_list_type variable in your code
17  (#) Declare as many IRPyro_sensor_device_type variables as IRPyros sensors
18  on the list.
19  (#) Fill the values for CS, INT and address for each IRPyro
20  (#) Fill the values for number_of_active_channels and read_mode
21  (#) AFE, CCP and WUP can be left empty if desired, configuration macros
22  will fill them with default values
23  (#) Call IRPyro_open() to commit the values to the physical IRPyro
24  (#) IRPyro_read() retrieves the values sampled by the IRPyro sensor
25  (#) Modify the IRPyro settings using IRPyro_IOCTL()
26  (#) Close the device when finished using IRPyro_read()
27  @endverbatim
28 ******************************************************************************
29  @attention <h2><center>&copy; COPYRIGHT 2018 _KEMET, Ltd</center></h2>
30  @verbatim
31  Copyright (c) 2018, _KEMET, Ltd
32  All rights reserved.
33 
34  THIS SOFTWARE IS PROVIDED BY _KEMET, Ltd ''AS IS'' AND ANY
35  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37  DISCLAIMED. IN NO EVENT SHALL _KEMET, Ltd BE LIABLE FOR ANY
38  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
41  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44  @endverbatim
45 ******************************************************************************
46  */
47 
48 /* Includes ------------------------------------------------------------------*/
49 #include "Version.h"
52 /* Private functions ---------------------------------------------------------*/
53 /**
54  * @defgroup IRPyro_multi IRPyro multiple device layer
55  * @brief Extends the functionality of the basic IRPyro functions (Open, Close and Read) by applying them sequentially to a list of devicesLIST
56  * @ingroup IRPyro_API
57  * @{
58  */
59 /** @defgroup LIST_IRPyro Multiple device layer Initialization and Configuration functions
60  * @brief Manipulates a LIST of IRPyro devices
61  * @verbatim
62  ===============================================================================
63  ##### Initialization and Configuration functions #####
64  ===============================================================================
65  [..] This section provides a set of functions allowing to initialize a LIST
66  by taking individual IRPyro sensor and setting AFE, CCP and WUP
67  registers and I2C address.
68  @endverbatim
69  * @{
70  */
71 /**
72  * @defgroup IRPyro_list_type_functions IRPyro multi device functions
73  * @brief Extends Open, Read and Close to a group of IRPyro devices
74  * @{
75  */
76 /**
77  * @brief initializes a group of IRPyro sensors
78  * @param this_list pointer to the IRPyro list data structure
79  * @param list_size number of elements in the list
80  * @retval op_result 1 success / 0 error
81  */
82 uint8_t IRPyro_open_devices(IRPyro_devices this_list, uint8_t list_size)
83 {
84  uint8_t op_result = 0;
85  for(uint8_t idx=0; idx<list_size; ++idx)
86  {
87  op_result += IRPyro_open(&this_list[idx]);
88  }
89  return (op_result == list_size ? 1:0); // 1 success / 0 error
90 }
91 
92 /**
93  * @brief Collects data from the IRPyro group
94  * @param this_list pointer to the IRPyro data structure
95  * @param list_size number of elements in the list
96  * @retval op_result 1 success / 0 error
97  */
98 uint8_t IRPyro_read_devices(IRPyro_devices this_list, uint8_t list_size)
99 {
100  uint8_t op_result = 0;
101  for(uint8_t idx=0; idx<list_size; ++idx)
102  {
103  op_result += IRPyro_read(&this_list[idx]);
104  }
105  return (op_result == list_size ? 1:0); // 1 success / 0 error
106 }
107 
108 /**
109  * @brief Stops streaming, deallocates memory and disable the IRPyro sensor
110  * @param this_list pointer to the IRPyro data structure
111  * @param list_size number of elements in the list
112  * @retval None
113  */
114 uint8_t IRPyro_close_devices(IRPyro_devices this_list, uint8_t list_size)
115 {
116  uint8_t op_result = 0;
117  for(uint8_t idx=0; idx<list_size; ++idx)
118  {
119  op_result += IRPyro_close(&this_list[idx]);
120  }
121  return (op_result == list_size ? 1:0); // 1 success / 0 error
122 }
123 /**
124  * @brief access to IRPyro registers
125  * @param this_list pointer to the IRPyro data structure
126  * @param list_size number of elements in the list
127  * @param cmd pointer to command data structure
128  * @param arg argument data structure
129  * @retval 1 success / 0 fail
130  */
131 uint8_t IRPyro_ioctl_devices(IRPyro_devices this_list, uint8_t list_size, IRPyro_cmd_type* cmd, IRPyro_arg_type arg)
132 {
133  uint8_t op_result = 0;
134  for(uint8_t idx=0; idx<list_size; ++idx)
135  {
136  op_result += IRPyro_ioctl(&this_list[idx], cmd, arg);
137  }
138  return (op_result == list_size ? 1:0); // 1 success / 0 error
139 }
140 
141 /** end of IRPyro multi device functions
142  * @}
143  */
144 /** end Multiple device layer Initialization and Configuration functions
145  * @}
146  */
147 /** end IRPyro multiple device layer
148  * @}
149  */
150 /* ********** Copyright (c) 2018 _KEMET, Ltd. **********END OF FILE************/
uint8_t IRPyro_open_devices(IRPyro_devices this_list, uint8_t list_size)
initializes a group of IRPyro sensors
uint8_t IRPyro_ioctl_devices(IRPyro_devices this_list, uint8_t list_size, IRPyro_cmd_type *cmd, IRPyro_arg_type arg)
access to IRPyro registers
uint8_t IRPyro_open(IRPyro_sensor_device_type *this_device)
Initializes the IRPyro device.
IRPyro data structures and prototype functions
uint8_t IRPyro_ioctl(IRPyro_sensor_device_type *this_device, IRPyro_cmd_type *cmd, IRPyro_arg_type arg)
access to IRPyro registers
uint8_t IRPyro_read_devices(IRPyro_devices this_list, uint8_t list_size)
Collects data from the IRPyro group.
Product and component names and versions.
uint8_t IRPyro_read(IRPyro_sensor_device_type *this_device)
Reads a frame of data from the IRPyro.
uint8_t IRPyro_close(IRPyro_sensor_device_type *this_device)
Stops streaming, deallocates memory and disable the IRPyro sensor.
IRPyro group definition
IRPyro command argument
IRPyro data structures and prototype functions
uint8_t IRPyro_close_devices(IRPyro_devices this_list, uint8_t list_size)
Stops streaming, deallocates memory and disable the IRPyro sensor.