Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
humid_sht.c File Reference

SHTxx sensor interface. More...

#include "std.h"
#include "mcu_periph/gpio.h"
#include "mcu_periph/uart.h"
#include "messages.h"
#include "subsystems/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
 
uint16_t tempsht
 
float fhumidsht
 
float ftempsht
 
bool_t 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

#define ACK   1

Definition at line 41 of file humid_sht.c.

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

#define DATA_CLR   gpio_setup_output(SHT_DAT_GPIO)

set data pin to output

Definition at line 69 of file humid_sht.c.

Referenced by s_read_byte(), s_transstart(), and s_write_byte().

#define DATA_IN   gpio_get(SHT_DAT_GPIO)

get data pin

Definition at line 71 of file humid_sht.c.

Referenced by s_measure(), s_read_byte(), s_read_measure(), and s_write_byte().

#define DATA_SET   gpio_setup_input(SHT_DAT_GPIO)

set data pin to input

Definition at line 67 of file humid_sht.c.

Referenced by s_connectionreset(), s_read_byte(), s_transstart(), and s_write_byte().

#define HUMI   1

Definition at line 43 of file humid_sht.c.

Referenced by humid_sht_periodic(), s_measure(), and s_start_measure().

#define MEASURE_HUMI   0x05

Definition at line 53 of file humid_sht.c.

Referenced by s_measure(), and s_start_measure().

#define MEASURE_TEMP   0x03

Definition at line 51 of file humid_sht.c.

Referenced by s_measure(), and s_start_measure().

#define noACK   0

Definition at line 40 of file humid_sht.c.

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

#define RESET   0x1e

Definition at line 55 of file humid_sht.c.

Referenced by exti2_irq_handler(), and humid_sht_reset().

#define SCK_CLR   gpio_clear(SHT_SCK_GPIO)

set clock pin to low

Definition at line 76 of file humid_sht.c.

Referenced by s_connectionreset(), s_read_byte(), s_transstart(), and s_write_byte().

#define SCK_SET   gpio_set(SHT_SCK_GPIO)

set clock pin to high

Definition at line 74 of file humid_sht.c.

Referenced by s_connectionreset(), s_read_byte(), s_transstart(), and s_write_byte().

#define SHT_IDLE   0

Definition at line 58 of file humid_sht.c.

Referenced by humid_sht_init(), and humid_sht_periodic().

#define SHT_MEASURING_HUMID   1

Definition at line 59 of file humid_sht.c.

Referenced by humid_sht_periodic().

#define SHT_MEASURING_TEMP   2

Definition at line 60 of file humid_sht.c.

Referenced by humid_sht_periodic().

#define STATUS_REG_R   0x07

Definition at line 49 of file humid_sht.c.

Referenced by s_read_statusreg().

#define STATUS_REG_W   0x06

Definition at line 47 of file humid_sht.c.

Referenced by s_write_statusreg().

#define TEMP   0

Definition at line 42 of file humid_sht.c.

Referenced by humid_sht_periodic(), s_measure(), and s_start_measure().

Function Documentation

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

Definition at line 253 of file humid_sht.c.

References C1, and C2.

Referenced by humid_sht_periodic().

+ Here is the caller graph for this function:

void humid_sht_init ( void  )

Definition at line 295 of file humid_sht.c.

References FALSE, 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:

void humid_sht_periodic ( void  )
uint8_t humid_sht_reset ( void  )

Definition at line 284 of file humid_sht.c.

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

+ Here is the call graph for this function:

void s_connectionreset ( void  )

Definition at line 162 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:

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

Definition at line 204 of file humid_sht.c.

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

+ Here is the call graph for this function:

uint8_t s_read_byte ( uint8_t  ack)

Definition at line 118 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:

uint8_t s_read_measure ( uint16_t p_value,
uint8_t p_checksum 
)

Definition at line 240 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:

uint8_t s_read_statusreg ( uint8_t p_value,
uint8_t p_checksum 
)

Definition at line 181 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:

uint8_t s_start_measure ( uint8_t  mode)

Definition at line 225 of file humid_sht.c.

References HUMI, MEASURE_HUMI, MEASURE_TEMP, 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:

void s_transstart ( void  )

Definition at line 139 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:

uint8_t s_write_byte ( uint8_t  value)

Definition at line 97 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:

uint8_t s_write_statusreg ( uint8_t p_value)

Definition at line 193 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

float fhumidsht

Definition at line 80 of file humid_sht.c.

Referenced by humid_sht_periodic().

float ftempsht

Definition at line 80 of file humid_sht.c.

Referenced by humid_hih_periodic(), and humid_sht_periodic().

bool_t humid_sht_available

Definition at line 81 of file humid_sht.c.

Referenced by humid_sht_init(), and humid_sht_periodic().

uint8_t humid_sht_status

Definition at line 82 of file humid_sht.c.

Referenced by humid_sht_init(), and humid_sht_periodic().

uint16_t humidsht

Definition at line 79 of file humid_sht.c.

Referenced by humid_sht_periodic().

uint16_t tempsht

Definition at line 79 of file humid_sht.c.

Referenced by humid_sht_periodic().