2.6 I2C Temp Sensor MCP98xx Driver
2.6.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.
2.6.2 How to Host Multiple Clients on a Single I2C Bus
- Launch MCC and select MCC Melody
- Load at least two I2C-dependent modules (in the case illustrated by Figure 2-3 2-7), without assigning any I2C instance in the I2C Host Dependency selector.
- Assign an I2C instance to only one of the loaded I2C-dependent modules (refer to Figure 2-4 2-8).
- If there are more than one I2C instance on the device, keep the I2C Host Dependency selector on the second I2C-dependent module (I2C Color Sensor VEML3328) on “None”.
- Check the notifications on the second I2C-dependent module for instructions on how to assign the same I2C instance in the generated C-code. Ignore this warning when generating the code.
- Generate the code.
- Modify the generated C-code by assigning the generated I2C driver APIs.
2.6.3 I2C Temp Sensor MCP98xx Driver Documentation
2.6.3.1 Module Documentation
2.6.3.1.1 MCP9808
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
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.
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.
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.
|
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.
|
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.
|
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.
|
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.
|
MCP98XX status code. |
MCP9808_CelsiusToFahrenheit()
float MCP9808_CelsiusToFahrenheit (float tempVal)
Converts the temperature value from Celsius to Fahrenheit.
|
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.
|
MCP98XX status code. |
MCP9808_FahrenheitToCelsius()
float MCP9808_FahrenheitToCelsius (float tempVal)
Converts the temperature value from Fahrenheit to Celsius.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
MCP98XX status code. |
MCP9808_TemperatureCelsiusToRawValue()
int16_t MCP9808_TemperatureCelsiusToRawValue (float tempVal)
Converts the temperature value from Celsius to raw value.
|
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.
|
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.
|
MCP98XX status code. |
MCP9808_TemperatureRawToCelsius()
float MCP9808_TemperatureRawToCelsius (uint16_t rawVal)
Converts the temperature raw value to Celsius.
|
Temperature value in Celsius. |
MCP9808_TemperatureRawToFahrenheit()
float MCP9808_TemperatureRawToFahrenheit (uint16_t rawVal)
Converts the temperature raw value to Fahrenheit.
|
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.
|
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.
|
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.
|
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.
|
MCP98XX status code. |
Enumeration Type Documentation
_MCP9808_DEVICE_INFORMATION_t
enum _MCP9808_DEVICE_INFORMATION_t
Enumeration of the MCP9808 device information.
MANUFACTURER_ID | ||
DEVICE_ID | ||
DEVICE_REVISION |
2.6.3.1.2 MCP9808_I2C
This contains the API prototypes for the MCP9808 I2C Protocol.
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.
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.
|
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.
|
MCP9808 I2C status code. |
2.6.3.1.3 MCP98XX
This contains the APIs for the MCP98xx driver interface.
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.
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
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
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
Enumeration of the user-configurable temperature boundaries that is used as a parameter for setting the boundaries.
LOWER_BOUNDARY | ||
UPPER_BOUNDARY | ||
CRITICAL_BOUNDARY |
2.6.3.1.4 How to Host Multiple Clients on a Single I2C Bus
- Launch MCC and select MCC Melody
- Load at least two I2C-dependent modules (in the case illustrated by Figure 2-3 2-7), without assigning any I2C instance in the I2C Host Dependency selector.
- Assign an I2C instance to only one of the loaded I2C-dependent modules (refer to Figure 2-4 2-8).
- If there are more than one I2C instance on the device, keep the I2C Host Dependency selector on the second I2C-dependent module (I2C Color Sensor VEML3328) on “None”.
- Check the notifications on the second I2C-dependent module for instructions on how to assign the same I2C instance in the generated C-code. Ignore this warning when generating the code.
- Generate the code.
- Modify the generated C-code by assigning the generated I2C driver APIs.
2.6.3.2 Class Documentation
2.6.3.2.1 MCP9808 Struct Reference
An instance of MCP98XX_INTERFACE_t for the MCP98xx driver.
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/
2.6.3.2.2 MCP9808_INITIAL_CONFIG Struct Reference
An instance of MCP98XX_DEVICE_INIT for the MCP98xx driver.
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/
2.6.3.2.3 MCP98XX_DEVICE_CONTEXT Struct Reference
Structure containing the MCP98xx driver context that can be used in the processes.
Detailed Description
Structure containing the MCP98xx driver context that can be used in the processes.
#include <mcp98xx_types.h>
Public Attributes
uint16_t i2cAddress
float tempUpperLimit
float tempLowerLimit
float tempCritLimit
uint8_t rxBuffer [2]
uint8_t tempResolution
uint8_t txBuffer [3]
Member Data Documentation
deviceInfo
MCP98XX_DEVICE_INFO_t MCP98XX_DEVICE_CONTEXT::deviceInfo
i2cAddress
uint16_t MCP98XX_DEVICE_CONTEXT::i2cAddress
rxBuffer
uint8_t MCP98XX_DEVICE_CONTEXT::rxBuffer[2]
sensorConfigReg
MCP98XX_CONFIG_REG_t MCP98XX_DEVICE_CONTEXT::sensorConfigReg
tempCritLimit
float MCP98XX_DEVICE_CONTEXT::tempCritLimit
tempLowerLimit
float MCP98XX_DEVICE_CONTEXT::tempLowerLimit
tempResolution
uint8_t MCP98XX_DEVICE_CONTEXT::tempResolution
tempUpperLimit
float MCP98XX_DEVICE_CONTEXT::tempUpperLimit
txBuffer
uint8_t MCP98XX_DEVICE_CONTEXT::txBuffer[3]
2.6.3.2.4 MCP98XX_DEVICE_INFO Struct Reference
Structure containing the MCP98xx driver information.
Detailed Description
Structure containing the MCP98xx driver information.
#include <mcp98xx_types.h>
Public Attributes
uint16_t manufacturerId
uint8_t deviceId
uint8_t deviceRevision
Member Data Documentation
deviceId
uint8_t MCP98XX_DEVICE_INFO::deviceId
deviceRevision
uint8_t MCP98XX_DEVICE_INFO::deviceRevision
manufacturerId
uint16_t MCP98XX_DEVICE_INFO::manufacturerId
2.6.3.2.5 MCP98XX_DEVICE_INIT Struct Reference
Structure containing the MCP98xx driver registers to be initialized.
Detailed Description
Structure containing the MCP98xx driver registers to be initialized.
#include <mcp98xx_types.h>
Public Attributes
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
Member Data Documentation
alertClear
bool MCP98XX_DEVICE_INIT::alertClear
alertControl
bool MCP98XX_DEVICE_INIT::alertControl
alertMode
bool MCP98XX_DEVICE_INIT::alertMode
alertPolarity
bool MCP98XX_DEVICE_INIT::alertPolarity
alertSelect
bool MCP98XX_DEVICE_INIT::alertSelect
critLock
bool MCP98XX_DEVICE_INIT::critLock
i2cAddress
uint16_t MCP98XX_DEVICE_INIT::i2cAddress
shutdownMode
bool MCP98XX_DEVICE_INIT::shutdownMode
tempCritBoundary
float MCP98XX_DEVICE_INIT::tempCritBoundary
tempHysteresis
uint8_t MCP98XX_DEVICE_INIT::tempHysteresis
tempLowerBoundary
float MCP98XX_DEVICE_INIT::tempLowerBoundary
tempResolution
uint8_t MCP98XX_DEVICE_INIT::tempResolution
tempUpperBoundary
float MCP98XX_DEVICE_INIT::tempUpperBoundary
winLock
bool MCP98XX_DEVICE_INIT::winLock
2.6.3.2.6 MCP98XX_INTERFACE_t Struct Reference
Structure containing the function pointers to the MCP98xx driver APIs.
Detailed Description
Structure containing the function pointers to the MCP98xx driver APIs.
#include <mcp98xx_interface.h>
Public Attributes
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)
Member Data Documentation
Initialize
MCP98XX_STATUS_t(* MCP98XX_INTERFACE_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(* MCP98XX_INTERFACE_t::TempRead) (MCP98XX_DEVICE_CONTEXT_PTR devicePtr, uint16_t *tempRawVal)
This is a pointer to the function that reads the Ambient Temperature data.
2.6.3.2.7 MCP98XX_SENSOR_CONFIG_REG Struct Reference
Structure containing the MCP98xx driver Sensor Configuration bit register settings.
Detailed Description
Structure containing the MCP98xx driver Sensor Configuration bit register settings.
#include <mcp98xx_types.h>
Public Attributes
uint8_t tempHysteresis
bool shutdownMode
bool critLock
bool winLock
bool alertClear
bool alertStat
bool alertControl
bool alertSelect
bool alertPolarity
bool alertMode
Member Data Documentation
alertClear
bool MCP98XX_SENSOR_CONFIG_REG::alertClear
alertControl
bool MCP98XX_SENSOR_CONFIG_REG::alertControl
alertMode
bool MCP98XX_SENSOR_CONFIG_REG::alertMode
alertPolarity
bool MCP98XX_SENSOR_CONFIG_REG::alertPolarity
alertSelect
bool MCP98XX_SENSOR_CONFIG_REG::alertSelect
alertStat
bool MCP98XX_SENSOR_CONFIG_REG::alertStat
critLock
bool MCP98XX_SENSOR_CONFIG_REG::critLock
shutdownMode
bool MCP98XX_SENSOR_CONFIG_REG::shutdownMode
tempHysteresis
uint8_t MCP98XX_SENSOR_CONFIG_REG::tempHysteresis
winLock
bool MCP98XX_SENSOR_CONFIG_REG::winLock
2.6.3.3 File Documentation
2.6.3.3.1 source/mcp9808.h File Reference
#include <stdint.h> #include "../temperature-mcp98xx/mcp9808_i2c.h" #include "../temperature-mcp98xx/mcp98xx_interface.h"
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.
Macros
Custom Driver Type Macros
Macros that are used to redefine the driver types:
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)
Typedefs
Enumerations
enum _MCP9808_DEVICE_INFORMATION_t { MANUFACTURER_ID = 1U, DEVICE_ID = 2U, DEVICE_REVISION = 3U }
Enumeration of the MCP9808 device information.
Variables
Detailed Description
MCP9808 Generated Driver API Header File.
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)
Typedef Documentation
MCP9808_DEVICE_INFORMATION_t
Variable Documentation
MCP9808
const MCP98XX_INTERFACE_t MCP9808
MCP9808_INITIAL_CONFIG
2.6.3.3.2 source/mcp9808_config.h File Reference
This contains macros for device-specific configuration.
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)
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)
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)
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)
Generic Macros
Macros used in driver operation:
#define MCP9808_ENABLE_BIT (1U)
#define MCP9808_REGISTER_ADDRESS_LENGTH (1U)
Detailed Description
This contains macros for device-specific configuration.
MCP9808 Generated Driver Header File.
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)
2.6.3.3.3 source/mcp9808_i2c.h File Reference
#include <stdint.h> #include <stddef.h> #include <stdbool.h>
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.
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)
Detailed Description
MCP9808 Generated Driver I2C Interface API Header File.
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)
2.6.3.3.4 source/mcp98xx_interface.h File Reference
#include <stdint.h> #include "../temperature-mcp98xx/mcp98xx_types.h"
Data structures
struct MCP98XX_INTERFACE_t
Structure containing the function pointers to the MCP98xx driver APIs.
Detailed Description
MCP98XX Generated Driver Interface API Header File.
2.6.3.3.5 source/mcp98xx_types.h File Reference
This contains the MCP98xx driver types.
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.
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
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.
Detailed Description
This contains the MCP98xx driver types.
MCP98XX Generated Driver Types Header File.
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
2.6.3.3.6 source/src/mcp9808.c File Reference
This contains the API implementation for the MCP9808 driver.
#include "../../temperature-mcp98xx/mcp9808.h" #include "../../temperature-mcp98xx/mcp9808_config.h"
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.
Variables
Detailed Description
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, }
2.6.3.3.7 source/src/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"
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.
Variables
const i2c_host_interface_t MCP9808_I2C_Host
Detailed Description
Variable Documentation
MCP9808_I2C_Host
const i2c_host_interface_t MCP9808_I2C_Host
Initial value:
= { .Write = TWI1_Write, .WriteRead = TWI1_WriteRead, .IsBusy = TWI1_IsBusy, }