Browse Source

bme280: added missing return in non-void function

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Mihai Tudor Panu 8 years ago
parent
commit
102d86870a
1 changed files with 208 additions and 210 deletions
  1. 208
    210
      src/bme280/bme280.cxx

+ 208
- 210
src/bme280/bme280.cxx View File

@@ -31,7 +31,7 @@
31 31
 #include "bme280.h"
32 32
 #include "bme280driver.h"
33 33
 /************** I2C buffer length ******/
34
-#define	I2C_BUFFER_LEN 26
34
+#define I2C_BUFFER_LEN 26
35 35
 
36 36
 
37 37
 
@@ -41,13 +41,13 @@ using namespace upm;
41 41
 
42 42
 
43 43
 /*----------------------------------------------------------------------------*
44
- *  	struct bme280_t parameters can be accessed by using bme280
45
- *	bme280_t having the following parameters
46
- *	Bus write function pointer: BME280_WR_FUNC_PTR
47
- 	Bus read function pointer: BME280_RD_FUNC_PTR
48
- *	Delay function pointer: delay_msec
49
- *	I2C address: dev_addr
50
- *	Chip id of the sensor: chip_id
44
+ *      struct bme280_t parameters can be accessed by using bme280
45
+ *  bme280_t having the following parameters
46
+ *  Bus write function pointer: BME280_WR_FUNC_PTR
47
+    Bus read function pointer: BME280_RD_FUNC_PTR
48
+ *  Delay function pointer: delay_msec
49
+ *  I2C address: dev_addr
50
+ *  Chip id of the sensor: chip_id
51 51
  *---------------------------------------------------------------------------*/
52 52
 
53 53
 struct bme280_t bme280;
@@ -57,23 +57,23 @@ mraa::I2c* BME280::m_i2c = NULL;
57 57
 int BME280::m_bus = 0;
58 58
 
59 59
 BME280::BME280 (int bus, int devAddr) {
60
-	m_bus = bus;
61
-	if( m_i2c == NULL)
62
-	{
63
-      		m_i2c = new mraa::I2c(m_bus);
64
-		m_i2c->address(BME280_I2C_ADDRESS1);
65
-		//Based on the requirement,  configure I2C interface.
66
-		I2C_routine();
67
-		/*--------------------------------------------------------------------------*
68
-		 *  This function used to assign the value/reference of
69
-		 *	the following parameters
70
-		 *	I2C address
71
-		 *	Bus Write
72
-		 *	Bus read
73
-		 *	Chip id
74
-		*-------------------------------------------------------------------------*/
75
-		bme280_init(&bme280);
76
-	}
60
+    m_bus = bus;
61
+    if( m_i2c == NULL)
62
+    {
63
+            m_i2c = new mraa::I2c(m_bus);
64
+        m_i2c->address(BME280_I2C_ADDRESS1);
65
+        //Based on the requirement,  configure I2C interface.
66
+        I2C_routine();
67
+        /*--------------------------------------------------------------------------*
68
+         *  This function used to assign the value/reference of
69
+         *  the following parameters
70
+         *  I2C address
71
+         *  Bus Write
72
+         *  Bus read
73
+         *  Chip id
74
+        *-------------------------------------------------------------------------*/
75
+        bme280_init(&bme280);
76
+    }
77 77
 }
78 78
 
79 79
 BME280::~BME280() {
@@ -81,21 +81,21 @@ BME280::~BME280() {
81 81
 }
82 82
 
83 83
 /* This function is an example for reading sensor temperature
84
- *	\param: None
85
- *	\return: compensated temperature
84
+ *  \param: None
85
+ *  \return: compensated temperature
86 86
  */
87 87
 
88 88
 int32_t BME280::getTemperatureInternal(void)
89 89
 {
90
-	/* The variable used to read uncompensated temperature*/
91
-	int32_t v_data_uncomp_tem_int32 =  getTemperatureRawInternal();
90
+    /* The variable used to read uncompensated temperature*/
91
+    int32_t v_data_uncomp_tem_int32 =  getTemperatureRawInternal();
92 92
 
93 93
 /*------------------------------------------------------------------*
94 94
 ************ START READ TRUE PRESSURE, TEMPERATURE AND HUMIDITY DATA ********
95 95
 *---------------------------------------------------------------------*/
96
-	/* API is used to read the true temperature*/
97
-	/* Input value as uncompensated temperature and output format*/
98
-	int32_t v_actual_temp_int32 = bme280_compensate_temperature_int32(v_data_uncomp_tem_int32);
96
+    /* API is used to read the true temperature*/
97
+    /* Input value as uncompensated temperature and output format*/
98
+    int32_t v_actual_temp_int32 = bme280_compensate_temperature_int32(v_data_uncomp_tem_int32);
99 99
 /*--------------------------------------------------------------------*
100 100
 ************ END READ TRUE TEMPERATURE  ********
101 101
 *-------------------------------------------------------------------------*/
@@ -104,22 +104,22 @@ return v_actual_temp_int32;
104 104
 }
105 105
 
106 106
 /* This function is an example for reading sensor pressure
107
- *	\param: None
108
- *	\return: compensated pressure
107
+ *  \param: None
108
+ *  \return: compensated pressure
109 109
  */
110 110
 
111 111
 int32_t BME280::getPressureInternal(void)
112 112
 {
113
-	/* The variable used to read uncompensated pressure*/
114
-	int32_t v_data_uncomp_pres_int32 = getPressureRawInternal();
113
+    /* The variable used to read uncompensated pressure*/
114
+    int32_t v_data_uncomp_pres_int32 = getPressureRawInternal();
115 115
 
116 116
 
117 117
 /*------------------------------------------------------------------*
118 118
 ************ START READ TRUE PRESSURE DATA ********
119 119
 *---------------------------------------------------------------------*/
120
-	/* API is used to read the true pressure*/
121
-	/* Input value as uncompensated pressure */
122
-	uint32_t v_actual_press_uint32 = bme280_compensate_pressure_int32(v_data_uncomp_pres_int32);
120
+    /* API is used to read the true pressure*/
121
+    /* Input value as uncompensated pressure */
122
+    uint32_t v_actual_press_uint32 = bme280_compensate_pressure_int32(v_data_uncomp_pres_int32);
123 123
 
124 124
 /*--------------------------------------------------------------------*
125 125
 ************ END READ TRUE PRESSURE ********
@@ -130,21 +130,21 @@ return v_actual_press_uint32;
130 130
 
131 131
 
132 132
 /* This function is an example for reading sensor humidity
133
- *	\param: None
134
- *	\return: compensated humidity
133
+ *  \param: None
134
+ *  \return: compensated humidity
135 135
  */
136 136
 
137 137
 int32_t BME280::getHumidityInternal(void)
138 138
 {
139
-	/* The variable used to read uncompensated pressure*/
140
-	int32_t v_data_uncomp_hum_int32 = getHumidityRawInternal();
139
+    /* The variable used to read uncompensated pressure*/
140
+    int32_t v_data_uncomp_hum_int32 = getHumidityRawInternal();
141 141
 
142 142
 /*------------------------------------------------------------------*
143 143
 ************ START READ TRUE HUMIDITY DATA ********
144 144
 *---------------------------------------------------------------------*/
145
-	/* API is used to read the true humidity*/
146
-	/* Input value as uncompensated humidity and output format*/
147
-	 uint32_t  v_actual_humity_uint32 = bme280_compensate_humidity_int32(v_data_uncomp_hum_int32);
145
+    /* API is used to read the true humidity*/
146
+    /* Input value as uncompensated humidity and output format*/
147
+     uint32_t  v_actual_humity_uint32 = bme280_compensate_humidity_int32(v_data_uncomp_hum_int32);
148 148
 
149 149
 /*--------------------------------------------------------------------*
150 150
 ************ END READ TRUE HUMIDITY ********
@@ -156,37 +156,37 @@ return v_actual_humity_uint32;
156 156
 
157 157
 
158 158
 /* This function is an example for reading sensor temperature
159
- *	\param: None
160
- *	\return: uncompensated temperature
159
+ *  \param: None
160
+ *  \return: uncompensated temperature
161 161
  */
162 162
 
163 163
 int32_t BME280::getTemperatureRawInternal(void)
164 164
 {
165
-	/* The variable used to read uncompensated temperature*/
166
-	int32_t v_data_uncomp_tem_int32 = BME280_INIT_VALUE;
167
-
168
-	/*	For initialization it is required to set the mode of
169
-	 *	the sensor as "NORMAL"
170
-	 *	data acquisition/read/write is possible in this mode
171
-	 *	by using the below API able to set the power mode as NORMAL*/
172
-	/* Set the power mode as NORMAL*/
173
-	bme280_set_power_mode(BME280_NORMAL_MODE);
174
-	/*	For reading the  temperature data it is required to
175
-	 *	set the OSS setting of temperature
176
-	 * In the code automated reading and writing of "BME280_CTRLHUM_REG_OSRSH"
177
-	 * register first set the "BME280_CTRLHUM_REG_OSRSH" and then read and write
178
-	 * the "BME280_CTRLMEAS_REG" register in the function*/
179
-
180
-	/* set the temperature oversampling*/
181
-	bme280_set_oversamp_temperature(BME280_OVERSAMP_4X);
165
+    /* The variable used to read uncompensated temperature*/
166
+    int32_t v_data_uncomp_tem_int32 = BME280_INIT_VALUE;
167
+
168
+    /*  For initialization it is required to set the mode of
169
+     *  the sensor as "NORMAL"
170
+     *  data acquisition/read/write is possible in this mode
171
+     *  by using the below API able to set the power mode as NORMAL*/
172
+    /* Set the power mode as NORMAL*/
173
+    bme280_set_power_mode(BME280_NORMAL_MODE);
174
+    /*  For reading the  temperature data it is required to
175
+     *  set the OSS setting of temperature
176
+     * In the code automated reading and writing of "BME280_CTRLHUM_REG_OSRSH"
177
+     * register first set the "BME280_CTRLHUM_REG_OSRSH" and then read and write
178
+     * the "BME280_CTRLMEAS_REG" register in the function*/
179
+
180
+    /* set the temperature oversampling*/
181
+    bme280_set_oversamp_temperature(BME280_OVERSAMP_4X);
182 182
 
183 183
 /************************* END INITIALIZATION *************************/
184 184
 
185 185
 /*------------------------------------------------------------------*
186 186
 ************ START READ UNCOMPENSATED TEMPERATURE  DATA ********
187 187
 *---------------------------------------------------------------------*/
188
-	/* API is used to read the uncompensated temperature*/
189
-	bme280_read_uncomp_temperature(&v_data_uncomp_tem_int32);
188
+    /* API is used to read the uncompensated temperature*/
189
+    bme280_read_uncomp_temperature(&v_data_uncomp_tem_int32);
190 190
 
191 191
 
192 192
 /*--------------------------------------------------------------------*
@@ -196,14 +196,14 @@ int32_t BME280::getTemperatureRawInternal(void)
196 196
 /*-----------------------------------------------------------------------*
197 197
 ************************* START DE-INITIALIZATION ***********************
198 198
 *-------------------------------------------------------------------------*/
199
-	/*	For de-initialization it is required to set the mode of
200
-	 *	the sensor as "SLEEP"
201
-	 *	the device reaches the lowest power consumption only
202
-	 *	In SLEEP mode no measurements are performed
203
-	 *	All registers are accessible
204
-	 *	by using the below API able to set the power mode as SLEEP*/
205
-	 /* Set the power mode as SLEEP*/
206
-	bme280_set_power_mode(BME280_SLEEP_MODE);
199
+    /*  For de-initialization it is required to set the mode of
200
+     *  the sensor as "SLEEP"
201
+     *  the device reaches the lowest power consumption only
202
+     *  In SLEEP mode no measurements are performed
203
+     *  All registers are accessible
204
+     *  by using the below API able to set the power mode as SLEEP*/
205
+     /* Set the power mode as SLEEP*/
206
+    bme280_set_power_mode(BME280_SLEEP_MODE);
207 207
 /*---------------------------------------------------------------------*
208 208
 ************************* END DE-INITIALIZATION **********************
209 209
 *---------------------------------------------------------------------*/
@@ -211,34 +211,34 @@ return v_data_uncomp_tem_int32;
211 211
 }
212 212
 
213 213
 /* This function is an example for reading sensor pressure
214
- *	\param: None
215
- *	\return: uncompensated pressure
214
+ *  \param: None
215
+ *  \return: uncompensated pressure
216 216
  */
217 217
 
218 218
 int32_t BME280::getPressureRawInternal(void)
219 219
 {
220
-	/* The variable used to read uncompensated pressure*/
221
-	int32_t v_data_uncomp_pres_int32 = BME280_INIT_VALUE;
222
-
223
-
224
-	/*	For initialization it is required to set the mode of
225
-	 *	the sensor as "NORMAL"
226
-	 *	data acquisition/read/write is possible in this mode
227
-	 *	by using the below API able to set the power mode as NORMAL*/
228
-	/* Set the power mode as NORMAL*/
229
-	bme280_set_power_mode(BME280_NORMAL_MODE);
230
-	/*	For reading the pressure data it is required to
231
-	 *	set the OSS setting of humidity, pressure and temperature
232
-	 * The "BME280_CTRLHUM_REG_OSRSH" register sets the humidity
233
-	 * data acquisition options of the device.
234
-	 * changes to this registers only become effective after a write operation to
235
-	 * "BME280_CTRLMEAS_REG" register.
236
-	 * In the code automated reading and writing of "BME280_CTRLHUM_REG_OSRSH"
237
-	 * register first set the "BME280_CTRLHUM_REG_OSRSH" and then read and write
238
-	 * the "BME280_CTRLMEAS_REG" register in the function*/
239
-
240
-	/* set the pressure oversampling*/
241
-	bme280_set_oversamp_pressure(BME280_OVERSAMP_2X);
220
+    /* The variable used to read uncompensated pressure*/
221
+    int32_t v_data_uncomp_pres_int32 = BME280_INIT_VALUE;
222
+
223
+
224
+    /*  For initialization it is required to set the mode of
225
+     *  the sensor as "NORMAL"
226
+     *  data acquisition/read/write is possible in this mode
227
+     *  by using the below API able to set the power mode as NORMAL*/
228
+    /* Set the power mode as NORMAL*/
229
+    bme280_set_power_mode(BME280_NORMAL_MODE);
230
+    /*  For reading the pressure data it is required to
231
+     *  set the OSS setting of humidity, pressure and temperature
232
+     * The "BME280_CTRLHUM_REG_OSRSH" register sets the humidity
233
+     * data acquisition options of the device.
234
+     * changes to this registers only become effective after a write operation to
235
+     * "BME280_CTRLMEAS_REG" register.
236
+     * In the code automated reading and writing of "BME280_CTRLHUM_REG_OSRSH"
237
+     * register first set the "BME280_CTRLHUM_REG_OSRSH" and then read and write
238
+     * the "BME280_CTRLMEAS_REG" register in the function*/
239
+
240
+    /* set the pressure oversampling*/
241
+    bme280_set_oversamp_pressure(BME280_OVERSAMP_2X);
242 242
 
243 243
 /************************* END INITIALIZATION *************************/
244 244
 
@@ -246,8 +246,8 @@ int32_t BME280::getPressureRawInternal(void)
246 246
 ************ START READ UNCOMPENSATED PRESSURE DATA ********
247 247
 *---------------------------------------------------------------------*/
248 248
 
249
-	/* API is used to read the uncompensated pressure*/
250
-	bme280_read_uncomp_pressure(&v_data_uncomp_pres_int32);
249
+    /* API is used to read the uncompensated pressure*/
250
+    bme280_read_uncomp_pressure(&v_data_uncomp_pres_int32);
251 251
 
252 252
 /*--------------------------------------------------------------------*
253 253
 ************ END READ UNCOMPENSATED PRESSURE ********
@@ -257,14 +257,14 @@ int32_t BME280::getPressureRawInternal(void)
257 257
 /*-----------------------------------------------------------------------*
258 258
 ************************* START DE-INITIALIZATION ***********************
259 259
 *-------------------------------------------------------------------------*/
260
-	/*	For de-initialization it is required to set the mode of
261
-	 *	the sensor as "SLEEP"
262
-	 *	the device reaches the lowest power consumption only
263
-	 *	In SLEEP mode no measurements are performed
264
-	 *	All registers are accessible
265
-	 *	by using the below API able to set the power mode as SLEEP*/
266
-	 /* Set the power mode as SLEEP*/
267
-	bme280_set_power_mode(BME280_SLEEP_MODE);
260
+    /*  For de-initialization it is required to set the mode of
261
+     *  the sensor as "SLEEP"
262
+     *  the device reaches the lowest power consumption only
263
+     *  In SLEEP mode no measurements are performed
264
+     *  All registers are accessible
265
+     *  by using the below API able to set the power mode as SLEEP*/
266
+     /* Set the power mode as SLEEP*/
267
+    bme280_set_power_mode(BME280_SLEEP_MODE);
268 268
 /*---------------------------------------------------------------------*
269 269
 ************************* END DE-INITIALIZATION **********************
270 270
 *---------------------------------------------------------------------*/
@@ -273,31 +273,31 @@ return v_data_uncomp_pres_int32;
273 273
 
274 274
 
275 275
 /* This function is an example for reading sensor humidity
276
- *	\param: None
277
- *	\return: uncompensated humidity
276
+ *  \param: None
277
+ *  \return: uncompensated humidity
278 278
  */
279 279
 
280 280
 int32_t BME280::getHumidityRawInternal(void)
281 281
 {
282
-	/* The variable used to read uncompensated pressure*/
283
-	int32_t v_data_uncomp_hum_int32 = BME280_INIT_VALUE;
284
-
285
-	/*	For initialization it is required to set the mode of
286
-	 *	the sensor as "NORMAL"
287
-	 *	data acquisition/read/write is possible in this mode
288
-	 *	by using the below API able to set the power mode as NORMAL*/
289
-	/* Set the power mode as NORMAL*/
290
-	bme280_set_power_mode(BME280_NORMAL_MODE);
291
-	/*	For reading  humidity  data it is required to
292
-	 *	set the OSS setting of humidity
293
-	 * The "BME280_CTRLHUM_REG_OSRSH" register sets the humidity
294
-	 * data acquisition options of the device.
295
-	 * changes to this registers only become effective after a write operation to
296
-	 * "BME280_CTRLMEAS_REG" register.
297
-	 * In the code automated reading and writing of "BME280_CTRLHUM_REG_OSRSH"
298
-	 * register first set the "BME280_CTRLHUM_REG_OSRSH" and then read and write
299
-	 * the "BME280_CTRLMEAS_REG" register in the function*/
300
-	bme280_set_oversamp_humidity(BME280_OVERSAMP_1X);
282
+    /* The variable used to read uncompensated pressure*/
283
+    int32_t v_data_uncomp_hum_int32 = BME280_INIT_VALUE;
284
+
285
+    /*  For initialization it is required to set the mode of
286
+     *  the sensor as "NORMAL"
287
+     *  data acquisition/read/write is possible in this mode
288
+     *  by using the below API able to set the power mode as NORMAL*/
289
+    /* Set the power mode as NORMAL*/
290
+    bme280_set_power_mode(BME280_NORMAL_MODE);
291
+    /*  For reading  humidity  data it is required to
292
+     *  set the OSS setting of humidity
293
+     * The "BME280_CTRLHUM_REG_OSRSH" register sets the humidity
294
+     * data acquisition options of the device.
295
+     * changes to this registers only become effective after a write operation to
296
+     * "BME280_CTRLMEAS_REG" register.
297
+     * In the code automated reading and writing of "BME280_CTRLHUM_REG_OSRSH"
298
+     * register first set the "BME280_CTRLHUM_REG_OSRSH" and then read and write
299
+     * the "BME280_CTRLMEAS_REG" register in the function*/
300
+    bme280_set_oversamp_humidity(BME280_OVERSAMP_1X);
301 301
 
302 302
 
303 303
 /************************* END INITIALIZATION *************************/
@@ -305,7 +305,7 @@ int32_t BME280::getHumidityRawInternal(void)
305 305
 /*------------------------------------------------------------------*
306 306
 ************ START READ HUMIDITY DATA ********
307 307
 *---------------------------------------------------------------------*/
308
-	/* API is used to read the uncompensated humidity*/
308
+    /* API is used to read the uncompensated humidity*/
309 309
         bme280_read_uncomp_humidity(&v_data_uncomp_hum_int32);
310 310
 
311 311
 /*--------------------------------------------------------------------*
@@ -316,14 +316,14 @@ int32_t BME280::getHumidityRawInternal(void)
316 316
 /*-----------------------------------------------------------------------*
317 317
 ************************* START DE-INITIALIZATION ***********************
318 318
 *-------------------------------------------------------------------------*/
319
-	/*	For de-initialization it is required to set the mode of
320
-	 *	the sensor as "SLEEP"
321
-	 *	the device reaches the lowest power consumption only
322
-	 *	In SLEEP mode no measurements are performed
323
-	 *	All registers are accessible
324
-	 *	by using the below API able to set the power mode as SLEEP*/
325
-	 /* Set the power mode as SLEEP*/
326
-	bme280_set_power_mode(BME280_SLEEP_MODE);
319
+    /*  For de-initialization it is required to set the mode of
320
+     *  the sensor as "SLEEP"
321
+     *  the device reaches the lowest power consumption only
322
+     *  In SLEEP mode no measurements are performed
323
+     *  All registers are accessible
324
+     *  by using the below API able to set the power mode as SLEEP*/
325
+     /* Set the power mode as SLEEP*/
326
+    bme280_set_power_mode(BME280_SLEEP_MODE);
327 327
 /*---------------------------------------------------------------------*
328 328
 ************************* END DE-INITIALIZATION **********************
329 329
 *---------------------------------------------------------------------*/
@@ -335,120 +335,118 @@ return v_data_uncomp_hum_int32;
335 335
 
336 336
 
337 337
 /*--------------------------------------------------------------------------*
338
-*	The following function is used to map the I2C bus read, write, delay and
339
-*	device address with global structure bme280
338
+*   The following function is used to map the I2C bus read, write, delay and
339
+*   device address with global structure bme280
340 340
 *-------------------------------------------------------------------------*/
341 341
 int8_t BME280::I2C_routine()
342
- {
342
+{
343 343
 /*--------------------------------------------------------------------------*
344 344
  *  By using bme280 the following structure parameter can be accessed
345
- *	Bus write function pointer: BME280_WR_FUNC_PTR
346
- *	Bus read function pointer: BME280_RD_FUNC_PTR
347
- *	Delay function pointer: delay_msec
348
- *	I2C address: dev_addr
345
+ *  Bus write function pointer: BME280_WR_FUNC_PTR
346
+ *  Bus read function pointer: BME280_RD_FUNC_PTR
347
+ *  Delay function pointer: delay_msec
348
+ *  I2C address: dev_addr
349 349
  *--------------------------------------------------------------------------*/
350
-//	bme280.bus_write = &BME280::BME280_I2C_bus_write;
351
-	bme280.bus_write = BME280_I2C_bus_write;
350
+//  bme280.bus_write = &BME280::BME280_I2C_bus_write;
351
+    bme280.bus_write = BME280_I2C_bus_write;
352 352
 
353
-	//bme280.bus_write = BME280_I2C_bus_write_dummy;
354
-	bme280.bus_read = BME280_I2C_bus_read;
355
-	bme280.dev_addr = BME280_I2C_ADDRESS1;
356
-	bme280.delay_msec = BME280_delay_msek;
353
+    //bme280.bus_write = BME280_I2C_bus_write_dummy;
354
+    bme280.bus_read = BME280_I2C_bus_read;
355
+    bme280.dev_addr = BME280_I2C_ADDRESS1;
356
+    bme280.delay_msec = BME280_delay_msek;
357 357
 
358
-	return BME280_INIT_VALUE;
358
+    return BME280_INIT_VALUE;
359 359
 }
360 360
 
361 361
 
362 362
 
363 363
 /*-------------------------------------------------------------------*
364
-*	The device address defined in the bme280.h file
364
+*   The device address defined in the bme280.h file
365 365
 *-----------------------------------------------------------------------*/
366 366
 int32_t BME280::i2c_write_string(uint8_t dev_addr,uint8_t* ptr, uint8_t cnt)
367 367
 {
368
-	mraa::Result ret;
369
-	m_i2c->address(dev_addr);
370
-
371
-	if((ret = m_i2c->write((const uint8_t*) (ptr), cnt)) != 0)
372
-	{
373
-	  	UPM_THROW("I2C write error");
374
-
375
-	}
376
-
368
+    mraa::Result ret;
369
+    m_i2c->address(dev_addr);
370
+
371
+    if((ret = m_i2c->write((const uint8_t*) (ptr), cnt)) != 0)
372
+    {
373
+        UPM_THROW("I2C write error");
374
+    }
375
+    return 0;
377 376
 }
378 377
 
379
-/*	\Brief: The function is used as I2C bus write
380
-*	\Return : Status of the I2C write
381
-*	\param dev_addr : The device address of the sensor
382
-*	\param reg_addr : Address of the first register, will data is going to be written
383
-*	\param reg_data : It is a value hold in the array,
384
-*		will be used for write the value into the register
385
-*	\param cnt : The no of byte of data to be write
378
+/*  \Brief: The function is used as I2C bus write
379
+*   \Return : Status of the I2C write
380
+*   \param dev_addr : The device address of the sensor
381
+*   \param reg_addr : Address of the first register, will data is going to be written
382
+*   \param reg_data : It is a value hold in the array,
383
+*       will be used for write the value into the register
384
+*   \param cnt : The no of byte of data to be write
386 385
 */
387 386
 
388 387
 int8_t BME280::BME280_I2C_bus_write(uint8_t dev_addr, uint8_t reg_addr, uint8_t *reg_data, uint8_t cnt)
389 388
 
390 389
 {
391
-	int32_t iError = BME280_INIT_VALUE;
392
-	static uint8_t array[I2C_BUFFER_LEN];
390
+    int32_t iError = BME280_INIT_VALUE;
391
+    static uint8_t array[I2C_BUFFER_LEN];
393 392
         for (int i=0; i<I2C_BUFFER_LEN; i++) array[i]=0;
394 393
 
395
-	uint8_t stringpos = BME280_INIT_VALUE;
396
-	array[BME280_INIT_VALUE] = reg_addr;
397
-	for (stringpos = BME280_INIT_VALUE; stringpos < cnt; stringpos++) {
398
-		array[stringpos + BME280_ONE_U8X] = *(reg_data + stringpos);
399
-	}
400
-	iError = i2c_write_string(dev_addr,array, cnt+1);
401
-	return (int8_t)iError;
394
+    uint8_t stringpos = BME280_INIT_VALUE;
395
+    array[BME280_INIT_VALUE] = reg_addr;
396
+    for (stringpos = BME280_INIT_VALUE; stringpos < cnt; stringpos++) {
397
+        array[stringpos + BME280_ONE_U8X] = *(reg_data + stringpos);
398
+    }
399
+    iError = i2c_write_string(dev_addr,array, cnt+1);
400
+    return (int8_t)iError;
402 401
 }
403 402
 
404 403
 int32_t BME280::i2c_write_read_string(uint8_t dev_addr,uint8_t reg_addr , uint8_t * ptr, uint8_t cnt)
405 404
 {
406
-	 mraa::Result ret;
405
+     mraa::Result ret;
407 406
 
408
-	m_i2c->address(dev_addr);
407
+    m_i2c->address(dev_addr);
409 408
 
410
-	if( m_i2c->readBytesReg(reg_addr, ptr, cnt) != cnt)
411
-	{
412
-		UPM_THROW("bme280 register read failed");
409
+    if( m_i2c->readBytesReg(reg_addr, ptr, cnt) != cnt)
410
+    {
411
+        UPM_THROW("bme280 register read failed");
413 412
 
414
-	}
415
-	return 0;
413
+    }
414
+    return 0;
416 415
 }
417 416
 
418
- /*	\Brief: The function is used as I2C bus read
419
- *	\Return : Status of the I2C read
420
- *	\param dev_addr : The device address of the sensor
421
- *	\param reg_addr : Address of the first register, will data is going to be read
422
- *	\param reg_data : This data read from the sensor, which is hold in an array
423
- *	\param cnt : The no of data byte of to be read
417
+ /* \Brief: The function is used as I2C bus read
418
+ *  \Return : Status of the I2C read
419
+ *  \param dev_addr : The device address of the sensor
420
+ *  \param reg_addr : Address of the first register, will data is going to be read
421
+ *  \param reg_data : This data read from the sensor, which is hold in an array
422
+ *  \param cnt : The no of data byte of to be read
424 423
  */
425 424
 int8_t BME280::BME280_I2C_bus_read(uint8_t dev_addr, uint8_t reg_addr, uint8_t *reg_data, uint8_t cnt)
426 425
 {
427
-	int32_t iError = BME280_INIT_VALUE;
428
-	uint8_t array[I2C_BUFFER_LEN] = {BME280_INIT_VALUE};
429
-	uint8_t stringpos = BME280_INIT_VALUE;
430
-	array[BME280_INIT_VALUE] = reg_addr;
431
-	i2c_write_read_string(dev_addr,reg_addr,array,cnt);
432
-	for (stringpos = BME280_INIT_VALUE; stringpos < cnt; stringpos++) {
433
-		*(reg_data + stringpos) = array[stringpos];
434
-	}
435
-	return (int8_t)iError;
426
+    int32_t iError = BME280_INIT_VALUE;
427
+    uint8_t array[I2C_BUFFER_LEN] = {BME280_INIT_VALUE};
428
+    uint8_t stringpos = BME280_INIT_VALUE;
429
+    array[BME280_INIT_VALUE] = reg_addr;
430
+    i2c_write_read_string(dev_addr,reg_addr,array,cnt);
431
+    for (stringpos = BME280_INIT_VALUE; stringpos < cnt; stringpos++) {
432
+        *(reg_data + stringpos) = array[stringpos];
433
+    }
434
+    return (int8_t)iError;
436 435
 }
437 436
 
438
-/*	Brief : The delay routine
439
- *	\param : delay in ms
437
+/*  Brief : The delay routine
438
+ *  \param : delay in ms
440 439
 */
441 440
 void BME280::BME280_delay_msek(uint16_t mseconds)
442 441
 {
443
-	struct timespec sleepTime;
444
-
445
-	sleepTime.tv_sec = mseconds / 1000; // Number of seconds
446
-	sleepTime.tv_nsec = ( mseconds % 1000 ) * 1000000; // Convert fractional seconds to nanoseconds
442
+    struct timespec sleepTime;
447 443
 
448
-	// Iterate nanosleep in a loop until the total sleep time is the original
449
-	// value of the seconds parameter
450
-	while ( ( nanosleep( &sleepTime, &sleepTime ) != 0 ) && ( errno == EINTR ) );
444
+    sleepTime.tv_sec = mseconds / 1000; // Number of seconds
445
+    sleepTime.tv_nsec = ( mseconds % 1000 ) * 1000000; // Convert fractional seconds to nanoseconds
451 446
 
447
+    // Iterate nanosleep in a loop until the total sleep time is the original
448
+    // value of the seconds parameter
449
+    while ( ( nanosleep( &sleepTime, &sleepTime ) != 0 ) && ( errno == EINTR ) );
452 450
 }
453 451
 
454 452