BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Macros | Functions
mcp9808.h File Reference

Interface to the MCP9808 digital temperature sensor. More...

#include <bsp430/serial.h>
#include <bsp430/periph/timer.h>

Go to the source code of this file.

Macros

#define BSP430_SENSORS_MCP9808_I2C_ADDRESS   0x18
 
#define BSP430_SENSORS_MCP9808_REGNO_CONFIG   1
 
#define BSP430_SENSORS_MCP9808_REGNO_TUPPER   2
 
#define BSP430_SENSORS_MCP9808_REGNO_TLOWER   3
 
#define BSP430_SENSORS_MCP9808_REGNO_TCRIT   4
 
#define BSP430_SENSORS_MCP9808_REGNO_TA   5
 
#define BSP430_SENSORS_MCP9808_REGNO_MFGID   6
 
#define BSP430_SENSORS_MCP9808_REGNO_DEVID   7
 
#define BSP430_SENSORS_MCP9808_REGNO_RESOLUTION   8
 
#define BSP430_SENSORS_MCP9808_CONFIG_HYST0p0   0x0000
 
#define BSP430_SENSORS_MCP9808_CONFIG_HYST1p5   0x0200
 
#define BSP430_SENSORS_MCP9808_CONFIG_HYST3p0   0x0400
 
#define BSP430_SENSORS_MCP9808_CONFIG_HYST6p0   0x0600
 
#define BSP430_SENSORS_MCP9808_CONFIG_HYSTM   0x0600
 
#define BSP430_SENSORS_MCP9808_CONFIG_SHDN   0x0010
 
#define BSP430_SENSORS_MCP9808_CONFIG_CRITLCK   0x0080
 
#define BSP430_SENSORS_MCP9808_CONFIG_WNDWLCK   0x0040
 
#define BSP430_SENSORS_MCP9808_CONFIG_INTCLR   0x0020
 
#define BSP430_SENSORS_MCP9808_CONFIG_ALRSTAT   0x0010
 
#define BSP430_SENSORS_MCP9808_CONFIG_ALRCTL   0x0008
 
#define BSP430_SENSORS_MCP9808_CONFIG_ALRSEL   0x0004
 
#define BSP430_SENSORS_MCP9808_CONFIG_ALRPOL   0x0002
 
#define BSP430_SENSORS_MCP9808_CONFIG_ALRMOD   0x0001
 
#define BSP430_SENSORS_MCP9808_CONVERSION_ms(res_)
 
#define BSP430_SENSORS_MCP9808_TEMP_CRIT   0x8000
 
#define BSP430_SENSORS_MCP9808_TEMP_HIGH   0x4000
 
#define BSP430_SENSORS_MCP9808_TEMP_LOW   0x2000
 
#define BSP430_SENSORS_MCP9808_TEMP_SIGN   0x1000
 
#define BSP430_SENSORS_MCP9808_TEMP_MASK   0x0FFF
 
#define BSP430_SENSORS_MCP9808_OFFSET_Kd160   (43704UL)
 

Functions

static BSP430_CORE_INLINE int iBSP430sensorsMCP9808tempFromRaw_cK (uint16_t raw)
 

Detailed Description

Interface to the MCP9808 digital temperature sensor.

This device measures temperature in Celcius (K + 273.15) with an accuracy of 0.25 K and a resolution of 0.0625 K.

The device permits read and (sometimes) write of 16-bit registers that are stored in MSB order, except for the 8-bit resolution register.

Homepage
http://github.com/pabigot/bsp430

Macro Definition Documentation

#define BSP430_SENSORS_MCP9808_CONFIG_ALRCTL   0x0008

Alert control

#define BSP430_SENSORS_MCP9808_CONFIG_ALRMOD   0x0001

Alert mode

#define BSP430_SENSORS_MCP9808_CONFIG_ALRPOL   0x0002

Alert polarity

#define BSP430_SENSORS_MCP9808_CONFIG_ALRSEL   0x0004

Alert select

#define BSP430_SENSORS_MCP9808_CONFIG_ALRSTAT   0x0010

Alert status

#define BSP430_SENSORS_MCP9808_CONFIG_CRITLCK   0x0080

Critical register lock bit

#define BSP430_SENSORS_MCP9808_CONFIG_HYST0p0   0x0000

Configuration bitmask for no hysteresis

#define BSP430_SENSORS_MCP9808_CONFIG_HYST1p5   0x0200

Configuration bitmask for 1.5 K

#define BSP430_SENSORS_MCP9808_CONFIG_HYST3p0   0x0400

Configuration bitmask for 3.0 K

#define BSP430_SENSORS_MCP9808_CONFIG_HYST6p0   0x0600

Configuration bitmask for 6.0 K

#define BSP430_SENSORS_MCP9808_CONFIG_HYSTM   0x0600

Mask for hysterisis bits

#define BSP430_SENSORS_MCP9808_CONFIG_INTCLR   0x0020

Interrupt clear

#define BSP430_SENSORS_MCP9808_CONFIG_SHDN   0x0010

Shutdown mode. Setting this enables low-power; clearing it enables continuous conversion.

#define BSP430_SENSORS_MCP9808_CONFIG_WNDWLCK   0x0040

Upper/lower window register lock bit

#define BSP430_SENSORS_MCP9808_CONVERSION_ms (   res_)
Value:
((0 == (res_)) ? 30 \
: (1 == (res_)) ? 35 \
: (2 == (res_)) ? 130 \
: 250)

Conversion time, in milliseconds, for the given resolution setting

#define BSP430_SENSORS_MCP9808_I2C_ADDRESS   0x18

The 7-bit I2C slave address for the device. If you pull up any of the three address lines, add the binary value to this.

#define BSP430_SENSORS_MCP9808_OFFSET_Kd160   (43704UL)

Offset added to convert measured Cel/160 to K/160. Value is (273.15*160) which provides an exact integer.

#define BSP430_SENSORS_MCP9808_REGNO_CONFIG   1

Register index for configuration

#define BSP430_SENSORS_MCP9808_REGNO_DEVID   7

Register index for device ID/revision

#define BSP430_SENSORS_MCP9808_REGNO_MFGID   6

Register index for manufacturer ID

#define BSP430_SENSORS_MCP9808_REGNO_RESOLUTION   8

Register index for device resolution (8-bit)

#define BSP430_SENSORS_MCP9808_REGNO_TA   5

Register index for temperature

#define BSP430_SENSORS_MCP9808_REGNO_TCRIT   4

Register index for critical temperature

#define BSP430_SENSORS_MCP9808_REGNO_TLOWER   3

Register index for alert lower boundary trip

#define BSP430_SENSORS_MCP9808_REGNO_TUPPER   2

Register index for alert upper boundary trip

#define BSP430_SENSORS_MCP9808_TEMP_CRIT   0x8000

Bit set in raw temperature to indicate measured temperature at or above configured critical temperature

#define BSP430_SENSORS_MCP9808_TEMP_HIGH   0x4000

Bit set in raw temperature to indicate measured temperature above configured upper bound temperature

#define BSP430_SENSORS_MCP9808_TEMP_LOW   0x2000

Bit set in raw temperature to indicate measured temperature below configured lower bound temperature

#define BSP430_SENSORS_MCP9808_TEMP_MASK   0x0FFF

Mask for temperature absolute value in Cel/16

#define BSP430_SENSORS_MCP9808_TEMP_SIGN   0x1000

Bit set in raw temperature to indicate negative temperatures

Function Documentation

static BSP430_CORE_INLINE int iBSP430sensorsMCP9808tempFromRaw_cK ( uint16_t  raw)
static

Convert a temperature value from the raw value Cel/16 to K/100.