STIMA  3
i2c-opc-config.h
Go to the documentation of this file.
1 
3 /*********************************************************************
4 Copyright (C) 2017 Marco Baldinetti <m.baldinetti@digiteco.it>
5 authors:
6 Paolo patruno <p.patruno@iperbole.bologna.it>
7 Marco Baldinetti <m.baldinetti@digiteco.it>
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of
12 the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 **********************************************************************/
22 
23 #ifndef _I2C_OPC_CONFIG_H
24 #define _I2C_OPC_CONFIG_H
25 
26 #include <sensors_config.h>
27 
28 /*********************************************************************
29 * MODULE
30 *********************************************************************/
35 #define MODULE_VERSION (3)
36 
41 #define MODULE_TYPE (STIMA_MODULE_TYPE_OPC)
42 
43 /*********************************************************************
44 * CONFIGURATION
45 *********************************************************************/
50 #define CONFIGURATION_DEFAULT_IS_ONESHOT (false)
51 
56 #define CONFIGURATION_DEFAULT_IS_CONTINUOUS (true)
57 
62 #define CONFIGURATION_DEFAULT_I2C_ADDRESS (I2C_OPC_DEFAULT_ADDRESS)
63 
68 #define CONFIGURATION_RESET_PIN (8)
69 
74 #define OPC_POWER_PIN (9) // 8 per N2
75 
80 #define OPC_SPI_POWER_PIN (6)
81 
86 #define OPC_CHIP_SELECT (10)
87 #define SDCARD_CHIP_SELECT_PIN 7
92 
97 #define SPI_SPEED SD_SCK_MHZ(4)
98 
99 /*********************************************************************
100 * POWER DOWN
101 *********************************************************************/
106 #define USE_POWER_DOWN (true)
107 
112 #define DEBOUNCING_POWER_DOWN_TIME_MS (10)
113 
118 #define USE_TIMER_1 (true)
119 
124 #define USE_OPC_POWER_DOWN (false)
125 
126 /*********************************************************************
127 * WATCHDOG
128 *********************************************************************/
137 #define WDT_TIMER (WDTO_8S)
138 
139 /*********************************************************************
140 * OPC SENSORS
141 *********************************************************************/
142 // observations with processing every 1-10 minutes (minutes for processing sampling)
143 // report every 5-60 minutes (> OBSERVATIONS_MINUTES)
144 
149 #define SENSORS_SAMPLE_TIME_MS (10000)
150 
155 #define SENSORS_SAMPLE_COUNT_MIN ((uint8_t)(OBSERVATIONS_MINUTES * 60 / ((uint8_t)(SENSORS_SAMPLE_TIME_MS / 1000))))
156 
157 #if ((OBSERVATIONS_MINUTES * 60) % (SENSORS_SAMPLE_TIME_MS / 1000) == 0)
162 #define SENSORS_SAMPLE_COUNT_MAX (SENSORS_SAMPLE_COUNT_MIN)
163 #else
168 #define SENSORS_SAMPLE_COUNT_MAX (SENSORS_SAMPLE_COUNT_MIN + 1)
169 #endif
170 
175 #define SENSORS_SAMPLE_COUNT_TOLERANCE (4)
176 
181 #define USE_SENSORS_COUNT (USE_SENSOR_OA2 + USE_SENSOR_OB2 + USE_SENSOR_OC2 + USE_SENSOR_OD2 + USE_SENSOR_OA3 + USE_SENSOR_OB3 + USE_SENSOR_OC3 + USE_SENSOR_OD3 + USE_SENSOR_OE3)
182 
183 #if (USE_SENSORS_COUNT == 0)
184 #error No sensor used. Are you sure? If not, enable it in RmapConfig/sensors_config.h
185 #endif
186 
187 /*********************************************************************
188 * TIMER1
189 *********************************************************************/
194 #define TIMER1_INTERRUPT_TIME_MS (2000)
195 
201 #define TIMER1_OVERFLOW_TIME_MS (4194)
202 
207 #define TIMER1_TCNT1_VALUE ((uint16_t)(0xFFFF - (float)(1.0 * 0xFFFF * TIMER1_INTERRUPT_TIME_MS / TIMER1_OVERFLOW_TIME_MS)))
208 
213 #define TIMER1_VALUE_MAX_MS (60000)
214 
215 /*********************************************************************
216 * TASKS
217 *********************************************************************/
222 #define OPC_RETRY_COUNT_MAX (2)
223 
224 #if (USE_SENSOR_OA2 || USE_SENSOR_OB2 || USE_SENSOR_OC2 || USE_SENSOR_OD2)
229 #define OPC_BINS_LENGTH (OPCN2_BINS_LENGTH)
230 #endif
231 
232 #if (USE_SENSOR_OA3 || USE_SENSOR_OB3 || USE_SENSOR_OC3 || USE_SENSOR_OD3 || USE_SENSOR_OE3)
237 #define OPC_BINS_LENGTH (OPCN3_BINS_LENGTH)
238 #endif
239 
240 #endif
#define SDCARD_CHIP_SELECT_PIN
Chip select for SDcard SPI.
Definition: i2c-opc-config.h:91