BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Typedefs | Functions
hh10d.h File Reference

Interface to Hope RF HH10D Humidity Sensor. More...

#include <bsp430/serial.h>
#include <bsp430/periph/timer.h>

Go to the source code of this file.

Data Structures

struct  sBSP430sensorsHH10Dstate
 

Macros

#define BSP430_SENSORS_HH10D_I2C_ADDRESS   0x51
 
#define BSP430_SENSORS_HH10D_FLAG_VALID_CAPTURE   0x01
 
#define BSP430_SENSORS_HH10D_FLAG_VALID_COUNT   0x02
 
#define BSP430_SENSORS_HH10D_FLAG_WAKE_ON_COUNT   0x04
 
#define BSP430_SENSORS_HH10D_FLAG_AUTOSAMPLE   0x08
 

Typedefs

typedef struct sBSP430sensorsHH10Dstate sBSP430sensorsHH10Dstate
 
typedef sBSP430sensorsHH10DstatehBSP430sensorsHH10Dstate
 

Functions

int iBSP430sensorsHH10DperiodicCallback_ni (const struct sBSP430halISRIndexedChainNode *cb, void *context, int idx)
 
int iBSP430sensorsHH10DgetCalibration (hBSP430halSERIAL i2c, hBSP430sensorsHH10Dstate hh10d)
 
static BSP430_CORE_INLINE int iBSP430sensorsHH10Dconvert_ppth_ni (hBSP430sensorsHH10Dstate hh10d, unsigned int interval_s)
 

Detailed Description

Interface to Hope RF HH10D Humidity Sensor.

This device is a humidity-to-pulse converter, which represents humidity as a linear function of the frequency, ranging from 5 kHz to 10 kHz. Each device is calibrated, with offset and sensitivity constants accessed through I2C.

To use this with BSP430 you will need an I2C device, a timer that will use the HH10D FOUT as its clock signal, and a capture/compare index on another timer to periodically read the first clock and estimate frequency. See examples/sensors/hh10d for an example of how to use it.

Warning
Because the humidity estimate is based on frequency, an accurate measurement of frequency is critical. A wildly inaccurate humidity estimate is likely when this sensor is used with a board that does not have a provide an accurate clock.
Homepage
http://github.com/pabigot/bsp430

Macro Definition Documentation

#define BSP430_SENSORS_HH10D_FLAG_AUTOSAMPLE   0x08

Bit set in sBSP430sensorsHH10Dstate::flags to cause iBSP430sensorsHH10DperiodicCallback_ni to automatically increment the compare index by sBSP430sensorsHH10Dstate::interval_tck to schedule the next callback.

Examples:
sensors/hh10d/main.c.
#define BSP430_SENSORS_HH10D_FLAG_VALID_CAPTURE   0x01
#define BSP430_SENSORS_HH10D_FLAG_VALID_COUNT   0x02
#define BSP430_SENSORS_HH10D_FLAG_WAKE_ON_COUNT   0x04

Bit set in sBSP430sensorsHH10Dstate::flags to cause iBSP430sensorsHH10DperiodicCallback_ni to include BSP430_HAL_ISR_CALLBACK_EXIT_LPM in its return value.

Examples:
sensors/hh10d/main.c.
#define BSP430_SENSORS_HH10D_I2C_ADDRESS   0x51

The 7-bit I2C slave address for the device. This is not configurable.

Typedef Documentation

Handle for an HH10D state instance.

State used to interact with the HH10D sensor.

Function Documentation

static BSP430_CORE_INLINE int iBSP430sensorsHH10Dconvert_ppth_ni ( hBSP430sensorsHH10Dstate  hh10d,
unsigned int  interval_s 
)
static

Convert the most recent HH10D sample into a humidity value.

Parameters
hh10dthe HH10D state
interval_sthe number of seconds covered by each sampling period. Be sure that this value (and the sBSP430sensorsHH10Dstate::interval_tck that produces it) does not exceed the duration at which the counter may wrap (max rate 10 kHz with 16-bit counter so a little over five seconds).
Returns
-1 if there is no available data, otherwise the measured relative humidity in parts-per-thousand.
Examples:
sensors/hh10d/main.c.
int iBSP430sensorsHH10DgetCalibration ( hBSP430halSERIAL  i2c,
hBSP430sensorsHH10Dstate  hh10d 
)

Read the calibration data from an HH10D device and store it in the state structure.

Note
  • The caller must hold the i2c resource
  • i2c may be in reset mode on entry, in which case it will be put back into reset mode before returning. i2c must not be in hold mode .
  • The slave address of the i2c resource will be reconfigured by this function.
Parameters
i2cthe I2C bus on which the HH10D device can be contacted.
hh10dthe state structure for the device.

return 0 if the calibration constants could be read; otherwise a negative error code.

Examples:
sensors/hh10d/main.c.
int iBSP430sensorsHH10DperiodicCallback_ni ( const struct sBSP430halISRIndexedChainNode cb,
void *  context,
int  idx 
)

A timer callback to handle HH10D periodic state updates.

This callback should be configured for periodic invocation on a timer. It should be installed in the cb.callback_ni field of a sBSP430sensorsHH10Dstate instance. There is probably no value in invoking it directly.

Parameters
cba pointer to the sBSP430sensorsHH10Dstate::cb field of an HH10D state instance.
contextas with iBSP430halISRCallbackIndexed_ni()
idxas with iBSP430halISRCallbackIndexed_ni()
Returns
as with iBSP430halISRCallbackIndexed_ni()
Examples:
sensors/hh10d/main.c.