Thermometer indicating temperature and humidity by LED blink pattern
Dependencies: BLE_API mbed nRF51822
hts221.h
00001 /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 00002 * 00003 * The information contained herein is property of Nordic Semiconductor ASA. 00004 * Terms and conditions of usage are described in detail in NORDIC 00005 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 00006 * 00007 * Licensees are granted free, non-transferable use of the information. NO 00008 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 00009 * the file. 00010 * 00011 */ 00012 00013 #ifndef HTS221_H 00014 #define HTS221_H 00015 00016 /*lint ++flb "Enter library region" */ 00017 00018 #include <stdbool.h> 00019 #include <stdint.h> 00020 00021 #define ADDRESS_WHO_AM_I (0x0FU) //!< WHO_AM_I register identifies the device. Expected value is 0xBC. 00022 00023 #define HTS221_WriteADDE 0xBE 00024 #define HTS221_ReadADDE 0xBF 00025 #define HTS221_TempHumi_OUT 0x28 00026 #define HTS221_CALIB 0x30 00027 00028 #define MaxTemp 120 00029 #define MinTemp -40 00030 #define MaxHumi 100 00031 #define MinHumi 0 00032 00033 // Humidity and temperature resolution mode, to ocnfigure sample average 00034 #define TRes_1 000 // Number of temperature samples take 2^1, TRes_2 take 2^2, and so forth. 00035 #define TRes_2 001 00036 #define TRes_3 010 00037 #define TRes_4 011 00038 #define TRes_5 100 00039 #define TRes_6 101 00040 #define TRes_7 102 00041 #define TRes_8 103 00042 00043 #define HRes_2 000 // Number of humidity samples take 2^2, HRes_3 take 2^3, and so forth. 00044 #define HRes_3 001 00045 #define HRes_4 010 00046 #define HRes_5 011 00047 #define HRes_6 100 00048 #define HRes_7 101 00049 #define HRes_8 102 00050 #define HRes_9 103 00051 00052 // Control register 1 00053 #define PD_On 0x80 // Power down mode 00054 #define PD_Off 0x00 // Active mode 00055 00056 #define BDU_On 0x04 // Block data update, this feature prevents the reading of LSB and MSB related to different samples. 00057 #define BDU_Off 0x00 00058 // Define output data rate 00059 #define ODR_OneShot 0x00 00060 #define ODR_1Hz 0x01 00061 #define ODR_7Hz 0x02 00062 #define ODR_12_5Hz 0x03 00063 // Control register 2 00064 #define Boot 0x80 00065 #define NoBoot 0x00 00066 #define HeaterOn 0x02 00067 #define HeaterOff 0x00 00068 #define New_OS 0x01 // One shot, a single acquisition of temperature and humidity is started 00069 #define No_OS 0x00 00070 // Control register 3 00071 #define DRDY_H 0x00 // Data Ready output signal active high(default) 00072 #define DRDY_L 0x80 // Data Ready output signal active low 00073 #define PP_OD_PP 0x00 // Push-pull on PIN3(DRDY)(default) 00074 #define PP_OD_OD 0x40 // Open Drain on PIN3(DRDY) 00075 #define DRDY_EN 0x04 // Data Ready enable 00076 #define DRDY_NON 0x00 // Data Ready disable(default) 00077 00078 // Status register 00079 #define H_DA_On 0x02 // Humidity data avialable, set to 1 whenever a new humidity sample is available. 00080 #define H_DA_Off 0x00 00081 #define T_DA_On 0x01 // Temperature data avialable, set to 1 whenever a new humidity sample is available. 00082 #define T_DA_Off 0x00 00083 00084 bool hts221_init(void); 00085 00086 void hts221_register_write(uint8_t register_address, const uint8_t value); 00087 00088 void hts221_register_read(char register_address, char *destination, uint8_t number_of_bytes); 00089 00090 bool hts221_verify_product_id(void); 00091 00092 void HTS221_Calib(void); 00093 00094 void HTS221_ReadTempHumi( float *pTemp , float *pHumi); 00095 00096 float linear_interpolation(int16_t x0, float y0, int16_t x1, float y1, float mes); 00097 00098 #endif /* HTS221_H */ 00099
Generated on Fri Aug 26 2022 21:33:01 by 1.7.2