1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/drivers/si70xx/include/si70xx_internals.h
iosabi f72efb1daf drivers/si70xx: Add support for Si705x sensors
The Silicon Labs Si705x sensors (Si7050/1/3/4/5) are very similar to the
Si7021 sensors featuring only a temperature sensor and no humidity
sensor. The only difference between the Si705x is the temperature
accuracy of the reading, ranging from +/- 0.1 C in the Si7051 to +/- 1 C
in the Si7050.

This patch adds support for this family of sensors extending the
functionality of the existing si70xx driver. Following the style of
other modules, this implements a pseudomodule per supported chip, adding
si7050, si7051, si7053, si7054 and si7055 pseudomodules.

As a minor change this patch also implements the missing
si70xx_get_serial, si70xx_get_id and si70xx_get_revision functions that
were declared in the si70xx.h header but implemented as private
functions. The si70xx_get_id() may be relevant for the application to
know at run time exactly which version of the hardware is installed.

The updated test running with a Si7051 shows the following output, which
seems consistent with the room temperature conditions during the test.

```
make SI70XX_VARIANT=si7051 -C tests/driver_si70xx/ all flash
```

```
SI70XX temperature and humidity sensor test application
Initializing sensor...
[OK]
Found SI7051 sensor, revision 32
temperature: 24.71 C
temperature: 24.69 C
```
2021-04-17 20:14:35 +00:00

89 lines
2.2 KiB
C

/*
* Copyright (C) 2016 Bas Stottelaar <basstottelaar@gmail.com>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup drivers_si70xx
*
* @{
* @file
* @brief Internal definitions for Si7006/13/20/21
*
* @author Bas Stottelaar <basstottelaar@gmail.com>
*/
#ifndef SI70XX_INTERNALS_H
#define SI70XX_INTERNALS_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Si70xx chip addresses.
*/
#define SI70XX_I2C_ADDRESS (0x40)
/**
* @name Si70xx device commands.
* @{
*/
#define SI70XX_MEASURE_RH_HOLD (0xE5)
#define SI70XX_MEASURE_RH (0xF5)
#define SI70XX_MEASURE_TEMP_HOLD (0xE3)
#define SI70XX_MEASURE_TEMP (0xF3)
#define SI70XX_MEASURE_TEMP_PREV (0xE0)
#define SI70XX_RESET (0xFE)
#define SI70XX_WRITE_USER_REG (0xE6)
#define SI70XX_READ_USER_REG (0xE7)
#define SI70XX_WRITE_HEATER_REG (0x51)
#define SI70XX_READ_HEATER_REG (0x11)
#define SI70XX_READ_ID_FIRST_A (0xFA)
#define SI70XX_READ_ID_FIRST_B (0x0F)
#define SI70XX_READ_ID_SECOND_A (0xFC)
#define SI70XX_READ_ID_SECOND_B (0xC9)
#define SI70XX_READ_REVISION_A (0x84)
#define SI70XX_READ_REVISION_B (0xB8)
/** @} */
/**
* @name Si70xx register values.
* @{
*/
#if defined(MODULE_SI7006)
#define SI70XX_ID (6)
#elif defined(MODULE_SI7013)
#define SI70XX_ID (13)
#elif defined(MODULE_SI7020)
#define SI70XX_ID (20)
#elif defined(MODULE_SI7021)
#define SI70XX_ID (21)
#elif defined(MODULE_SI7050)
#define SI70XX_ID (50)
#elif defined(MODULE_SI7051)
#define SI70XX_ID (51)
#elif defined(MODULE_SI7053)
#define SI70XX_ID (53)
#elif defined(MODULE_SI7054)
#define SI70XX_ID (54)
#elif defined(MODULE_SI7055)
#define SI70XX_ID (55)
#else
#error "Please provide a valid Si70xx variant (Si7006/13/20/21/5X)"
#endif
#define SI70XX_REVISION_1 (0xFF)
#define SI70XX_REVISION_2 (0x20)
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* SI70XX_INTERNALS_H */
/** @} */