Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
humid_sht.c File Reference

SHTxx sensor interface. More...

#include "std.h"
#include "mcu_periph/gpio.h"
#include "mcu_periph/uart.h"
#include "pprzlink/messages.h"
#include "modules/datalink/downlink.h"
#include "humid_sht.h"
+ Include dependency graph for humid_sht.c:

Go to the source code of this file.

Macros

#define noACK   0
 
#define ACK   1
 
#define TEMP   0
 
#define HUMI   1
 
#define STATUS_REG_W   0x06
 
#define STATUS_REG_R   0x07
 
#define MEASURE_TEMP   0x03
 
#define MEASURE_HUMI   0x05
 
#define RESET   0x1e
 
#define SHT_IDLE   0
 
#define SHT_MEASURING_HUMID   1
 
#define SHT_MEASURING_TEMP   2
 
#define DATA_SET   gpio_setup_input(SHT_DAT_GPIO)
 set data pin to input More...
 
#define DATA_CLR   gpio_setup_output(SHT_DAT_GPIO)
 set data pin to output More...
 
#define DATA_IN   gpio_get(SHT_DAT_GPIO)
 get data pin More...
 
#define SCK_SET   gpio_set(SHT_SCK_GPIO)
 set clock pin to high More...
 
#define SCK_CLR   gpio_clear(SHT_SCK_GPIO)
 set clock pin to low More...
 

Functions

uint8_t s_write_byte (uint8_t value)
 
uint8_t s_read_byte (uint8_t ack)
 
void s_transstart (void)
 
void s_connectionreset (void)
 
uint8_t s_read_statusreg (uint8_t *p_value, uint8_t *p_checksum)
 
uint8_t s_write_statusreg (uint8_t *p_value)
 
uint8_t s_measure (uint16_t *p_value, uint8_t *p_checksum, uint8_t mode)
 
uint8_t s_start_measure (uint8_t mode)
 
uint8_t s_read_measure (uint16_t *p_value, uint8_t *p_checksum)
 
void calc_sht (uint16_t hum, uint16_t tem, float *fhum, float *ftem)
 
uint8_t humid_sht_reset (void)
 
void humid_sht_init (void)
 
void humid_sht_periodic (void)
 

Variables

uint16_t humidsht
 !SITL More...
 
uint16_t tempsht
 
float fhumidsht
 
float ftempsht
 
bool humid_sht_available
 
uint8_t humid_sht_status
 

Detailed Description

SHTxx sensor interface.

This reads the values for humidity and temperature from the SHTxx sensor through bit banging.

Definition in file humid_sht.c.

Macro Definition Documentation

◆ ACK

#define ACK   1

Definition at line 48 of file humid_sht.c.

◆ DATA_CLR

#define DATA_CLR   gpio_setup_output(SHT_DAT_GPIO)

set data pin to output

Definition at line 76 of file humid_sht.c.

◆ DATA_IN

#define DATA_IN   gpio_get(SHT_DAT_GPIO)

get data pin

Definition at line 78 of file humid_sht.c.

◆ DATA_SET

#define DATA_SET   gpio_setup_input(SHT_DAT_GPIO)

set data pin to input

Definition at line 74 of file humid_sht.c.

◆ HUMI

#define HUMI   1

Definition at line 50 of file humid_sht.c.

◆ MEASURE_HUMI

#define MEASURE_HUMI   0x05

Definition at line 60 of file humid_sht.c.

◆ MEASURE_TEMP

#define MEASURE_TEMP   0x03

Definition at line 58 of file humid_sht.c.

◆ noACK

#define noACK   0

Definition at line 47 of file humid_sht.c.

◆ RESET

#define RESET   0x1e

Definition at line 62 of file humid_sht.c.

◆ SCK_CLR

#define SCK_CLR   gpio_clear(SHT_SCK_GPIO)

set clock pin to low

Definition at line 83 of file humid_sht.c.

◆ SCK_SET

#define SCK_SET   gpio_set(SHT_SCK_GPIO)

set clock pin to high

Definition at line 81 of file humid_sht.c.

◆ SHT_IDLE

#define SHT_IDLE   0

Definition at line 65 of file humid_sht.c.

◆ SHT_MEASURING_HUMID

#define SHT_MEASURING_HUMID   1

Definition at line 66 of file humid_sht.c.

◆ SHT_MEASURING_TEMP

#define SHT_MEASURING_TEMP   2

Definition at line 67 of file humid_sht.c.

◆ STATUS_REG_R

#define STATUS_REG_R   0x07

Definition at line 56 of file humid_sht.c.

◆ STATUS_REG_W

#define STATUS_REG_W   0x06

Definition at line 54 of file humid_sht.c.

◆ TEMP

#define TEMP   0

Definition at line 49 of file humid_sht.c.

Function Documentation

◆ calc_sht()

void calc_sht ( uint16_t  hum,
uint16_t  tem,
float *  fhum,
float *  ftem 
)

Definition at line 257 of file humid_sht.c.

References C1, and C2.

Referenced by humid_sht_periodic().

+ Here is the caller graph for this function:

◆ humid_sht_init()

void humid_sht_init ( void  )

Definition at line 299 of file humid_sht.c.

References gpio_clear(), gpio_setup_input(), gpio_setup_output(), humid_sht_available, humid_sht_status, and SHT_IDLE.

+ Here is the call graph for this function:

◆ humid_sht_periodic()

◆ humid_sht_reset()

uint8_t humid_sht_reset ( void  )

Definition at line 288 of file humid_sht.c.

References RESET, s_connectionreset(), and s_write_byte().

+ Here is the call graph for this function:

◆ s_connectionreset()

void s_connectionreset ( void  )

Definition at line 167 of file humid_sht.c.

References DATA_SET, s_transstart(), SCK_CLR, and SCK_SET.

Referenced by humid_sht_periodic(), and humid_sht_reset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ s_measure()

uint8_t s_measure ( uint16_t p_value,
uint8_t p_checksum,
uint8_t  mode 
)

Definition at line 208 of file humid_sht.c.

References ACK, DATA_IN, HUMI, MEASURE_HUMI, MEASURE_TEMP, mode, noACK, s_read_byte(), s_transstart(), s_write_byte(), and TEMP.

+ Here is the call graph for this function:

◆ s_read_byte()

uint8_t s_read_byte ( uint8_t  ack)

Definition at line 124 of file humid_sht.c.

References DATA_CLR, DATA_IN, DATA_SET, SCK_CLR, SCK_SET, and val.

Referenced by s_measure(), s_read_measure(), and s_read_statusreg().

+ Here is the caller graph for this function:

◆ s_read_measure()

uint8_t s_read_measure ( uint16_t p_value,
uint8_t p_checksum 
)

Definition at line 244 of file humid_sht.c.

References ACK, DATA_IN, noACK, and s_read_byte().

Referenced by humid_sht_periodic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ s_read_statusreg()

uint8_t s_read_statusreg ( uint8_t p_value,
uint8_t p_checksum 
)

Definition at line 185 of file humid_sht.c.

References ACK, noACK, s_read_byte(), s_transstart(), s_write_byte(), and STATUS_REG_R.

+ Here is the call graph for this function:

◆ s_start_measure()

uint8_t s_start_measure ( uint8_t  mode)

Definition at line 229 of file humid_sht.c.

References HUMI, MEASURE_HUMI, MEASURE_TEMP, mode, s_transstart(), s_write_byte(), and TEMP.

Referenced by humid_sht_periodic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ s_transstart()

void s_transstart ( void  )

Definition at line 144 of file humid_sht.c.

References DATA_CLR, DATA_SET, SCK_CLR, and SCK_SET.

Referenced by s_connectionreset(), s_measure(), s_read_statusreg(), s_start_measure(), and s_write_statusreg().

+ Here is the caller graph for this function:

◆ s_write_byte()

uint8_t s_write_byte ( uint8_t  value)

Definition at line 104 of file humid_sht.c.

References DATA_CLR, DATA_IN, DATA_SET, SCK_CLR, and SCK_SET.

Referenced by humid_sht_reset(), s_measure(), s_read_statusreg(), s_start_measure(), and s_write_statusreg().

+ Here is the caller graph for this function:

◆ s_write_statusreg()

uint8_t s_write_statusreg ( uint8_t p_value)

Definition at line 197 of file humid_sht.c.

References s_transstart(), s_write_byte(), and STATUS_REG_W.

+ Here is the call graph for this function:

Variable Documentation

◆ fhumidsht

float fhumidsht

Definition at line 87 of file humid_sht.c.

Referenced by humid_sht_periodic().

◆ ftempsht

float ftempsht

Definition at line 87 of file humid_sht.c.

Referenced by humid_hih_periodic(), and humid_sht_periodic().

◆ humid_sht_available

bool humid_sht_available

Definition at line 88 of file humid_sht.c.

Referenced by humid_sht_init(), and humid_sht_periodic().

◆ humid_sht_status

uint8_t humid_sht_status

Definition at line 89 of file humid_sht.c.

Referenced by humid_sht_init(), and humid_sht_periodic().

◆ humidsht

uint16_t humidsht

!SITL

Definition at line 86 of file humid_sht.c.

Referenced by humid_sht_periodic().

◆ tempsht

uint16_t tempsht

Definition at line 86 of file humid_sht.c.

Referenced by humid_sht_periodic().