See Quickstart guide for MCP980X module.
The module provides useful API of MCP980X temperature sensor through a TWI interface.
This driver depends on the following module:
Modules | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the MCP980X Temperature Sensor. | |
Macros | |
#define | MCP980X_CONF_REG (0x01) /* Configuration Register */ |
#define | MCP980X_DEC_UNIT (625) |
#define | MCP980X_HYST_REG (0x02) /* Temperature Hysteresis Register */ |
#define | MCP980X_LIMT_REG (0x03) /* Temperature Limit-set Register */ |
#define | MCP980X_TEMP_REG (0x00) /* Temperature Register */ |
#define | TWI_SPEED (400000ul) /* 400KHz TWI bus frequency */ |
Functions | |
uint32_t | mcp980x_disable (void) |
Disable the sensor. More... | |
uint32_t | mcp980x_enable (void) |
Enable the sensor. More... | |
uint32_t | mcp980x_get_configuration (uint8_t *p_config) |
Get MCP980X configuration. More... | |
uint32_t | mcp980x_get_temperature (int8_t *p_integer, uint32_t *p_decimal) |
Get ambient temperature. More... | |
uint32_t | mcp980x_get_temperature_hysteresis (int8_t *p_integer, uint32_t *p_decimal) |
Get temperature hysteresis. More... | |
uint32_t | mcp980x_get_temperature_limit (int8_t *p_integer, uint32_t *p_decimal) |
Get temperature limit. More... | |
static void | mcp980x_hex_to_temperature_dec (uint8_t uc_hex, uint32_t *p_decimal) |
Convert hexadecimal value to decimal part of temperature. More... | |
static void | mcp980x_hex_to_temperature_int (uint8_t uc_hex, int8_t *p_integer) |
Convert hexadecimal value to integer part of temperature. More... | |
uint32_t | mcp980x_init (void) |
Init the sensor. More... | |
static uint32_t | mcp980x_interface_init (void) |
Initialize the hardware interface to the controller. More... | |
uint32_t | mcp980x_one_shot_mode (void) |
Enable One-Shot mode and perform a single temperature measure. More... | |
static uint32_t | mcp980x_read_register (uint32_t ul_reg_index, uint8_t *p_reg_value) |
Read the MCP980X register specified by ul_reg_index. More... | |
uint32_t | mcp980x_set_configuration (uint8_t uc_config) |
Set MCP980X configuration. More... | |
uint32_t | mcp980x_set_temperature_hysteresis (int8_t c_integer, uint32_t ul_decimal) |
Set temperature hysteresis. More... | |
uint32_t | mcp980x_set_temperature_limit (int8_t c_integer, uint32_t ul_decimal) |
Set temperature limit. More... | |
static void | mcp980x_temperature_to_hex_dec (uint32_t ul_decimal, uint8_t *p_hex) |
Convert decimal part of temperature to hexadecimal value. More... | |
static void | mcp980x_temperature_to_hex_int (int8_t c_integer, uint8_t *p_hex) |
Convert integer part of temperature to hexadecimal value. More... | |
static uint32_t | mcp980x_write_register (uint32_t ul_reg_index, uint8_t *p_reg_value) |
Write the MCP980X register specified by ul_reg_index. More... | |
#define MCP980X_CONF_REG (0x01) /* Configuration Register */ |
#define MCP980X_DEC_UNIT (625) |
Referenced by mcp980x_hex_to_temperature_dec(), and mcp980x_temperature_to_hex_dec().
#define MCP980X_HYST_REG (0x02) /* Temperature Hysteresis Register */ |
Referenced by mcp980x_get_temperature_hysteresis(), and mcp980x_set_temperature_hysteresis().
#define MCP980X_LIMT_REG (0x03) /* Temperature Limit-set Register */ |
Referenced by mcp980x_get_temperature_limit(), and mcp980x_set_temperature_limit().
#define MCP980X_TEMP_REG (0x00) /* Temperature Register */ |
Referenced by mcp980x_get_temperature().
#define TWI_SPEED (400000ul) /* 400KHz TWI bus frequency */ |
Referenced by mcp980x_interface_init().
uint32_t mcp980x_disable | ( | void | ) |
Disable the sensor.
References MCP980X_CONF_REG, MCP980X_CONFIG_SHUTDOWN_ENABLE, mcp980x_read_register(), mcp980x_write_register(), and TWI_SUCCESS.
Referenced by mcp980x_one_shot_mode().
uint32_t mcp980x_enable | ( | void | ) |
Enable the sensor.
References MCP980X_CONF_REG, MCP980X_CONFIG_SHUTDOWN_ENABLE, mcp980x_read_register(), mcp980x_write_register(), and TWI_SUCCESS.
uint32_t mcp980x_get_configuration | ( | uint8_t * | p_config | ) |
Get MCP980X configuration.
p_config | Pointer to the configuration of sensor. |
References MCP980X_CONF_REG, and mcp980x_read_register().
Referenced by mcp980x_one_shot_mode().
uint32_t mcp980x_get_temperature | ( | int8_t * | p_integer, |
uint32_t * | p_decimal | ||
) |
Get ambient temperature.
p_integer | Pointer to the integer part of ambient temperature in degree Celsius. |
p_decimal | Pointer to the decimal part of ambient temperature in 10 ^ -4 degree Celsius. |
References mcp980x_hex_to_temperature_dec(), mcp980x_hex_to_temperature_int(), mcp980x_read_register(), MCP980X_TEMP_REG, and TWI_SUCCESS.
uint32_t mcp980x_get_temperature_hysteresis | ( | int8_t * | p_integer, |
uint32_t * | p_decimal | ||
) |
Get temperature hysteresis.
p_integer | Pointer to the integer part of temperature hysteresis in degree Celsius. |
p_decimal | Pointer to the decimal part of temperature hysteresis in 10 ^ -4 degree Celsius. |
References mcp980x_hex_to_temperature_dec(), mcp980x_hex_to_temperature_int(), MCP980X_HYST_REG, mcp980x_read_register(), and TWI_SUCCESS.
uint32_t mcp980x_get_temperature_limit | ( | int8_t * | p_integer, |
uint32_t * | p_decimal | ||
) |
Get temperature limit.
p_integer | Pointer to the integer part of temperature limit in degree Celsius. |
p_decimal | Pointer to the decimal part of temperature limit in 10 ^ -4 degree Celsius. |
References mcp980x_hex_to_temperature_dec(), mcp980x_hex_to_temperature_int(), MCP980X_LIMT_REG, mcp980x_read_register(), and TWI_SUCCESS.
|
static |
Convert hexadecimal value to decimal part of temperature.
uc_hex | The hexadecimal value. |
p_decimal | Pointer to the decimal part of temperature. |
References MCP980X_DEC_UNIT.
Referenced by mcp980x_get_temperature(), mcp980x_get_temperature_hysteresis(), and mcp980x_get_temperature_limit().
|
static |
Convert hexadecimal value to integer part of temperature.
uc_hex | The hexadecimal value. |
p_integer | Pointer to the integer part of temperature. |
Referenced by mcp980x_get_temperature(), mcp980x_get_temperature_hysteresis(), and mcp980x_get_temperature_limit().
uint32_t mcp980x_init | ( | void | ) |
|
static |
Initialize the hardware interface to the controller.
This will initialize the module used for communication with the controller. Currently supported interface by this driver is the TWI module in master mode.
References BOARD_MCP980X_ADDR, BOARD_MCP980X_TWI_INSTANCE, twi_options::speed, twi_master_setup(), and TWI_SPEED.
Referenced by mcp980x_init().
uint32_t mcp980x_one_shot_mode | ( | void | ) |
Enable One-Shot mode and perform a single temperature measure.
References MCP980X_CONFIG_ONE_SHOT_ENABLE, MCP980X_CONFIG_SHUTDOWN_ENABLE, mcp980x_disable(), mcp980x_get_configuration(), mcp980x_set_configuration(), and TWI_SUCCESS.
|
static |
Read the MCP980X register specified by ul_reg_index.
ul_reg_index | The index of MCP980X register. |
p_reg_value | Pointer to the value read from the specified MCP980X register. |
References BOARD_MCP980X_ADDR, BOARD_MCP980X_TWI_INSTANCE, twi_packet::chip, twi_packet::length, MCP980X_CONF_REG, and twi_master_read().
Referenced by mcp980x_disable(), mcp980x_enable(), mcp980x_get_configuration(), mcp980x_get_temperature(), mcp980x_get_temperature_hysteresis(), and mcp980x_get_temperature_limit().
uint32_t mcp980x_set_configuration | ( | uint8_t | uc_config | ) |
Set MCP980X configuration.
uc_config | The configuration of sensor. |
References MCP980X_CONF_REG, and mcp980x_write_register().
Referenced by mcp980x_one_shot_mode().
uint32_t mcp980x_set_temperature_hysteresis | ( | int8_t | c_integer, |
uint32_t | ul_decimal | ||
) |
Set temperature hysteresis.
c_integer | The integer part of temperature hysteresis in degree Celsius. |
ul_decimal | The decimal part of temperature hysteresis in 10 ^ -4 degree Celsius. |
References MCP980X_HYST_REG, mcp980x_temperature_to_hex_dec(), mcp980x_temperature_to_hex_int(), and mcp980x_write_register().
uint32_t mcp980x_set_temperature_limit | ( | int8_t | c_integer, |
uint32_t | ul_decimal | ||
) |
Set temperature limit.
c_integer | The integer part of temperature limit in degree Celsius. |
ul_decimal | The decimal part of temperature limit in 10 ^ -4 degree Celsius. |
References MCP980X_LIMT_REG, mcp980x_temperature_to_hex_dec(), mcp980x_temperature_to_hex_int(), and mcp980x_write_register().
|
static |
Convert decimal part of temperature to hexadecimal value.
ul_decimal | The decimal part of temperature. |
p_hex | Pointer to the hexadecimal value. |
References MCP980X_DEC_UNIT.
Referenced by mcp980x_set_temperature_hysteresis(), and mcp980x_set_temperature_limit().
|
static |
Convert integer part of temperature to hexadecimal value.
c_integer | The integer part of temperature. |
p_hex | Pointer to the hexadecimal value. |
Referenced by mcp980x_set_temperature_hysteresis(), and mcp980x_set_temperature_limit().
|
static |
Write the MCP980X register specified by ul_reg_index.
ul_reg_index | The index of MCP980X register. |
p_reg_value | Pointer to the value to be written to the specified MCP980X register. |
References BOARD_MCP980X_ADDR, BOARD_MCP980X_TWI_INSTANCE, twi_packet::chip, twi_packet::length, MCP980X_CONF_REG, and twi_master_write().
Referenced by mcp980x_disable(), mcp980x_enable(), mcp980x_set_configuration(), mcp980x_set_temperature_hysteresis(), and mcp980x_set_temperature_limit().