adt7310.h¶
Interface definition for the ADT7310 sensor driver.
-
ADT7310_CONF_FAULT_QUEUE_MASK¶ 1
(0x03)
-
ADT7310_CONF_FAULT_QUEUE_SHIFT¶ 1
(0)
-
ADT7310_CONF_FAULT_QUEUE( x)¶ 1
(((x) << ADT7310_CONF_FAULT_QUEUE_SHIFT) & ADT7310_CONF_FAULT_QUEUE_MASK)
-
ADT7310_CONF_CT_POL_MASK¶ 1
(0x04)
-
ADT7310_CONF_CT_POL_SHIFT¶ 1
(2)
-
ADT7310_CONF_CT_POL( x)¶ 1
(((x) << ADT7310_CONF_CT_POL_SHIFT) & ADT7310_CONF_CT_POL_MASK)
-
ADT7310_CONF_INT_POL_MASK¶ 1
(0x08)
-
ADT7310_CONF_INT_POL_SHIFT¶ 1
(3)
-
ADT7310_CONF_INT_POL( x)¶ 1
(((x) << ADT7310_CONF_INT_POL_SHIFT) & ADT7310_CONF_INT_POL_MASK)
-
ADT7310_CONF_INTCT_MODE_MASK¶ 1
(0x10)
-
ADT7310_CONF_INTCT_MODE_SHIFT¶ 1
(4)
-
ADT7310_CONF_INTCT_MODE( x)¶ 1
(((x) << ADT7310_CONF_INTCT_MODE_SHIFT) & ADT7310_CONF_INTCT_MODE_MASK)
-
ADT7310_CONF_OPERATION_MODE_MASK¶ 1
(0x60)
-
ADT7310_CONF_OPERATION_MODE_SHIFT¶ 1
(5)
-
ADT7310_CONF_OPERATION_MODE( x)¶ 1
(((x) << ADT7310_CONF_OPERATION_MODE_SHIFT) & ADT7310_CONF_OPERATION_MODE_MASK)
-
ADT7310_CONF_RESOLUTION_MASK¶ 1
(0x80)
-
ADT7310_CONF_RESOLUTION_SHIFT¶ 1
(7)
-
ADT7310_CONF_RESOLUTION( x)¶ 1
(((x) << ADT7310_CONF_RESOLUTION_SHIFT) & ADT7310_CONF_RESOLUTION_MASK)
-
ADT7310_MODE_CONTINUOUS¶ Continuous operation mode.
1
(ADT7310_CONF_OPERATION_MODE(0))
-
ADT7310_MODE_ONE_SHOT¶ One shot.
1
(ADT7310_CONF_OPERATION_MODE(1))
-
ADT7310_MODE_1SPS¶ 1 sample per second
1
(ADT7310_CONF_OPERATION_MODE(2))
-
ADT7310_MODE_SHUTDOWN¶ Shut down (powersave)
1
(ADT7310_CONF_OPERATION_MODE(3))
-
int
adt7310_set_config(adt7310_t * dev, uint8_t config)¶ Set configuration register of an ADT7310 sensor.
Parameters
dev: pointer to sensor device descriptor config: configuration byte, see macros in adt7310.h Return values
- 0 on success
- -1 on error
-
int
adt7310_init(adt7310_t * dev,spi.h::spi_tspi,atmega_common/include/periph_cpu_common.h::spi_clk_tclk,gpio.h::gpio_tcs)¶ Initialize the ADT7310 sensor driver.
Note
The SPI bus is expected to have been initialized when adt7310_init is called.
Parameters
dev: pointer to sensor device descriptor spi: SPI bus the sensor is connected to clk: SPI bus speed cs: GPIO pin the chip select signal is connected to Return values
- 0 on success
- <0 on error
-
int16_t
adt7310_read_raw(const adt7310_t * dev)¶ Read raw temperature register value.
Note
The three least-significant bits of the value register are used for flags if the sensor is configured for 13 bit mode.
Parameters
dev: pointer to sensor device descriptor Return values
- raw sensor value on success
- INT16_MIN on error
-
int32_t
adt7310_read(const adt7310_t * dev)¶ Read temperature value from sensor and convert to milli-degrees Celsius.
Divide the returned value by 1000 to get integer degrees.
Parameters
dev: pointer to sensor device descriptor Return values
- temperature in milli-degrees Celsius
- INT32_MIN on errors
-
float
adt7310_read_float(const adt7310_t * dev)¶ Read temperature value from sensor and convert to degrees Celsius.
Parameters
dev: pointer to sensor device descriptor Return values
- floating point representation of temperature in degrees Celsius
- NaN on errors
-
struct
adt7310_t¶ Device descriptor for ADT7310 sensors.
-
spi.h::spi_tspi¶ SPI bus the sensor is connected to.
-
atmega_common/include/periph_cpu_common.h::spi_clk_tclk¶ SPI bus clock speed.
-
gpio.h::gpio_tcs¶ CS pin GPIO handle.
-
bool
initialized¶ sensor status, true if sensor is initialized
-
bool
high_res¶ Sensor resolution, true if configured to 16 bit resolution.
-