BSP430
20141115
Board Support Package for MSP430 microcontrollers
|
Interface to Hope RF HH10D Humidity Sensor. More...
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 sBSP430sensorsHH10Dstate * | hBSP430sensorsHH10Dstate |
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) |
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.
#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.
#define BSP430_SENSORS_HH10D_FLAG_VALID_CAPTURE 0x01 |
Bit set in sBSP430sensorsHH10Dstate::flags when sBSP430sensorsHH10Dstate::last_capture has a valid value.
#define BSP430_SENSORS_HH10D_FLAG_VALID_COUNT 0x02 |
Bit set in sBSP430sensorsHH10Dstate::flags when sBSP430sensorsHH10Dstate::last_period_count has a valid value.
#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.
#define BSP430_SENSORS_HH10D_I2C_ADDRESS 0x51 |
The 7-bit I2C slave address for the device. This is not configurable.
Handle for an HH10D state instance.
typedef struct sBSP430sensorsHH10Dstate sBSP430sensorsHH10Dstate |
State used to interact with the HH10D sensor.
|
static |
Convert the most recent HH10D sample into a humidity value.
hh10d | the HH10D state |
interval_s | the 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). |
int iBSP430sensorsHH10DgetCalibration | ( | hBSP430halSERIAL | i2c, |
hBSP430sensorsHH10Dstate | hh10d | ||
) |
Read the calibration data from an HH10D device and store it in the state structure.
i2c
resourcei2c
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 .i2c
resource will be reconfigured by this function.i2c | the I2C bus on which the HH10D device can be contacted. |
hh10d | the state structure for the device. |
return 0 if the calibration constants could be read; otherwise a negative error code.
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.
cb | a pointer to the sBSP430sensorsHH10Dstate::cb field of an HH10D state instance. |
context | as with iBSP430halISRCallbackIndexed_ni() |
idx | as with iBSP430halISRCallbackIndexed_ni() |