Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 23 additions & 40 deletions drivers/include/sht1x.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,57 +26,40 @@
#include <stdint.h>
#include <periph/gpio.h>

#include "sht1x_types.h"
#include "sht1x_params.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef MODULE_AUTO_INIT_ACTUATORS_SENSORS_SHT1X
/**
* @brief Possible configuration (=status byte) values of the SHT10/11/15
* @brief Array of all auto-initialized SHT1X device descriptors
*
* These values can be or'ed together to get the configuration.
*/
typedef enum {
/** Use 8/12 bit resolution instead of 12/14 bit for temp/hum */
SHT1X_CONF_LOW_RESOLUTION = 0x01,
/** Don't upload calibration data to register to safe 10 millisec */
SHT1X_CONF_SKIP_CALIBRATION = 0x02,
/** Waste 8mA at 5V to increase the sensor temperature up to 10°C */
SHT1X_CONF_ENABLE_HEATER = 0x04,
/** Skip the CRC check (and reading the CRC byte) to safe time */
SHT1X_CONF_SKIP_CRC = 0x08,
} sht1x_conf_t;

/**
* @brief Possible values for Vdd (measured temperature depends on it)
* @note Only available if module @ref sys_auto_init_actuators_sensors_sht1x
* is used
*/
typedef enum {
SHT1X_VDD_5_0V = 0,
SHT1X_VDD_4_0V = 1,
SHT1X_VDD_3_5V = 2,
SHT1X_VDD_3_0V = 3,
SHT1X_VDD_2_5V = 4,
} sht1x_vdd_t;
extern sht1x_dev_t sht1x_devs[SHT1X_NUMOF];

/**
* @brief SHT10/11/15 temperature humidity sensor
* @brief If `sht1x` is auto-initialized, device descriptors can be retrieved by number
* @param num Number of the SHT1X device to retrieve the device descriptor of
* @return The device descriptor of the device with number @p num
* @retval `NULL` @p num is out of range
*
* @note Only available if module @ref sys_auto_init_actuators_sensors_sht1x
* is used
*/
typedef struct {
gpio_t clk; /**< GPIO connected to the clock pin of the SHT1X */
gpio_t data; /**< GPIO connected to the data pin of the SHT1X */
int16_t temp_off; /**< Offset to add to the measured temperature */
int16_t hum_off; /**< Offset to add to the measured humidity */
uint8_t conf; /**< Status byte (containing configuration) of the SHT1X */
uint8_t vdd; /**< Supply voltage of the SHT1X (as sht1x_vdd_t) */
} sht1x_dev_t;
static inline sht1x_dev_t * sht1x_get_dev(unsigned num)
Comment thread
maribu marked this conversation as resolved.
{
if (num >= SHT1X_NUMOF) {
return NULL;
}

/**
* @brief Parameters required to set up the SHT10/11/15 device driver
*/
typedef struct {
gpio_t clk; /**< GPIO connected to the clock pin of the SHT1X */
gpio_t data; /**< GPIO connected to the data pin of the SHT1X */
sht1x_vdd_t vdd; /**< The supply voltage of the SHT1X */
} sht1x_params_t;
return &sht1x_devs[num];
}
#endif /* MODULE_AUTO_INIT_ACTUATORS_SENSORS_SHT1X */

/**
* @brief Initialize the SHT10/11/15 sensor
Expand Down
3 changes: 3 additions & 0 deletions drivers/sht1x/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
FEATURES_REQUIRED += periph_gpio
USEMODULE += xtimer
ifneq (,$(filter auto_init_sensors_actuators_default,$(USEMODULE)))
USEMODULE += auto_init_actuators_sensors_sht1x
endif
7 changes: 6 additions & 1 deletion drivers/sht1x/include/sht1x_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define SHT1X_PARAMS_H

#include "board.h"
#include "sht1x.h"
#include "sht1x_types.h"
#include "saul_reg.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -85,6 +85,11 @@ static const saul_reg_info_t sht1x_saul_info[] =
SHT1X_SAULINFO
};

/**
* @brief Number of SHT1x devices
*/
#define SHT1X_NUMOF (sizeof(sht1x_params) / sizeof(sht1x_params[0]))

#ifdef __cplusplus
}
#endif
Expand Down
82 changes: 82 additions & 0 deletions drivers/sht1x/include/sht1x_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
Comment thread
maribu marked this conversation as resolved.
* Copyright 2019 Otto-von-Guericke-Universität Magdeburg
*
* 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_sht1x
*
* @{
* @file
* @brief Data types of SHT10/SHT11/SHT15 Device Driver
*
* @author Marian Buschsieweke <marian.buschsieweke@ovgu.de>
*/

#ifndef SHT1X_TYPES_H
#define SHT1X_TYPES_H

#include <stdint.h>
#include <periph/gpio.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Possible configuration (=status byte) values of the SHT10/11/15
*
* These values can be or'ed together to get the configuration.
*/
typedef enum {
/** Use 8/12 bit resolution instead of 12/14 bit for temp/hum */
SHT1X_CONF_LOW_RESOLUTION = 0x01,
/** Don't upload calibration data to register to safe 10 millisec */
SHT1X_CONF_SKIP_CALIBRATION = 0x02,
/** Waste 8mA at 5V to increase the sensor temperature up to 10°C */
SHT1X_CONF_ENABLE_HEATER = 0x04,
/** Skip the CRC check (and reading the CRC byte) to safe time */
SHT1X_CONF_SKIP_CRC = 0x08,
} sht1x_conf_t;

/**
* @brief Possible values for Vdd (measured temperature depends on it)
*/
typedef enum {
SHT1X_VDD_5_0V = 0,
SHT1X_VDD_4_0V = 1,
SHT1X_VDD_3_5V = 2,
SHT1X_VDD_3_0V = 3,
SHT1X_VDD_2_5V = 4,
} sht1x_vdd_t;

/**
* @brief SHT10/11/15 temperature humidity sensor
*/
typedef struct {
gpio_t clk; /**< GPIO connected to the clock pin of the SHT1X */
gpio_t data; /**< GPIO connected to the data pin of the SHT1X */
int16_t temp_off; /**< Offset to add to the measured temperature */
int16_t hum_off; /**< Offset to add to the measured humidity */
uint8_t conf; /**< Status byte (containing configuration) of the SHT1X */
uint8_t vdd; /**< Supply voltage of the SHT1X (as sht1x_vdd_t) */
} sht1x_dev_t;

/**
* @brief Parameters required to set up the SHT10/11/15 device driver
*/
typedef struct {
gpio_t clk; /**< GPIO connected to the clock pin of the SHT1X */
gpio_t data; /**< GPIO connected to the data pin of the SHT1X */
sht1x_vdd_t vdd; /**< The supply voltage of the SHT1X */
} sht1x_params_t;

#ifdef __cplusplus
}
#endif

#endif /* SHT1X_TYPES_H */
/** @} */
1 change: 1 addition & 0 deletions makefiles/defaultmodules.inc.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DEFAULT_MODULE += board cpu core core_init core_msg core_panic sys

DEFAULT_MODULE += auto_init
DEFAULT_MODULE += auto_init_actuators_sensors_default

# Initialize all used peripherals by default
DEFAULT_MODULE += periph_init
Expand Down
1 change: 1 addition & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ PSEUDOMODULES += test_utils_interactive_sync_shell

# All auto_init modules are pseudomodules
PSEUDOMODULES += auto_init_%
NO_PSEUDOMODULES += auto_init_actuators_sensors
NO_PSEUDOMODULES += auto_init_can
NO_PSEUDOMODULES += auto_init_loramac
NO_PSEUDOMODULES += auto_init_multimedia
Expand Down
14 changes: 12 additions & 2 deletions sys/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ ifneq (,$(filter arduino,$(USEMODULE)))
FEATURES_REQUIRED += periph_uart
SKETCH_MODULE ?= arduino_sketches
USEMODULE += $(SKETCH_MODULE)
USEMODULE += fmt
USEMODULE += xtimer
endif

ifneq (,$(filter arduino_pwm,$(FEATURES_USED)))
Expand All @@ -24,6 +22,14 @@ ifneq (,$(filter congure_test,$(USEMODULE)))
USEMODULE += fmt
endif

ifneq (,$(filter auto_init_actuators_sensors_%,$(filter-out auto_init_actuators_sensors_default,$(USEMODULE))))
USEMODULE += auto_init_actuators_sensors
endif

ifneq (,$(filter auto_init_saul,$(USEMODULE)))
USEMODULE += auto_init_actuators_sensors_default
endif

ifneq (,$(filter eepreg,$(USEMODULE)))
FEATURES_REQUIRED += periph_eeprom
endif
Expand Down Expand Up @@ -605,6 +611,10 @@ ifneq (,$(filter shell_commands,$(USEMODULE)))
USEMODULE += netif
USEMODULE += ipv6_addr
endif

ifneq (,$(filter sht1x,$(USEMODULE)))
USEMODULE += auto_init_actuators_sensors_sht1x
endif
endif

ifneq (,$(filter posix_semaphore,$(USEMODULE)))
Expand Down
4 changes: 4 additions & 0 deletions sys/auto_init/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
ifneq (,$(filter auto_init_actuators_sensors,$(USEMODULE)))
DIRS += actuators_sensors
endif

ifneq (,$(filter gnrc_netif_init,$(USEMODULE)))
DIRS += netif
endif
Expand Down
7 changes: 7 additions & 0 deletions sys/auto_init/actuators_sensors/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MODULE = auto_init_actuators_sensors

SRC := $(MODULE).c

SUBMODULES := 1

include $(RIOTBASE)/Makefile.base
27 changes: 27 additions & 0 deletions sys/auto_init/actuators_sensors/auto_init_actuators_sensors.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2020 Otto-von-Guericke-Universität Magdeburg
*
* 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 sys_auto_init_actuators_sensors
*
* @{
* @file
* @brief Implementation of the auto initialization of actuators and sensors
*
* @author Marian Buschsieweke <marian.buschsieweke@ovgu.de>
*
* @}
*/
#include <stdint.h>
#include <stdio.h>

#include "auto_init.h"

void auto_init_actuators_sensors(void)
{
}
32 changes: 32 additions & 0 deletions sys/auto_init/actuators_sensors/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2020 Otto-von-Guericke-Universität Magdeburg
*
* 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.
*/

/**
* @defgroup sys_auto_init_actuators_sensors Actuator & Sensor Auto Initialisation
* @ingroup sys_auto_init
* @brief Auto initialisation of actuator and sensor drivers
*
* This module contains auto init functions for actuator and sensor drivers.
*
* # Architecture / Usage
* Each actuator/sensor driver "foo" capable of auto initialization must provide
* the (pseudo) module `auto_init_actuators_sensors_foo` that provides the
* auto initialization. The module `auto_init_actuators_sensors` provides the
* function `void auto_init_actuators_sensors(void)` that will call the auto
* initialisation hooks of the individual actuator and sensor drivers.
*
* Note that the auto initialization of each actuator and sensor driver must
* be individually enabled to allow the user maximum flexibility. However,
* the pseudo module `auto_init_sensors_actuators_default` will pull in the auto
* initialization hooks of all used actuator and sensor drivers.
*
* # SAUL Integration
* Each actuator driver and sensor driver auto-init hook must also register the
* SAUL endpoints (if present) if and only if the module `auto_init_saul` is
* used.
*/
Loading