4 I2C Temp Sensor MCP98xx Driver
Driver library for the MCP98xx line of Temperature Sensors using the I2C protocol
4.1 Introduction
The MPLAB® Code Configurator Melody I2C Temp Sensor MCP98xx Library allows quick and easy configuration and code generation for temperature reading applications. This library enables microcontrollers to interface with the MCP98xx Temperature Sensor family using the I2C protocol.
4.2 Supported Device Families
PIC16F | PIC18F | tiny AVR | AVR |
4.3 Required Header Files:
#include "mcc_generated_files/temperature-mcp98xx/mcp9808.h"
4.4 I2C Temp Sensor MCP98xx Driver Documentation
4.4.1 Module Documentation
4.4.1.1 MCP9808
4.4.1.1.1 Module description
This contains the MCP9808 API prototypes and other data types for the MCP9808 driver.
Data structures
struct MCP9808
An instance of MCP98XX_INTERFACE_t for the MCP98xx driver.
struct MCP9808_INITIAL_CONFIG
An instance of MCP98XX_DEVICE_INIT for the MCP98xx driver.
Enumerations
enum _MCP9808_DEVICE_INFORMATION_t { MANUFACTURER_ID = 1U, DEVICE_ID = 2U, DEVICE_REVISION = 3U }
Enumeration of the MCP9808 device information.
Functions
int16_t MCP9808_TemperatureCelsiusToRawValue (float tempVal)
Converts the temperature value from Celsius to raw value.
void MCP9808_SensorConfigBufferSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Performs byte arrangements for the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_Initialize (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_DEVICE_INIT_t deviceInit)
Initializes the MCP9808 Temperature Sensor driver.
MCP9808_STATUS_t MCP9808_SensorConfigSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_CONFIG_REG_t sensorConfigReg)
Sets the configuration of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_SensorConfigGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_CONFIG_REG_PTR sensorConfigVal)
Gets the configuration of the MCP9808 Temperature Sensor and updates the structure containing the Sensor Configuration register settings.
MCP9808_STATUS_t MCP9808_TemperatureHysteresisSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_HYSTERESIS_VALUE_t tempHysteresisVal)
Sets the Temperature Hysteresis of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_ShutdownModeEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Shutdown mode feature of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_ShutdownModeDisable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Disables the Shutdown mode feature of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureCriticalLockEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Critical Lock bit of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureWindowLockEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Window Lock bit of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AlertOutputClear (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Clears the Alert output interrupt of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AlertOutputStatusRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, bool *alertStat)
Reads the Alert output status from the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AlertConfigurationSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_ALERT_CONFIG_t alertConfig, uint8_t alertSet)
Sets the Alert configuration of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureBoundarySet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_TEMP_BOUNDARY_t boundary, float tempVal)
Sets the user-specified temperature boundary for the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureBoundaryGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_TEMP_BOUNDARY_t boundary, float *tempVal)
Gets the temperature boundary value from the Temperature Boundary registers of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureRawValueRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, uint16_t *tempRawVal)
Reads the temperature sensor value from the Ambient Temperature register of the MCP9808 Temperature Sensor.
float MCP9808_TemperatureRawToCelsius (uint16_t rawVal)
Converts the temperature raw value to Celsius.
float MCP9808_TemperatureRawToFahrenheit (uint16_t rawVal)
Converts the temperature raw value to Fahrenheit.
MCP9808_STATUS_t MCP9808_AmbientTemperatureCelsiusRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, float *ambientTemp)
Reads the temperature sensor value in Celsius from the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AmbientTemperatureFahrenheitRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, float *ambientTemp)
Reads the temperature sensor value in Fahrenheit from the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TempResolutionSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_RESOLUTION_VALUE_t tempResolution)
Sets the temperature conversion resolution of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TempResolutionGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, uint8_t *tempResolutionVal)
Gets the temperature conversion resolution of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_DeviceInfoGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_DEVICE_INFORMATION_t deviceInfo, uint16_t *deviceInfoVal)
Sets the temperature conversion resolution of the MCP9808 Temperature Sensor.
float MCP9808_CelsiusToFahrenheit (float tempVal)
Converts the temperature value from Celsius to Fahrenheit.
float MCP9808_FahrenheitToCelsius (float tempVal)
Converts the temperature value from Fahrenheit to Celsius.
4.4.1.1.2 Function Documentation
MCP9808_AlertConfigurationSet()
MCP9808_STATUS_t MCP9808_AlertConfigurationSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_ALERT_CONFIG_t alertConfig, uint8_t alertSet)
Sets the Alert configuration of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP9808_ALERT_CONFIG_t |
alertConfig - One of the enumerated Alert Configuration from MCP98XX_ALERT_CONFIG. |
uint8_t |
alertSet - Desired state of the Alert setting. |
MCP98XX status code. |
MCP9808_AlertOutputClear()
MCP9808_STATUS_t MCP9808_AlertOutputClear (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Clears the Alert output interrupt of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP98XX status code. |
MCP9808_AlertOutputStatusRead()
MCP9808_STATUS_t MCP9808_AlertOutputStatusRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, bool * alertStat)
Reads the Alert output status from the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
bool* |
alertStat - Pointer to a user-defined variable where the Alert output data is to be stored. |
MCP98XX status code. |
MCP9808_AmbientTemperatureCelsiusRead()
MCP9808_STATUS_t MCP9808_AmbientTemperatureCelsiusRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, float * ambientTemp)
Reads the temperature sensor value in Celsius from the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
float* |
ambientTemp - Pointer to a user-defined variable where the Ambient Temperature in Celsius is to be stored. |
MCP98XX status code. |
MCP9808_AmbientTemperatureFahrenheitRead()
MCP9808_STATUS_t MCP9808_AmbientTemperatureFahrenheitRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, float * ambientTemp)
Reads the temperature sensor value in Fahrenheit from the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
float* |
ambientTemp - Pointer to a user-defined variable where the Ambient Temperature in Fahrenheit is to be stored. |
MCP98XX status code. |
MCP9808_CelsiusToFahrenheit()
float MCP9808_CelsiusToFahrenheit (float tempVal)
Converts the temperature value from Celsius to Fahrenheit.
float |
tempVal - Temperature value to be converted. |
Converted value. |
MCP9808_DeviceInfoGet()
MCP9808_STATUS_t MCP9808_DeviceInfoGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_DEVICE_INFORMATION_t deviceInfo, uint16_t * deviceInfoVal)
Sets the temperature conversion resolution of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP9808_DEVICE_INFORMATION_t |
deviceInfo - One of the enumerated value. |
uint16_t* |
deviceInfoVal - Pointer to a user-defined variable where the device information is to be stored. |
MCP98XX status code. |
MCP9808_FahrenheitToCelsius()
float MCP9808_FahrenheitToCelsius (float tempVal)
Converts the temperature value from Fahrenheit to Celsius.
float |
tempVal - Temperature value to be converted. |
Converted value. |
MCP9808_Initialize()
MCP9808_STATUS_t MCP9808_Initialize (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_DEVICE_INIT_t deviceInit)
Initializes the MCP9808 Temperature Sensor driver.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP9808_DEVICE_INIT_t |
deviceInit - An instance of MCP98XX_DEVICE_INIT. |
MCP98XX status code. |
MCP9808_SensorConfigBufferSet()
void MCP9808_SensorConfigBufferSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Performs byte arrangements for the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP9808_DEVICE_CONTEXT_t. |
None. |
MCP9808_SensorConfigGet()
MCP9808_STATUS_t MCP9808_SensorConfigGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_CONFIG_REG_PTR sensorConfigVal)
Gets the configuration of the MCP9808 Temperature Sensor and updates the structure containing the Sensor Configuration register settings.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP9808_CONFIG_REG_PTR |
sensorConfigVal - Pointer to an instance of MCP98XX_SENSOR_CONFIG_REG. |
MCP98XX status code. |
MCP9808_SensorConfigSet()
MCP9808_STATUS_t MCP9808_SensorConfigSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_CONFIG_REG_t sensorConfigReg)
Sets the configuration of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP9808_CONFIG_REG_t |
sensorConfigReg - An instance of MCP98XX_SENSOR_CONFIG_REG. |
MCP98XX status code. |
MCP9808_ShutdownModeDisable()
MCP9808_STATUS_t MCP9808_ShutdownModeDisable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Disables the Shutdown mode feature of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP98XX status code. |
MCP9808_ShutdownModeEnable()
MCP9808_STATUS_t MCP9808_ShutdownModeEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Shutdown mode feature of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP98XX status code. |
MCP9808_TemperatureBoundaryGet()
MCP9808_STATUS_t MCP9808_TemperatureBoundaryGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_TEMP_BOUNDARY_t boundary, float * tempVal)
Gets the temperature boundary value from the Temperature Boundary registers of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP9808_TEMP_BOUNDARY_t |
boundary - One of the enumerated Temperature Boundary registers from MCP98XX_TEMP_BOUNDARY. |
float* |
tempVal - Pointer to a user-defined variable where the Temperature Boundary data is to be stored. |
MCP98XX status code. |
MCP9808_TemperatureBoundarySet()
MCP9808_STATUS_t MCP9808_TemperatureBoundarySet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_TEMP_BOUNDARY_t boundary, float tempVal)
Sets the user-specified temperature boundary for the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP9808_TEMP_BOUNDARY_t |
boundary - One of the enumerated Temperature Boundary registers from MCP98XX_TEMP_BOUNDARY. |
uint8_t |
alertSet - Temperature value in Celsius. |
MCP98XX status code. |
MCP9808_TemperatureCelsiusToRawValue()
int16_t MCP9808_TemperatureCelsiusToRawValue (float tempVal)
Converts the temperature value from Celsius to raw value.
float |
tempVal - Temperature value in Celsius to be converted. |
Signed temperature raw value. |
MCP9808_TemperatureCriticalLockEnable()
MCP9808_STATUS_t MCP9808_TemperatureCriticalLockEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Critical Lock bit of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP98XX status code. |
MCP9808_TemperatureHysteresisSet()
MCP9808_STATUS_t MCP9808_TemperatureHysteresisSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_HYSTERESIS_VALUE_t tempHysteresisVal)
Sets the Temperature Hysteresis of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP9808_HYSTERESIS_VALUE_t |
tempHysteresisVal - One of the enumerated hysteresis values from MCP98XX_HYSTERESIS_VALUE. |
MCP98XX status code. |
MCP9808_TemperatureRawToCelsius()
float MCP9808_TemperatureRawToCelsius (uint16_t rawVal)
Converts the temperature raw value to Celsius.
uint16_t |
rawVal - Raw value to be converted. |
Temperature value in Celsius. |
MCP9808_TemperatureRawToFahrenheit()
float MCP9808_TemperatureRawToFahrenheit (uint16_t rawVal)
Converts the temperature raw value to Fahrenheit.
uint16_t |
rawVal - Raw value to be converted. |
Temperature value in Fahrenheit. |
MCP9808_TemperatureRawValueRead()
MCP9808_STATUS_t MCP9808_TemperatureRawValueRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, uint16_t * tempRawVal)
Reads the temperature sensor value from the Ambient Temperature register of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
uint16_t* |
tempRawVal - Pointer to a user-defined variable where the raw value data is to be stored. |
MCP98XX status code. |
MCP9808_TemperatureWindowLockEnable()
MCP9808_STATUS_t MCP9808_TemperatureWindowLockEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Window Lock bit of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP98XX status code. |
MCP9808_TempResolutionGet()
MCP9808_STATUS_t MCP9808_TempResolutionGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, uint8_t * tempResolutionVal)
Gets the temperature conversion resolution of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
uint8_t* |
tempResolutionVal - Pointer to a user-defined variable where the Temperature Resolution data is to be stored. |
MCP98XX status code. |
MCP9808_TempResolutionSet()
MCP9808_STATUS_t MCP9808_TempResolutionSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_RESOLUTION_VALUE_t tempResolution)
Sets the temperature conversion resolution of the MCP9808 Temperature Sensor.
MCP9808_DEVICE_CONTEXT_PTR |
devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT. |
MCP9808_RESOLUTION_VALUE_t |
tempResolution - One of the enumerated Temperature Resolution value from MCP98XX_RESOLUTION_VALUE. |
MCP98XX status code. |
4.4.1.1.3 Enumeration Type Documentation
_MCP9808_DEVICE_INFORMATION_t
enum _MCP9808_DEVICE_INFORMATION_t
Enumeration of the MCP9808 device information.
MANUFACTURER_ID | |
DEVICE_ID | |
DEVICE_REVISION |
4.4.1.2 MCP9808_I2C
This contains the API prototypes for the MCP9808 I2C Protocol.
4.4.1.2.1 Module description
This contains the API prototypes for the MCP9808 I2C Protocol.
To ensure that the C driver runs properly, it is not advised to modify the I2C API prototypes. Refer to mcp9808_i2c.c to configure the I2C interface implementation.
Functions
uint8_t MCP9808_Write (uint16_t address, uint8_t *data, size_t dataLength)
Writes data to the MCP9808 Temperature Sensor using the I2C protocol.
uint8_t MCP9808_Read (uint16_t address, uint8_t *registerAddress, size_t addressLength, uint8_t *readData, size_t readLength)
Writes the register address pointer from the registerAddress to the bus and reads data from the MCP9808 Temperature Sensor using the I2C protocol, and then stores the received data in the readData.
4.4.1.2.2 Function Documentation
MCP9808_Read()
uint8_t MCP9808_Read (uint16_t address, uint8_t * registerAddress, size_t addressLength, uint8_t * readData, size_t readLength)
Writes the register address pointer from the registerAddress to the bus and reads data from the MCP9808 Temperature Sensor using the I2C protocol, and then stores the received data in the readData.
uint16_t |
address - 7-bit/10-bit Client address. |
uint8_t |
*registerAddress - Pointer to write data buffer. |
size_t |
addressLength - Write data length in bytes. |
uint8_t |
*readData - Pointer to read data buffer. |
size_t |
readLength - Read data length in bytes. |
MCP9808 I2C status code. |
MCP9808_Write()
uint8_t MCP9808_Write (uint16_t address, uint8_t * data, size_t dataLength)
Writes data to the MCP9808 Temperature Sensor using the I2C protocol.
uint16_t |
address - 7-bit/10-bit Client address. |
uint8_t |
*data - Pointer to source data buffer that contains the data to be transmitted. |
size_t |
dataLength - Length of data buffer in number of bytes. Also the number of bytes to be written. |
MCP9808 I2C status code. |
4.4.1.3 MCP98XX
This contains the APIs for the MCP98xx driver interface.
4.4.1.3.1 Module description
This contains the APIs for the MCP98xx driver interface.
Data structures
struct MCP98XX_INTERFACE_t
Structure containing the function pointers to the MCP98xx driver APIs.
struct MCP98XX_DEVICE_INIT
Structure containing the MCP98xx driver registers to be initialized.
struct MCP98XX_DEVICE_INFO
Structure containing the MCP98xx driver information.
struct MCP98XX_SENSOR_CONFIG_REG
Structure containing the MCP98xx driver Sensor Configuration bit register settings.
struct MCP98XX_DEVICE_CONTEXT
Structure containing the MCP98xx driver context that can be used in the processes.
Enumerations
enum MCP98XX_STATUS { MCP98XX_NO_ERROR = 0U, MCP98XX_ERROR = 1U, MCP98XX_COMMUNICATION_ERROR = 16U, MCP98XX_INVALID_DEVICE_INFO = 100U, MCP98XX_INVALID_RESOLUTION_VALUE = 101U, MCP98XX_INVALID_TEMP_VALUE = 102U, MCP98XX_INVALID_ALERT_CONFIG = 103U, MCP98XX_INVALID_PARAMETER = 104U, MCP98XX_NULL_POINTER = 105U, MCP98XX_NOT_ASSERTED = 10U, MCP98XX_LOWER_TEMP_ASSERTED = 2U, MCP98XX_UPPER_TEMP_ASSERTED = 4U, MCP98XX_CRIT_TEMP_ASSERTED = 8U }
Enumeration of the MCP98xx driver status codes.
enum MCP98XX_TEMP_BOUNDARY { LOWER_BOUNDARY = 1U, UPPER_BOUNDARY = 2U, CRITICAL_BOUNDARY = 3U }
Enumeration of the user-configurable temperature boundaries that is used as a parameter for setting the boundaries.
enum MCP98XX_ALERT_CONFIG { ALERT_OUTPUT_CLEAR = 1U, ALERT_CONTROL = 2U, ALERT_SELECT = 3U, ALERT_POLARITY = 4U, ALERT_MODE = 5U }
Enumeration of the user-configurable Alert output setting that is used as a parameter for setting the Alert configuration.
enum MCP98XX_HYSTERESIS_VALUE { HYSTERESIS_0, HYSTERESIS_1_5, HYSTERESIS_3, HYSTERESIS_6 }
Enumeration of the possible Temperature Hysteresis values.
enum MCP98XX_RESOLUTION_VALUE { RESOLUTION_0_5, RESOLUTION_0_25, RESOLUTION_0_125, RESOLUTION_0_0625 }
Enumeration of the possible Temperature Resolution values.
4.4.1.3.2 Enumeration Type Documentation
MCP98XX_ALERT_CONFIG
enum MCP98XX_ALERT_CONFIG
Enumeration of the user-configurable Alert output setting that is used as a parameter for setting the Alert configuration.
ALERT_OUTPUT_CLEAR | |
ALERT_CONTROL | |
ALERT_SELECT | |
ALERT_POLARITY | |
ALERT_MODE |
MCP98XX_HYSTERESIS_VALUE
enum MCP98XX_HYSTERESIS_VALUE
Enumeration of the possible Temperature Hysteresis values.
HYSTERESIS_0 |
Used as a parameter when setting the Temperature Hysteresis to 0 C |
HYSTERESIS_1_5 |
Used as a parameter when setting the Temperature Hysteresis to 1.5 C |
HYSTERESIS_3 |
Used as a parameter when setting the Temperature Hysteresis to 3 C |
HYSTERESIS_6 |
Used as a parameter when setting the Temperature Hysteresis to 6 C |
MCP98XX_RESOLUTION_VALUE
enum MCP98XX_RESOLUTION_VALUE
Enumeration of the possible Temperature Resolution values.
RESOLUTION_0_5 |
Used as a parameter when setting the Temperature Conversion Resolution to +0.5 C |
RESOLUTION_0_25 |
Used as a parameter when setting the Temperature Conversion Resolution to +0.25 C |
RESOLUTION_0_125 |
Used as a parameter when setting the Temperature Conversion Resolution to +0.125 C |
RESOLUTION_0_0625 |
Used as a parameter when setting the Temperature Conversion Resolution to +0.0625 C |
MCP98XX_STATUS
enum MCP98XX_STATUS
Enumeration of the MCP98xx driver status codes.
MCP98XX_NO_ERROR |
Returned value when there is no error encountered. |
MCP98XX_ERROR |
Returned value when there is an error encountered. |
MCP98XX_COMMUNICATION_ERROR |
Returned value when there is an error on the serial interface communication. |
MCP98XX_INVALID_DEVICE_INFO |
Returned value for invalid parameter in getting the device information. |
MCP98XX_INVALID_RESOLUTION_VALUE |
Returned value for invalid parameter in setting the Temperature Conversion Resolution. |
MCP98XX_INVALID_TEMP_VALUE |
Returned value for invalid temperature boundary inputs. |
MCP98XX_INVALID_ALERT_CONFIG |
Returned value for invalid parameter in setting the alert configuration. |
MCP98XX_INVALID_PARAMETER |
Returned value for invalid parameter. |
MCP98XX_NULL_POINTER |
Returned value for Null pointer. |
MCP98XX_NOT_ASSERTED |
Returned value in the Ambient Temperature reading when an Alert output is not asserted by the device. |
MCP98XX_LOWER_TEMP_ASSERTED |
Returned value in the Ambient Temperature reading when an Alert output is triggered by the Lower temperature boundary. |
MCP98XX_UPPER_TEMP_ASSERTED |
Returned value in the Ambient Temperature reading when an Alert output is triggered by the Upper temperature boundary. |
MCP98XX_CRIT_TEMP_ASSERTED |
Returned value in the Ambient Temperature reading when an Alert output is triggered by the Critical temperature boundary. |
MCP98XX_TEMP_BOUNDARY
enum MCP98XX_TEMP_BOUNDARY
Enumeration of the user-configurable temperature boundaries that is used as a parameter for setting the boundaries.
LOWER_BOUNDARY | |
UPPER_BOUNDARY | |
CRITICAL_BOUNDARY |
4.4.2 Data Structure Documentation
4.4.2.1 MCP9808 Struct Reference
An instance of MCP98XX_INTERFACE_t for the MCP98xx driver.
4.4.2.1.1 Detailed Description
An instance of MCP98XX_INTERFACE_t for the MCP98xx driver.
#include <mcp9808.h>
The documentation for this struct was generated from the following file:
source/
4.4.2.2 MCP9808_INITIAL_CONFIG Struct Reference
An instance of MCP98XX_DEVICE_INIT for the MCP98xx driver.
4.4.2.2.1 Detailed Description
An instance of MCP98XX_DEVICE_INIT for the MCP98xx driver.
#include <mcp9808.h>
The documentation for this struct was generated from the following file:
source/
4.4.2.3 MCP98XX_DEVICE_CONTEXT Struct Reference
Structure containing the MCP98xx driver context that can be used in the processes.
4.4.2.3.1 Detailed Description
Structure containing the MCP98xx driver context that can be used in the processes.
#include <mcp98xx_types.h>
Data Fields
uint16_t i2cAddress
float tempUpperLimit
float tempLowerLimit
float tempCritLimit
uint8_t rxBuffer [2]
uint8_t tempResolution
uint8_t txBuffer [3]
4.4.2.3.2 Field Documentation
deviceInfo
MCP98XX_DEVICE_INFO_t deviceInfo
i2cAddress
uint16_t i2cAddress
rxBuffer
uint8_t rxBuffer[2]
sensorConfigReg
MCP98XX_CONFIG_REG_t sensorConfigReg
tempCritLimit
float tempCritLimit
tempLowerLimit
float tempLowerLimit
tempResolution
uint8_t tempResolution
tempUpperLimit
float tempUpperLimit
txBuffer
uint8_t txBuffer[3]
4.4.2.4 MCP98XX_DEVICE_INFO Struct Reference
Structure containing the MCP98xx driver information.
4.4.2.4.1 Detailed Description
Structure containing the MCP98xx driver information.
#include <mcp98xx_types.h>
Data Fields
uint16_t manufacturerId
uint8_t deviceId
uint8_t deviceRevision
4.4.2.4.2 Field Documentation
deviceId
uint8_t deviceId
deviceRevision
uint8_t deviceRevision
manufacturerId
uint16_t manufacturerId
4.4.2.5 MCP98XX_DEVICE_INIT Struct Reference
Structure containing the MCP98xx driver registers to be initialized.
4.4.2.5.1 Detailed Description
Structure containing the MCP98xx driver registers to be initialized.
#include <mcp98xx_types.h>
Data Fields
uint16_t i2cAddress
bool shutdownMode
uint8_t tempResolution
uint8_t tempHysteresis
float tempUpperBoundary
float tempLowerBoundary
float tempCritBoundary
bool critLock
bool winLock
bool alertClear
bool alertControl
bool alertSelect
bool alertMode
bool alertPolarity
4.4.2.5.2 Field Documentation
alertClear
bool alertClear
alertControl
bool alertControl
alertMode
bool alertMode
alertPolarity
bool alertPolarity
alertSelect
bool alertSelect
critLock
bool critLock
i2cAddress
uint16_t i2cAddress
shutdownMode
bool shutdownMode
tempCritBoundary
float tempCritBoundary
tempHysteresis
uint8_t tempHysteresis
tempLowerBoundary
float tempLowerBoundary
tempResolution
uint8_t tempResolution
tempUpperBoundary
float tempUpperBoundary
winLock
bool winLock
4.4.2.6 MCP98XX_INTERFACE_t Struct Reference
Structure containing the function pointers to the MCP98xx driver APIs.
4.4.2.6.1 Detailed Description
Structure containing the function pointers to the MCP98xx driver APIs.
#include <mcp98xx_interface.h>
Data Fields
MCP98XX_STATUS_t(* Initialize )(MCP98XX_DEVICE_CONTEXT_PTR devicePtr, MCP98XX_DEVICE_INIT_t deviceInit)
MCP98XX_STATUS_t(* TempRead )(MCP98XX_DEVICE_CONTEXT_PTR devicePtr, uint16_t *tempRawVal)
4.4.2.6.2 Field Documentation
Initialize
MCP98XX_STATUS_t(* Initialize) (MCP98XX_DEVICE_CONTEXT_PTR devicePtr, MCP98XX_DEVICE_INIT_t deviceInit)
This is a pointer to the driver initializer function.
TempRead
MCP98XX_STATUS_t(* TempRead) (MCP98XX_DEVICE_CONTEXT_PTR devicePtr, uint16_t *tempRawVal)
This is a pointer to the function that reads the Ambient Temperature data.
4.4.2.7 MCP98XX_SENSOR_CONFIG_REG Struct Reference
Structure containing the MCP98xx driver Sensor Configuration bit register settings.
4.4.2.7.1 Detailed Description
Structure containing the MCP98xx driver Sensor Configuration bit register settings.
#include <mcp98xx_types.h>
Data Fields
uint8_t tempHysteresis
bool shutdownMode
bool critLock
bool winLock
bool alertClear
bool alertStat
bool alertControl
bool alertSelect
bool alertPolarity
bool alertMode
4.4.2.7.2 Field Documentation
alertClear
bool alertClear
alertControl
bool alertControl
alertMode
bool alertMode
alertPolarity
bool alertPolarity
alertSelect
bool alertSelect
alertStat
bool alertStat
critLock
bool critLock
shutdownMode
bool shutdownMode
tempHysteresis
uint8_t tempHysteresis
winLock
bool winLock
4.4.3 File Documentation
4.4.3.1 source/mcp9808.c File Reference
This contains the API implementation for the MCP9808 driver.
#include "../../temperature-mcp98xx/mcp9808.h" #include "../../temperature-mcp98xx/mcp9808_config.h"
4.4.3.1.1 Functions
int16_t MCP9808_TemperatureCelsiusToRawValue (float tempVal)
Converts the temperature value from Celsius to raw value.
void MCP9808_SensorConfigBufferSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Performs byte arrangements for the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_Initialize (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_DEVICE_INIT_t deviceInit)
Initializes the MCP9808 Temperature Sensor driver.
MCP9808_STATUS_t MCP9808_SensorConfigSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_CONFIG_REG_t sensorConfigReg)
Sets the configuration of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_SensorConfigGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_CONFIG_REG_PTR sensorConfigVal)
Gets the configuration of the MCP9808 Temperature Sensor and updates the structure containing the Sensor Configuration register settings.
MCP9808_STATUS_t MCP9808_TemperatureHysteresisSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_HYSTERESIS_VALUE_t tempHysteresisVal)
Sets the Temperature Hysteresis of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_ShutdownModeEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Shutdown mode feature of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_ShutdownModeDisable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Disables the Shutdown mode feature of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureCriticalLockEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Critical Lock bit of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureWindowLockEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Window Lock bit of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AlertOutputClear (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Clears the Alert output interrupt of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AlertOutputStatusRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, bool *alertStat)
Reads the Alert output status from the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AlertConfigurationSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_ALERT_CONFIG_t alertConfig, uint8_t alertSet)
Sets the Alert configuration of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureBoundarySet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_TEMP_BOUNDARY_t boundary, float tempVal)
Sets the user-specified temperature boundary for the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureBoundaryGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_TEMP_BOUNDARY_t boundary, float *tempVal)
Gets the temperature boundary value from the Temperature Boundary registers of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureRawValueRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, uint16_t *tempRawVal)
Reads the temperature sensor value from the Ambient Temperature register of the MCP9808 Temperature Sensor.
float MCP9808_TemperatureRawToCelsius (uint16_t rawVal)
Converts the temperature raw value to Celsius.
float MCP9808_TemperatureRawToFahrenheit (uint16_t rawVal)
Converts the temperature raw value to Fahrenheit.
MCP9808_STATUS_t MCP9808_AmbientTemperatureCelsiusRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, float *ambientTemp)
Reads the temperature sensor value in Celsius from the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AmbientTemperatureFahrenheitRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, float *ambientTemp)
Reads the temperature sensor value in Fahrenheit from the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TempResolutionSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_RESOLUTION_VALUE_t tempResolution)
Sets the temperature conversion resolution of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TempResolutionGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, uint8_t *tempResolutionVal)
Gets the temperature conversion resolution of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_DeviceInfoGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_DEVICE_INFORMATION_t deviceInfo, uint16_t *deviceInfoVal)
Sets the temperature conversion resolution of the MCP9808 Temperature Sensor.
float MCP9808_CelsiusToFahrenheit (float tempVal)
Converts the temperature value from Celsius to Fahrenheit.
float MCP9808_FahrenheitToCelsius (float tempVal)
Converts the temperature value from Fahrenheit to Celsius.
4.4.3.1.2 Variables
4.4.3.1.3 Detailed Description
4.4.3.1.4 Variable Documentation
MCP9808
const MCP98XX_INTERFACE_t MCP9808
Initial value:
= { .Initialize = MCP9808_Initialize, .TempRead = MCP9808_TemperatureRawValueRead, }
MCP9808_INITIAL_CONFIG
const MCP9808_DEVICE_INIT_t MCP9808_INITIAL_CONFIG
Initial value:
= { .i2cAddress = MCP9808_DEVICE_ADDRESS, .tempResolution = MCP9808_RESOLUTION_INIT, .tempUpperBoundary = MCP9808_UPPER_TEMP_BOUNDARY_INIT, .tempLowerBoundary = MCP9808_LOWER_TEMP_BOUNDARY_INIT, .tempCritBoundary = MCP9808_CRITICAL_TEMP_BOUNDARY_INIT, .tempHysteresis = MCP9808_HYSTERESIS_INIT, .shutdownMode = MCP9808_SHDN_MODE_INIT, .critLock = MCP9808_CRIT_LOCK_INIT, .winLock = MCP9808_WIN_LOCK_INIT, .alertClear = MCP9808_INT_CLEAR_INIT, .alertControl = MCP9808_ALERT_CNTRL_INIT, .alertSelect = MCP9808_ALERT_SEL_INIT, .alertMode = MCP9808_ALERT_MOD_INIT, .alertPolarity = MCP9808_ALERT_POL_INIT, }
4.4.3.2 source/mcp9808.h File Reference
#include <stdint.h> #include "../temperature-mcp98xx/mcp9808_i2c.h" #include "../temperature-mcp98xx/mcp98xx_interface.h"
4.4.3.2.1 Functions
MCP9808_STATUS_t MCP9808_Initialize (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_DEVICE_INIT_t deviceInit)
Initializes the MCP9808 Temperature Sensor driver.
MCP9808_STATUS_t MCP9808_SensorConfigSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_CONFIG_REG_t sensorConfigReg)
Sets the configuration of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_SensorConfigGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_CONFIG_REG_PTR sensorConfigVal)
Gets the configuration of the MCP9808 Temperature Sensor and updates the structure containing the Sensor Configuration register settings.
MCP9808_STATUS_t MCP9808_TemperatureHysteresisSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_HYSTERESIS_VALUE_t tempHysteresisVal)
Sets the Temperature Hysteresis of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_ShutdownModeEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Shutdown mode feature of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_ShutdownModeDisable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Disables the Shutdown mode feature of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureCriticalLockEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Critical Lock bit of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureWindowLockEnable (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Enables the Window Lock bit of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AlertOutputClear (MCP9808_DEVICE_CONTEXT_PTR devicePtr)
Clears the Alert output interrupt of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AlertOutputStatusRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, bool *alertStat)
Reads the Alert output status from the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AlertConfigurationSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_ALERT_CONFIG_t alertConfig, uint8_t alertSet)
Sets the Alert configuration of the Sensor Configuration register of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureBoundarySet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_TEMP_BOUNDARY_t boundary, float tempVal)
Sets the user-specified temperature boundary for the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureBoundaryGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_TEMP_BOUNDARY_t boundary, float *tempVal)
Gets the temperature boundary value from the Temperature Boundary registers of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TemperatureRawValueRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, uint16_t *tempRawVal)
Reads the temperature sensor value from the Ambient Temperature register of the MCP9808 Temperature Sensor.
float MCP9808_TemperatureRawToCelsius (uint16_t rawVal)
Converts the temperature raw value to Celsius.
float MCP9808_TemperatureRawToFahrenheit (uint16_t rawVal)
Converts the temperature raw value to Fahrenheit.
MCP9808_STATUS_t MCP9808_AmbientTemperatureCelsiusRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, float *ambientTemp)
Reads the temperature sensor value in Celsius from the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_AmbientTemperatureFahrenheitRead (MCP9808_DEVICE_CONTEXT_PTR devicePtr, float *ambientTemp)
Reads the temperature sensor value in Fahrenheit from the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TempResolutionSet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_RESOLUTION_VALUE_t tempResolution)
Sets the temperature conversion resolution of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_TempResolutionGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, uint8_t *tempResolutionVal)
Gets the temperature conversion resolution of the MCP9808 Temperature Sensor.
MCP9808_STATUS_t MCP9808_DeviceInfoGet (MCP9808_DEVICE_CONTEXT_PTR devicePtr, MCP9808_DEVICE_INFORMATION_t deviceInfo, uint16_t *deviceInfoVal)
Sets the temperature conversion resolution of the MCP9808 Temperature Sensor.
float MCP9808_CelsiusToFahrenheit (float tempVal)
Converts the temperature value from Celsius to Fahrenheit.
float MCP9808_FahrenheitToCelsius (float tempVal)
Converts the temperature value from Fahrenheit to Celsius.
4.4.3.2.2 Macros
Custom Driver Type Macros
Macros that are used to redefine the driver types:
4.4.3.2.3 MCC-Generated Macros
Macros used to initialize the MCP9808 driver:
#define MCP9808_DEVICE_ADDRESS (0x18U)
#define MCP9808_HYSTERESIS_INIT HYSTERESIS_0
#define MCP9808_UPPER_TEMP_BOUNDARY_INIT (0)
#define MCP9808_LOWER_TEMP_BOUNDARY_INIT (0)
#define MCP9808_CRITICAL_TEMP_BOUNDARY_INIT (0)
#define MCP9808_ALERT_CNTRL_INIT (0U)
#define MCP9808_ALERT_SEL_INIT (0U)
#define MCP9808_ALERT_POL_INIT (0U)
#define MCP9808_ALERT_MOD_INIT (0U)
#define MCP9808_WIN_LOCK_INIT (0U)
#define MCP9808_CRIT_LOCK_INIT (0U)
#define MCP9808_INT_CLEAR_INIT (1U)
#define MCP9808_SHDN_MODE_INIT (0U)
4.4.3.2.4 Typedefs
4.4.3.2.5 Enumerations
enum _MCP9808_DEVICE_INFORMATION_t { MANUFACTURER_ID = 1U, DEVICE_ID = 2U, DEVICE_REVISION = 3U }
Enumeration of the MCP9808 device information.
4.4.3.2.6 Variables
4.4.3.2.7 Detailed Description
MCP9808 Generated Driver API Header File.
4.4.3.2.8 Macro Definition Documentation
MCP9808_ALERT_CNTRL_INIT
#define MCP9808_ALERT_CNTRL_INIT (0U)
MCP9808_ALERT_CONFIG_t
#define MCP9808_ALERT_CONFIG_t MCP98XX_ALERT_CONFIG_t
MCP9808_ALERT_MOD_INIT
#define MCP9808_ALERT_MOD_INIT (0U)
MCP9808_ALERT_POL_INIT
#define MCP9808_ALERT_POL_INIT (0U)
MCP9808_ALERT_SEL_INIT
#define MCP9808_ALERT_SEL_INIT (0U)
MCP9808_CONFIG_REG_PTR
#define MCP9808_CONFIG_REG_PTR MCP98XX_CONFIG_REG_PTR
MCP9808_CONFIG_REG_t
#define MCP9808_CONFIG_REG_t MCP98XX_CONFIG_REG_t
MCP9808_CRIT_LOCK_INIT
#define MCP9808_CRIT_LOCK_INIT (0U)
MCP9808_CRITICAL_TEMP_BOUNDARY_INIT
#define MCP9808_CRITICAL_TEMP_BOUNDARY_INIT (0)
MCP9808_DEVICE_ADDRESS
#define MCP9808_DEVICE_ADDRESS (0x18U)
MCP9808_DEVICE_CONTEXT_PTR
#define MCP9808_DEVICE_CONTEXT_PTR MCP98XX_DEVICE_CONTEXT_PTR
MCP9808_DEVICE_CONTEXT_t
#define MCP9808_DEVICE_CONTEXT_t MCP98XX_DEVICE_CONTEXT_t
MCP9808_DEVICE_INFO_t
#define MCP9808_DEVICE_INFO_t MCP98XX_DEVICE_INFO_t
MCP9808_DEVICE_INIT_t
#define MCP9808_DEVICE_INIT_t MCP98XX_DEVICE_INIT_t
MCP9808_HYSTERESIS_INIT
#define MCP9808_HYSTERESIS_INIT HYSTERESIS_0
MCP9808_HYSTERESIS_VALUE_t
#define MCP9808_HYSTERESIS_VALUE_t MCP98XX_HYSTERESIS_VALUE_t
MCP9808_INT_CLEAR_INIT
#define MCP9808_INT_CLEAR_INIT (1U)
MCP9808_LOWER_TEMP_BOUNDARY_INIT
#define MCP9808_LOWER_TEMP_BOUNDARY_INIT (0)
MCP9808_RESOLUTION_INIT
#define MCP9808_RESOLUTION_INIT RESOLUTION_0_0625
MCP9808_RESOLUTION_VALUE_t
#define MCP9808_RESOLUTION_VALUE_t MCP98XX_RESOLUTION_VALUE_t
MCP9808_SHDN_MODE_INIT
#define MCP9808_SHDN_MODE_INIT (0U)
MCP9808_STATUS_t
#define MCP9808_STATUS_t MCP98XX_STATUS_t
MCP9808_TEMP_BOUNDARY_t
#define MCP9808_TEMP_BOUNDARY_t MCP98XX_TEMP_BOUNDARY_t
MCP9808_UPPER_TEMP_BOUNDARY_INIT
#define MCP9808_UPPER_TEMP_BOUNDARY_INIT (0)
MCP9808_WIN_LOCK_INIT
#define MCP9808_WIN_LOCK_INIT (0U)
4.4.3.2.9 Typedef Documentation
MCP9808_DEVICE_INFORMATION_t
typedef enum _MCP9808_DEVICE_INFORMATION_t MCP9808_DEVICE_INFORMATION_t
4.4.3.2.10 Variable Documentation
MCP9808
const MCP98XX_INTERFACE_t MCP9808
MCP9808_INITIAL_CONFIG
const MCP9808_DEVICE_INIT_t MCP9808_INITIAL_CONFIG
4.4.3.3 source/mcp9808_config.h File Reference
This contains macros for device-specific configuration.
4.4.3.3.1 Macros
Register Pointer Macros
MCP9808 Register Address pointers:
#define MCP9808_SENSOR_CONFIG_REG_PTR (0x01U)
#define MCP9808_UPPER_BOUNDARY_REG_PTR (0x02U)
#define MCP9808_LOWER_BOUNDARY_REG_PTR (0x03U)
#define MCP9808_CRITICAL_BOUNDARY_REG_PTR (0x04U)
#define MCP9808_AMBIENT_TEMP_REG_PTR (0x05U)
#define MCP9808_MANUFACTURERID_REG_PTR (0x06U)
#define MCP9808_DEVICE_ID_AND_REVISION_REG_PTR (0x07U)
#define MCP9808_RESOLUTION_REG_PTR (0x08U)
4.4.3.3.2 Ambient Temperature register Macros
Macros used for the Ambient Temperature reading process:
#define MCP9808_AMBIENT_TEMP_BIT_12 (0x1000U)
#define MCP9808_CRIT_TEMP_VS_AMBIENT_TEMP (0x8000U)
#define MCP9808_UPPER_TEMP_VS_AMBIENT_TEMP (0x4000U)
#define MCP9808_LOWER_TEMP_VS_AMBIENT_TEMP (0x2000U)
4.4.3.3.3 Mask Macros
Macros used in masking the MCP9808 registers:
#define MCP9808_SIGN_BIT_MASK (0x10U)
#define MCP9808_BOUNDARY_MASK (0xE000U)
#define MCP9808_UNUSED_BIT_MASK (0x1FFCU)
#define MCP9808_TEMP_HYSTERESIS_MASK (0x06U)
#define MCP9808_SHDN_MODE_MASK (0x01U)
#define MCP9808_CRIT_LOCK_MASK (0x80U)
#define MCP9808_WIN_LOCK_MASK (0x40U)
#define MCP9808_INT_CLEAR_MASK (0x20U)
#define MCP9808_ALERT_STAT_MASK (0x10U)
#define MCP9808_ALERT_CNTRL_MASK (0x08U)
#define MCP9808_ALERT_SEL_MASK (0x04U)
#define MCP9808_ALERT_POL_MASK (0x02U)
#define MCP9808_ALERT_MOD_MASK (0x01U)
4.4.3.3.4 Bit Position Macros
Macros that indicate the MCP9808 register bit positions:
#define MCP9808_TEMP_HYSTERESIS_POSITION (1U)
#define MCP9808_CRIT_LOCK_POSITION (7U)
#define MCP9808_WIN_LOCK_POSITION (6U)
#define MCP9808_INT_CLEAR_POSITION (5U)
#define MCP9808_ALERT_STAT_POSITION (4U)
#define MCP9808_ALERT_CNTRL_POSITION (3U)
#define MCP9808_ALERT_SEL_POSITION (2U)
#define MCP9808_ALERT_POL_POSITION (1U)
4.4.3.3.5 Generic Macros
Macros used in driver operation:
#define MCP9808_ENABLE_BIT (1U)
#define MCP9808_REGISTER_ADDRESS_LENGTH (1U)
4.4.3.3.6 Detailed Description
This contains macros for device-specific configuration.
MCP9808 Generated Driver Header File.
4.4.3.3.7 Macro Definition Documentation
MCP9808_ALERT_CNTRL_MASK
#define MCP9808_ALERT_CNTRL_MASK (0x08U)
MCP9808_ALERT_CNTRL_POSITION
#define MCP9808_ALERT_CNTRL_POSITION (3U)
MCP9808_ALERT_MOD_MASK
#define MCP9808_ALERT_MOD_MASK (0x01U)
MCP9808_ALERT_POL_MASK
#define MCP9808_ALERT_POL_MASK (0x02U)
MCP9808_ALERT_POL_POSITION
#define MCP9808_ALERT_POL_POSITION (1U)
MCP9808_ALERT_SEL_MASK
#define MCP9808_ALERT_SEL_MASK (0x04U)
MCP9808_ALERT_SEL_POSITION
#define MCP9808_ALERT_SEL_POSITION (2U)
MCP9808_ALERT_STAT_MASK
#define MCP9808_ALERT_STAT_MASK (0x10U)
MCP9808_ALERT_STAT_POSITION
#define MCP9808_ALERT_STAT_POSITION (4U)
MCP9808_AMBIENT_TEMP_BIT_12
#define MCP9808_AMBIENT_TEMP_BIT_12 (0x1000U)
MCP9808_AMBIENT_TEMP_REG_PTR
#define MCP9808_AMBIENT_TEMP_REG_PTR (0x05U)
MCP9808_BOUNDARY_MASK
#define MCP9808_BOUNDARY_MASK (0xE000U)
MCP9808_CRIT_LOCK_MASK
#define MCP9808_CRIT_LOCK_MASK (0x80U)
MCP9808_CRIT_LOCK_POSITION
#define MCP9808_CRIT_LOCK_POSITION (7U)
MCP9808_CRIT_TEMP_VS_AMBIENT_TEMP
#define MCP9808_CRIT_TEMP_VS_AMBIENT_TEMP (0x8000U)
MCP9808_CRITICAL_BOUNDARY_REG_PTR
#define MCP9808_CRITICAL_BOUNDARY_REG_PTR (0x04U)
MCP9808_DEVICE_ID_AND_REVISION_REG_PTR
#define MCP9808_DEVICE_ID_AND_REVISION_REG_PTR (0x07U)
MCP9808_ENABLE_BIT
#define MCP9808_ENABLE_BIT (1U)
MCP9808_INT_CLEAR_MASK
#define MCP9808_INT_CLEAR_MASK (0x20U)
MCP9808_INT_CLEAR_POSITION
#define MCP9808_INT_CLEAR_POSITION (5U)
MCP9808_LOWER_BOUNDARY_REG_PTR
#define MCP9808_LOWER_BOUNDARY_REG_PTR (0x03U)
MCP9808_LOWER_TEMP_VS_AMBIENT_TEMP
#define MCP9808_LOWER_TEMP_VS_AMBIENT_TEMP (0x2000U)
MCP9808_MANUFACTURERID_REG_PTR
#define MCP9808_MANUFACTURERID_REG_PTR (0x06U)
MCP9808_REGISTER_ADDRESS_LENGTH
#define MCP9808_REGISTER_ADDRESS_LENGTH (1U)
MCP9808_RESOLUTION_REG_PTR
#define MCP9808_RESOLUTION_REG_PTR (0x08U)
MCP9808_SENSOR_CONFIG_REG_PTR
#define MCP9808_SENSOR_CONFIG_REG_PTR (0x01U)
MCP9808_SHDN_MODE_MASK
#define MCP9808_SHDN_MODE_MASK (0x01U)
MCP9808_SIGN_BIT_MASK
#define MCP9808_SIGN_BIT_MASK (0x10U)
MCP9808_TEMP_HYSTERESIS_MASK
#define MCP9808_TEMP_HYSTERESIS_MASK (0x06U)
MCP9808_TEMP_HYSTERESIS_POSITION
#define MCP9808_TEMP_HYSTERESIS_POSITION (1U)
MCP9808_UNUSED_BIT_MASK
#define MCP9808_UNUSED_BIT_MASK (0x1FFCU)
MCP9808_UPPER_BOUNDARY_REG_PTR
#define MCP9808_UPPER_BOUNDARY_REG_PTR (0x02U)
MCP9808_UPPER_TEMP_VS_AMBIENT_TEMP
#define MCP9808_UPPER_TEMP_VS_AMBIENT_TEMP (0x4000U)
MCP9808_WIN_LOCK_MASK
#define MCP9808_WIN_LOCK_MASK (0x40U)
MCP9808_WIN_LOCK_POSITION
#define MCP9808_WIN_LOCK_POSITION (6U)
4.4.3.4 source/mcp9808_i2c.c File Reference
This contains the I2C API implementation for the MCP9808 driver, which the user can edit based on the specific I2C hardware used.
#include "../../i2c_host/twi1.h" #include "../../temperature-mcp98xx/mcp9808_i2c.h"
4.4.3.4.1 Functions
uint8_t MCP9808_Write (uint16_t address, uint8_t *data, size_t dataLength)
Writes data to the MCP9808 Temperature Sensor using the I2C protocol.
uint8_t MCP9808_Read (uint16_t address, uint8_t *registerAddress, size_t addressLength, uint8_t *readData, size_t readLength)
Writes the register address pointer from the registerAddress to the bus and reads data from the MCP9808 Temperature Sensor using the I2C protocol, and then stores the received data in the readData.
4.4.3.4.2 Variables
const i2c_host_interface_t MCP9808_I2C_Host
4.4.3.4.3 Detailed Description
4.4.3.4.4 Variable Documentation
MCP9808_I2C_Host
const i2c_host_interface_t MCP9808_I2C_Host
Initial value:
= { .Write = TWI1_Write, .WriteRead = TWI1_WriteRead, .IsBusy = TWI1_IsBusy, }
4.4.3.5 source/mcp9808_i2c.h File Reference
#include <stdint.h> #include <stddef.h> #include <stdbool.h>
4.4.3.5.1 Functions
uint8_t MCP9808_Write (uint16_t address, uint8_t *data, size_t dataLength)
Writes data to the MCP9808 Temperature Sensor using the I2C protocol.
uint8_t MCP9808_Read (uint16_t address, uint8_t *registerAddress, size_t addressLength, uint8_t *readData, size_t readLength)
Writes the register address pointer from the registerAddress to the bus and reads data from the MCP9808 Temperature Sensor using the I2C protocol, and then stores the received data in the readData.
4.4.3.5.2 Macros
MCP9808 I2C Status Codes
Macros for the I2C status codes.
#define MCP9808_I2C_NO_ERROR (0U)
#define MCP9808_I2C_ERROR (1U)
#define MCP9808_INVALID_I2C_PARAMETER (2U)
4.4.3.5.3 Detailed Description
MCP9808 Generated Driver I2C Interface API Header File.
4.4.3.5.4 Macro Definition Documentation
MCP9808_I2C_ERROR
#define MCP9808_I2C_ERROR (1U)
MCP9808_I2C_NO_ERROR
#define MCP9808_I2C_NO_ERROR (0U)
MCP9808_INVALID_I2C_PARAMETER
#define MCP9808_INVALID_I2C_PARAMETER (2U)
4.4.3.6 source/mcp98xx_interface.h File Reference
#include <stdint.h> #include "../temperature-mcp98xx/mcp98xx_types.h"
4.4.3.6.1 Data structures
struct MCP98XX_INTERFACE_t
Structure containing the function pointers to the MCP98xx driver APIs.
4.4.3.6.2 Detailed Description
MCP98XX Generated Driver Interface API Header File.
4.4.3.7 source/mcp98xx_types.h File Reference
This contains the MCP98xx driver types.
4.4.3.7.1 Data structures
struct MCP98XX_DEVICE_INIT
Structure containing the MCP98xx driver registers to be initialized.
struct MCP98XX_DEVICE_INFO
Structure containing the MCP98xx driver information.
struct MCP98XX_SENSOR_CONFIG_REG
Structure containing the MCP98xx driver Sensor Configuration bit register settings.
struct MCP98XX_DEVICE_CONTEXT
Structure containing the MCP98xx driver context that can be used in the processes.
4.4.3.7.2 Typedefs
typedef enum MCP98XX_STATUS MCP98XX_STATUS_t
typedef enum MCP98XX_TEMP_BOUNDARY MCP98XX_TEMP_BOUNDARY_t
typedef enum MCP98XX_ALERT_CONFIG MCP98XX_ALERT_CONFIG_t
typedef enum MCP98XX_HYSTERESIS_VALUE MCP98XX_HYSTERESIS_VALUE_t
typedef enum MCP98XX_RESOLUTION_VALUE MCP98XX_RESOLUTION_VALUE_t
typedef struct MCP98XX_DEVICE_INIT MCP98XX_DEVICE_INIT_t
typedef struct MCP98XX_DEVICE_INFO MCP98XX_DEVICE_INFO_t
typedef struct MCP98XX_SENSOR_CONFIG_REG MCP98XX_CONFIG_REG_t
typedef struct MCP98XX_SENSOR_CONFIG_REG * MCP98XX_CONFIG_REG_PTR
typedef struct MCP98XX_DEVICE_CONTEXT MCP98XX_DEVICE_CONTEXT_t
typedef struct MCP98XX_DEVICE_CONTEXT * MCP98XX_DEVICE_CONTEXT_PTR
4.4.3.7.3 Enumerations
enum MCP98XX_STATUS { MCP98XX_NO_ERROR = 0U, MCP98XX_ERROR = 1U, MCP98XX_COMMUNICATION_ERROR = 16U, MCP98XX_INVALID_DEVICE_INFO = 100U, MCP98XX_INVALID_RESOLUTION_VALUE = 101U, MCP98XX_INVALID_TEMP_VALUE = 102U, MCP98XX_INVALID_ALERT_CONFIG = 103U, MCP98XX_INVALID_PARAMETER = 104U, MCP98XX_NULL_POINTER = 105U, MCP98XX_NOT_ASSERTED = 10U, MCP98XX_LOWER_TEMP_ASSERTED = 2U, MCP98XX_UPPER_TEMP_ASSERTED = 4U, MCP98XX_CRIT_TEMP_ASSERTED = 8U }
Enumeration of the MCP98xx driver status codes.
enum MCP98XX_TEMP_BOUNDARY { LOWER_BOUNDARY = 1U, UPPER_BOUNDARY = 2U, CRITICAL_BOUNDARY = 3U }
Enumeration of the user-configurable temperature boundaries that is used as a parameter for setting the boundaries.
enum MCP98XX_ALERT_CONFIG { ALERT_OUTPUT_CLEAR = 1U, ALERT_CONTROL = 2U, ALERT_SELECT = 3U, ALERT_POLARITY = 4U, ALERT_MODE = 5U }
Enumeration of the user-configurable Alert output setting that is used as a parameter for setting the Alert configuration.
enum MCP98XX_HYSTERESIS_VALUE { HYSTERESIS_0, HYSTERESIS_1_5, HYSTERESIS_3, HYSTERESIS_6 }
Enumeration of the possible Temperature Hysteresis values.
enum MCP98XX_RESOLUTION_VALUE { RESOLUTION_0_5, RESOLUTION_0_25, RESOLUTION_0_125, RESOLUTION_0_0625 }
Enumeration of the possible Temperature Resolution values.
4.4.3.7.4 Detailed Description
This contains the MCP98xx driver types.
MCP98XX Generated Driver Types Header File.
4.4.3.7.5 Typedef Documentation
MCP98XX_ALERT_CONFIG_t
typedef enum MCP98XX_ALERT_CONFIG MCP98XX_ALERT_CONFIG_t
MCP98XX_CONFIG_REG_PTR
typedef struct MCP98XX_SENSOR_CONFIG_REG * MCP98XX_CONFIG_REG_PTR
MCP98XX_CONFIG_REG_t
typedef struct MCP98XX_SENSOR_CONFIG_REG MCP98XX_CONFIG_REG_t
MCP98XX_DEVICE_CONTEXT_PTR
typedef struct MCP98XX_DEVICE_CONTEXT * MCP98XX_DEVICE_CONTEXT_PTR
MCP98XX_DEVICE_CONTEXT_t
typedef struct MCP98XX_DEVICE_CONTEXT MCP98XX_DEVICE_CONTEXT_t
MCP98XX_DEVICE_INFO_t
typedef struct MCP98XX_DEVICE_INFO MCP98XX_DEVICE_INFO_t
MCP98XX_DEVICE_INIT_t
typedef struct MCP98XX_DEVICE_INIT MCP98XX_DEVICE_INIT_t
MCP98XX_HYSTERESIS_VALUE_t
typedef enum MCP98XX_HYSTERESIS_VALUE MCP98XX_HYSTERESIS_VALUE_t
MCP98XX_RESOLUTION_VALUE_t
typedef enum MCP98XX_RESOLUTION_VALUE MCP98XX_RESOLUTION_VALUE_t
MCP98XX_STATUS_t
typedef enum MCP98XX_STATUS MCP98XX_STATUS_t
MCP98XX_TEMP_BOUNDARY_t
typedef enum MCP98XX_TEMP_BOUNDARY MCP98XX_TEMP_BOUNDARY_t