All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
ADT7310 SPI temperature sensor

Driver for the Analog Devices ADT7310 temperature sensor. More...

Detailed Description

Driver for the Analog Devices ADT7310 temperature sensor.

Description

The ADT7310 is a high accuracy digital temperature sensor in a narrow SOIC package. It contains a band gap temperature reference and a 13-bit ADC to monitor and digitize the temperature to a 0.0625°C resolution. The ADC resolution, by default, is set to 13 bits (0.0625 °C). This can be changed to 16 bits (0.0078 °C) by setting Bit 7 in the configuration register (Register Address 0x01). The ADT7310 is guaranteed to operate over supply voltages from 2.7 V to 5.5 V. Operating at 3.3 V, the average supply current is typically 210 μA. The ADT7310 has a shutdown mode that powers down the device and offers a shutdown current of typically 2 μA. The ADT7310 is rated for operation over the −55°C to +150°C temperature range.

Usage

See tests/drivers/adt7310 for an example application using this driver.

Caveats

This driver is currently missing support for a number of hardware features:

Files

file  adt7310.h
 Interface definition for the ADT7310 sensor driver.
 

Data Structures

struct  adt7310_t
 Device descriptor for ADT7310 sensors. More...
 

Functions

int adt7310_set_config (adt7310_t *dev, uint8_t config)
 Set configuration register of an ADT7310 sensor.
 
int adt7310_init (adt7310_t *dev, spi_t spi, spi_clk_t clk, gpio_t cs)
 Initialize the ADT7310 sensor driver.
 
int16_t adt7310_read_raw (const adt7310_t *dev)
 Read raw temperature register value.
 
int32_t adt7310_read (const adt7310_t *dev)
 Read temperature value from sensor and convert to milli-degrees Celsius.
 
float adt7310_read_float (const adt7310_t *dev)
 Read temperature value from sensor and convert to degrees Celsius.
 

ADT7310 configuration bits

#define ADT7310_CONF_FAULT_QUEUE_MASK   (0x03)
 
#define ADT7310_CONF_FAULT_QUEUE_SHIFT   (0)
 
#define ADT7310_CONF_FAULT_QUEUE(x)
 
#define ADT7310_CONF_CT_POL_MASK   (0x04)
 
#define ADT7310_CONF_CT_POL_SHIFT   (2)
 
#define ADT7310_CONF_CT_POL(x)
 
#define ADT7310_CONF_INT_POL_MASK   (0x08)
 
#define ADT7310_CONF_INT_POL_SHIFT   (3)
 
#define ADT7310_CONF_INT_POL(x)
 
#define ADT7310_CONF_INTCT_MODE_MASK   (0x10)
 
#define ADT7310_CONF_INTCT_MODE_SHIFT   (4)
 
#define ADT7310_CONF_INTCT_MODE(x)
 
#define ADT7310_CONF_OPERATION_MODE_MASK   (0x60)
 
#define ADT7310_CONF_OPERATION_MODE_SHIFT   (5)
 
#define ADT7310_CONF_OPERATION_MODE(x)
 
#define ADT7310_CONF_RESOLUTION_MASK   (0x80)
 
#define ADT7310_CONF_RESOLUTION_SHIFT   (7)
 
#define ADT7310_CONF_RESOLUTION(x)
 
#define ADT7310_MODE_CONTINUOUS   (ADT7310_CONF_OPERATION_MODE(0))
 Continuous operation mode.
 
#define ADT7310_MODE_ONE_SHOT   (ADT7310_CONF_OPERATION_MODE(1))
 One shot.
 
#define ADT7310_MODE_1SPS   (ADT7310_CONF_OPERATION_MODE(2))
 1 sample per second
 
#define ADT7310_MODE_SHUTDOWN   (ADT7310_CONF_OPERATION_MODE(3))
 Shut down (powersave)
 

Macro Definition Documentation

◆ ADT7310_CONF_CT_POL

#define ADT7310_CONF_CT_POL ( x)
Value:
(((x) << ADT7310_CONF_CT_POL_SHIFT) & ADT7310_CONF_CT_POL_MASK)

Definition at line 83 of file adt7310.h.

◆ ADT7310_CONF_CT_POL_MASK

#define ADT7310_CONF_CT_POL_MASK   (0x04)

Definition at line 81 of file adt7310.h.

◆ ADT7310_CONF_CT_POL_SHIFT

#define ADT7310_CONF_CT_POL_SHIFT   (2)

Definition at line 82 of file adt7310.h.

◆ ADT7310_CONF_FAULT_QUEUE

#define ADT7310_CONF_FAULT_QUEUE ( x)
Value:
(((x) << ADT7310_CONF_FAULT_QUEUE_SHIFT) & ADT7310_CONF_FAULT_QUEUE_MASK)

Definition at line 80 of file adt7310.h.

◆ ADT7310_CONF_FAULT_QUEUE_MASK

#define ADT7310_CONF_FAULT_QUEUE_MASK   (0x03)

Definition at line 78 of file adt7310.h.

◆ ADT7310_CONF_FAULT_QUEUE_SHIFT

#define ADT7310_CONF_FAULT_QUEUE_SHIFT   (0)

Definition at line 79 of file adt7310.h.

◆ ADT7310_CONF_INT_POL

#define ADT7310_CONF_INT_POL ( x)
Value:
(((x) << ADT7310_CONF_INT_POL_SHIFT) & ADT7310_CONF_INT_POL_MASK)

Definition at line 86 of file adt7310.h.

◆ ADT7310_CONF_INT_POL_MASK

#define ADT7310_CONF_INT_POL_MASK   (0x08)

Definition at line 84 of file adt7310.h.

◆ ADT7310_CONF_INT_POL_SHIFT

#define ADT7310_CONF_INT_POL_SHIFT   (3)

Definition at line 85 of file adt7310.h.

◆ ADT7310_CONF_INTCT_MODE

#define ADT7310_CONF_INTCT_MODE ( x)
Value:
(((x) << ADT7310_CONF_INTCT_MODE_SHIFT) & ADT7310_CONF_INTCT_MODE_MASK)

Definition at line 89 of file adt7310.h.

◆ ADT7310_CONF_INTCT_MODE_MASK

#define ADT7310_CONF_INTCT_MODE_MASK   (0x10)

Definition at line 87 of file adt7310.h.

◆ ADT7310_CONF_INTCT_MODE_SHIFT

#define ADT7310_CONF_INTCT_MODE_SHIFT   (4)

Definition at line 88 of file adt7310.h.

◆ ADT7310_CONF_OPERATION_MODE

#define ADT7310_CONF_OPERATION_MODE ( x)
Value:
(((x) << ADT7310_CONF_OPERATION_MODE_SHIFT) & ADT7310_CONF_OPERATION_MODE_MASK)

Definition at line 92 of file adt7310.h.

◆ ADT7310_CONF_OPERATION_MODE_MASK

#define ADT7310_CONF_OPERATION_MODE_MASK   (0x60)

Definition at line 90 of file adt7310.h.

◆ ADT7310_CONF_OPERATION_MODE_SHIFT

#define ADT7310_CONF_OPERATION_MODE_SHIFT   (5)

Definition at line 91 of file adt7310.h.

◆ ADT7310_CONF_RESOLUTION

#define ADT7310_CONF_RESOLUTION ( x)
Value:
(((x) << ADT7310_CONF_RESOLUTION_SHIFT) & ADT7310_CONF_RESOLUTION_MASK)

Definition at line 95 of file adt7310.h.

◆ ADT7310_CONF_RESOLUTION_MASK

#define ADT7310_CONF_RESOLUTION_MASK   (0x80)

Definition at line 93 of file adt7310.h.

◆ ADT7310_CONF_RESOLUTION_SHIFT

#define ADT7310_CONF_RESOLUTION_SHIFT   (7)

Definition at line 94 of file adt7310.h.

◆ ADT7310_MODE_1SPS

#define ADT7310_MODE_1SPS   (ADT7310_CONF_OPERATION_MODE(2))

1 sample per second

Definition at line 108 of file adt7310.h.

◆ ADT7310_MODE_CONTINUOUS

#define ADT7310_MODE_CONTINUOUS   (ADT7310_CONF_OPERATION_MODE(0))

Continuous operation mode.

Definition at line 100 of file adt7310.h.

◆ ADT7310_MODE_ONE_SHOT

#define ADT7310_MODE_ONE_SHOT   (ADT7310_CONF_OPERATION_MODE(1))

One shot.

Definition at line 104 of file adt7310.h.

◆ ADT7310_MODE_SHUTDOWN

#define ADT7310_MODE_SHUTDOWN   (ADT7310_CONF_OPERATION_MODE(3))

Shut down (powersave)

Definition at line 112 of file adt7310.h.

Function Documentation

◆ adt7310_init()

int adt7310_init ( adt7310_t * dev,
spi_t spi,
spi_clk_t clk,
gpio_t cs )

Initialize the ADT7310 sensor driver.

Note
The SPI bus is expected to have been initialized when adt7310_init is called.
Parameters
[in]devpointer to sensor device descriptor
[in]spiSPI bus the sensor is connected to
[in]clkSPI bus speed
[in]csGPIO pin the chip select signal is connected to
Returns
0 on success
<0 on error

◆ adt7310_read()

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
[in]devpointer to sensor device descriptor
Returns
temperature in milli-degrees Celsius
INT32_MIN on errors

◆ adt7310_read_float()

float adt7310_read_float ( const adt7310_t * dev)

Read temperature value from sensor and convert to degrees Celsius.

Parameters
[in]devpointer to sensor device descriptor
Returns
floating point representation of temperature in degrees Celsius
NaN on errors

◆ adt7310_read_raw()

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
[in]devpointer to sensor device descriptor
Returns
raw sensor value on success
INT16_MIN on error

◆ adt7310_set_config()

int adt7310_set_config ( adt7310_t * dev,
uint8_t config )

Set configuration register of an ADT7310 sensor.

Parameters
[in]devpointer to sensor device descriptor
[in]configconfiguration byte, see macros in adt7310.h
Returns
0 on success
-1 on error