ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_interface_tmp117.h
Go to the documentation of this file.
1 #ifndef RUUVI_INTERFACE_TMP117_H
2 #define RUUVI_INTERFACE_TMP117_H
28 #include "ruuvi_driver_error.h"
29 #include "ruuvi_driver_sensor.h"
30 
31 /*
32 ADDRESS TYPE RESET ACRONYM REGISTER NAME
33 00h R 8000h Temp_Result Temperature result register
34 01h R/W 0220h Configuration Configuration register
35 02h R/W 6000h THigh_Limit Temperature high limit register
36 03h R/W 8000h TLow_Limit Temperature low limit register
37 04h R/W 0000h EEPROM_UL EEPROM unlock register
38 05h R/W xxxxh EEPROM1 EEPROM1 register
39 06h R/W xxxxh EEPROM2 EEPROM2 register
40 07h R/W 0000h Temp_Offset Temperature offset register
41 08h R/W xxxxh EEPROM3 EEPROM3 register
42 0Fh R 0117h Device_ID Device ID register
43 */
44 
45 #define TMP117_REG_TEMP_RESULT (0x00U)
46 #define TMP117_REG_CONFIGURATION (0x01U)
47 #define TMP117_REG_THIGH_LIMIT (0x02U)
48 #define TMP117_REG_TLOW_LIMIT (0x03U)
49 #define TMP117_REG_EEPROM_UL (0x04U)
50 #define TMP117_REG_EEPROM1 (0x05U)
51 #define TMP117_REG_EEPROM2 (0x06U)
52 #define TMP117_REG_TEMP_OFFSET (0x07U)
53 #define TMP117_REG_EEPROM3 (0x08U)
54 #define TMP117_REG_DEVICE_ID (0x0FU)
55 
56 #define TMP117_MASK_RESET (0x0002U)
57 #define TMP117_MASK_ID (0x01FFU)
58 #define TMP117_MASK_OS (0x0060U)
59 #define TMP117_MASK_MODE (0x0C00U)
60 #define TMP117_MASK_CC (0x0380U)
61 
62 #define TMP117_VALUE_ID (0x0117U)
63 
64 #define TMP117_POS_OS (5U)
65 #define TMP117_VALUE_OS_1 (0x00U << TMP117_POS_OS)
66 #define TMP117_VALUE_OS_8 (0x01U << TMP117_POS_OS)
67 #define TMP117_VALUE_OS_32 (0x02U << TMP117_POS_OS)
68 #define TMP117_VALUE_OS_64 (0x03U << TMP117_POS_OS)
69 
70 #define TMP117_POS_CC (7U)
71 #define TMP117_VALUE_CC_16_MS (0x00U << TMP117_POS_CC)
72 #define TMP117_VALUE_CC_125_MS (0x01U << TMP117_POS_CC)
73 #define TMP117_VALUE_CC_250_MS (0x02U << TMP117_POS_CC)
74 #define TMP117_VALUE_CC_500_MS (0x03U << TMP117_POS_CC)
75 #define TMP117_VALUE_CC_1000_MS (0x04U << TMP117_POS_CC)
76 #define TMP117_VALUE_CC_4000_MS (0x05U << TMP117_POS_CC)
77 #define TMP117_VALUE_CC_8000_MS (0x06U << TMP117_POS_CC)
78 #define TMP117_VALUE_CC_16000_MS (0x07U << TMP117_POS_CC)
79 
80 #define TMP117_POS_MODE (10U)
81 #define TMP117_VALUE_MODE_SLEEP (0x01U << TMP117_POS_MODE)
82 #define TMP117_VALUE_MODE_SINGLE (0x03U << TMP117_POS_MODE)
83 #define TMP117_VALUE_MODE_CONT (0x00U << TMP117_POS_MODE)
84 
85 #define TMP117_POS_DRDY (13U)
86 #define TMP117_MASK_DRDY (1U << TMP117_POS_DRDY)
87 
88 #define TMP117_VALUE_TEMP_NA (0x8000U)
89 #define TMP117_OS_1_TSAMPLE_MS (16U)
90 #define TMP117_OS_8_TSAMPLE_MS (125U)
91 #define TMP117_OS_32_TSAMPLE_MS (500U)
92 #define TMP117_OS_64_TSAMPLE_MS (1000U)
93 
94 // POR reset 1.5 ms, soft reset 2 ms, margin.
95 #define TMP117_CC_RESET_DELAY_MS (4U)
96 
99  environmental_sensor, rd_bus_t bus, uint8_t handle);
102  environmental_sensor, rd_bus_t bus, uint8_t handle);
104 rd_status_t ri_tmp117_samplerate_set (uint8_t * samplerate);
106 rd_status_t ri_tmp117_samplerate_get (uint8_t * samplerate);
108 rd_status_t ri_tmp117_resolution_set (uint8_t * resolution);
110 rd_status_t ri_tmp117_resolution_get (uint8_t * resolution);
112 rd_status_t ri_tmp117_scale_set (uint8_t * scale);
114 rd_status_t ri_tmp117_scale_get (uint8_t * scale);
116 rd_status_t ri_tmp117_dsp_set (uint8_t * dsp, uint8_t * parameter);
118 rd_status_t ri_tmp117_dsp_get (uint8_t * dsp, uint8_t * parameter);
120 rd_status_t ri_tmp117_mode_set (uint8_t * mode);
122 rd_status_t ri_tmp117_mode_get (uint8_t * mode);
125  data);
127 #endif
uint32_t rd_status_t
bitfield for representing errors
rd_bus_t
Type of bus sensor uses.
rd_status_t ri_tmp117_resolution_set(uint8_t *resolution)
rd_sensor_setup_fp
rd_status_t ri_tmp117_dsp_get(uint8_t *dsp, uint8_t *parameter)
rd_sensor_dsp_fp
rd_status_t ri_tmp117_data_get(rd_sensor_data_t *const data)
rd_sensor_data_fp
rd_status_t ri_tmp117_resolution_get(uint8_t *resolution)
rd_sensor_setup_fp
rd_status_t ri_tmp117_uninit(rd_sensor_t *sensor, rd_bus_t bus, uint8_t handle)
rd_sensor_init_fp
rd_status_t ri_tmp117_scale_get(uint8_t *scale)
rd_sensor_setup_fp
rd_status_t ri_tmp117_samplerate_get(uint8_t *samplerate)
rd_sensor_setup_fp
rd_status_t ri_tmp117_scale_set(uint8_t *scale)
rd_sensor_setup_fp
rd_status_t ri_tmp117_mode_set(uint8_t *mode)
rd_sensor_setup_fp
rd_status_t ri_tmp117_dsp_set(uint8_t *dsp, uint8_t *parameter)
rd_sensor_dsp_fp
rd_status_t ri_tmp117_mode_get(uint8_t *mode)
rd_sensor_setup_fp
rd_status_t ri_tmp117_samplerate_set(uint8_t *samplerate)
rd_sensor_setup_fp
rd_status_t ri_tmp117_init(rd_sensor_t *environmental_sensor, rd_bus_t bus, uint8_t handle)
rd_sensor_init_fp
Ruuvi error codes and error check function.
Ruuvi sensor interface Lifecycle: Beta
Generic sensor data struct.
Interface to sensor. Some sensors can implement additional functions. The additional functions are de...