RocketLogger  1.1.6
sensor.h File Reference
#include <stdint.h>
#include "../rl_file.h"
+ Include dependency graph for sensor.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rl_sensor
 

Macros

#define MAX_MESSAGE_LENGTH   1000
 
#define I2C_BUS_FILENAME   "/dev/i2c-1"
 
#define SENSOR_REGISTRY_SIZE   5
 Number of sensor registred. More...
 
#define SENSOR_NAME_LENGTH   (RL_FILE_CHANNEL_NAME_LENGTH)
 

Functions

int Sensors_initSharedBus (void)
 
void Sensors_closeSharedBus (void)
 
int Sensors_getSharedBus (void)
 
int Sensors_initSharedComm (uint8_t)
 
int Sensors_openBus (void)
 
int Sensors_closeBus (int)
 
int Sensors_scan (int *)
 
void Sensors_close (int *)
 

Variables

const struct rl_sensor sensor_registry [SENSOR_REGISTRY_SIZE]
 

Macro Definition Documentation

#define I2C_BUS_FILENAME   "/dev/i2c-1"

Definition at line 42 of file sensor.h.

Referenced by Sensors_openBus().

#define MAX_MESSAGE_LENGTH   1000

Copyright (c) 2016-2019, Swiss Federal Institute of Technology (ETH Zurich) All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 39 of file sensor.h.

Referenced by Sensors_scan().

#define SENSOR_NAME_LENGTH   (RL_FILE_CHANNEL_NAME_LENGTH)

Definition at line 48 of file sensor.h.

#define SENSOR_REGISTRY_SIZE   5

Number of sensor registred.

Definition at line 46 of file sensor.h.

Referenced by ambient_setup_channels(), ambient_store_data(), Sensors_close(), and Sensors_scan().

Function Documentation

void Sensors_close ( int *  )
int Sensors_closeBus ( int  bus)

Close a I2C sensor bus.

Parameters
busThe I2C bus to close
Returns
Status (error) code

Definition at line 98 of file sensor.c.

References rl_sensor::close, ERROR, and rl_log().

Referenced by Sensors_closeSharedBus().

+ Here is the call graph for this function:

void Sensors_closeSharedBus ( void  )

Close the shared I2C sensor bus.

Returns
Status (error) code

Definition at line 134 of file sensor.c.

References sensor_bus, and Sensors_closeBus().

Referenced by hw_close().

+ Here is the call graph for this function:

int Sensors_getSharedBus ( void  )

Get the shared I2C bus handle.

Returns
The I2C bus handle

Definition at line 119 of file sensor.c.

References sensor_bus.

Referenced by BME280_getID(), BME280_init(), BME280_read(), BME280_readCalibration(), BME280_setParameters(), TSL4531_getID(), TSL4531_init(), TSL4531_read(), TSL4531_sendRange(), and TSL4531_setParameters().

int Sensors_initSharedBus ( void  )

Initialize the shared I2C sensor bus.

Returns
Status (error) code

Definition at line 110 of file sensor.c.

References sensor_bus, and Sensors_openBus().

Referenced by hw_init().

+ Here is the call graph for this function:

int Sensors_initSharedComm ( uint8_t  device_address)

Initiate an I2C communication with a device.

Parameters
sensor_addressThe I2C address of the device
Returns
Status (error) code

Definition at line 126 of file sensor.c.

References sensor_bus.

Referenced by BME280_init(), BME280_read(), TSL4531_init(), and TSL4531_read().

int Sensors_openBus ( void  )

Open a new handle of the I2C bus.

Returns
The bus handle

Definition at line 85 of file sensor.c.

References ERROR, I2C_BUS_FILENAME, and rl_log().

Referenced by Sensors_initSharedBus().

+ Here is the call graph for this function:

int Sensors_scan ( int *  )

Variable Documentation

const struct rl_sensor sensor_registry[SENSOR_REGISTRY_SIZE]

The sensor registry structure.

Register your sensor (channels) here. Multiple channels from the same sensor should be added as consecutive entries.

Note
The SENSOR_REGISTRY_SIZE needs to be adjusted accordingly.

Definition at line 53 of file sensor.c.

Referenced by ambient_setup_channels(), and ambient_store_data().