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

Table 4-1. 
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

This contains the MCP9808 API prototypes and other data types for the MCP9808 driver.

4.4.1.1.1 Module description

This contains the MCP9808 API prototypes and other data types for the MCP9808 driver.

Version: MCP98xx Driver Version 1.0.0
Functions
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.

Parameters:
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.

Returns:

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.

Parameters:
MCP9808_DEVICE_CONTEXT_PTR

devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT.

Returns:

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.

Parameters:
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.

Returns:

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.

Parameters:
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.

Returns:

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.

Parameters:
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.

Returns:

MCP98XX status code.

MCP9808_CelsiusToFahrenheit()

float MCP9808_CelsiusToFahrenheit (float tempVal)

Converts the temperature value from Celsius to Fahrenheit.

Parameters:
float

tempVal - Temperature value to be converted.

Returns:

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.

Parameters:
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.

Returns:

MCP98XX status code.

MCP9808_FahrenheitToCelsius()

float MCP9808_FahrenheitToCelsius (float tempVal)

Converts the temperature value from Fahrenheit to Celsius.

Parameters:
float

tempVal - Temperature value to be converted.

Returns:

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.

Parameters:
MCP9808_DEVICE_CONTEXT_PTR

devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT.

MCP9808_DEVICE_INIT_t

deviceInit - An instance of MCP98XX_DEVICE_INIT.

Returns:

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.

Parameters:
MCP9808_DEVICE_CONTEXT_PTR

devicePtr - Pointer to an instance of MCP9808_DEVICE_CONTEXT_t.

Returns:

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.

Parameters:
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.

Returns:

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.

Parameters:
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.

Returns:

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.

Parameters:
MCP9808_DEVICE_CONTEXT_PTR

devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT.

Returns:

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.

Parameters:
MCP9808_DEVICE_CONTEXT_PTR

devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT.

Returns:

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.

Parameters:
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.

Returns:

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.

Parameters:
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.

Returns:

MCP98XX status code.

MCP9808_TemperatureCelsiusToRawValue()

int16_t MCP9808_TemperatureCelsiusToRawValue (float tempVal)

Converts the temperature value from Celsius to raw value.

Parameters:
float

tempVal - Temperature value in Celsius to be converted.

Returns:

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.

Parameters:
MCP9808_DEVICE_CONTEXT_PTR

devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT.

Returns:

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.

Parameters:
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.

Returns:

MCP98XX status code.

MCP9808_TemperatureRawToCelsius()

float MCP9808_TemperatureRawToCelsius (uint16_t rawVal)

Converts the temperature raw value to Celsius.

Parameters:
uint16_t

rawVal - Raw value to be converted.

Returns:

Temperature value in Celsius.

MCP9808_TemperatureRawToFahrenheit()

float MCP9808_TemperatureRawToFahrenheit (uint16_t rawVal)

Converts the temperature raw value to Fahrenheit.

Parameters:
uint16_t

rawVal - Raw value to be converted.

Returns:

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.

Parameters:
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.

Returns:

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.

Parameters:
MCP9808_DEVICE_CONTEXT_PTR

devicePtr - Pointer to an instance of MCP98XX_DEVICE_CONTEXT.

Returns:

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.

Parameters:
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.

Returns:

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.

Parameters:
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.

Returns:

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.

Version: MCP98xx Driver Version 1.0.0
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.

Parameters:
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.

Returns:

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.

Parameters:
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.

Returns:

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.

Version: MCP98xx Driver Version 1.0.0
Data structures
Enumerations
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/

mcp9808.h

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/

mcp9808.h

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.2 Field Documentation

The documentation for this struct was generated from the following file:

source/

mcp98xx_types.h

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>

4.4.2.4.2 Field Documentation

The documentation for this struct was generated from the following file:

source/

mcp98xx_types.h

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.2 Field Documentation

The documentation for this struct was generated from the following file:

source/

mcp98xx_types.h

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.2 Field Documentation

The documentation for this struct was generated from the following file:

source/

mcp98xx_interface.h

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.2 Field Documentation

The documentation for this struct was generated from the following file:

source/

mcp98xx_types.h

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
4.4.3.1.3 Detailed Description

This contains the API implementation for the MCP9808 driver.

MCP9808 Generated Driver File.

Version: MCP98xx Driver Version 1.0.0
4.4.3.1.4 Variable Documentation
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
4.4.3.2.2 Macros
Custom Driver Type Macros
4.4.3.2.3 MCC-Generated Macros
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.3 Mask Macros

Macros used in masking the MCP9808 registers:

4.4.3.3.6 Detailed Description

This contains macros for device-specific configuration.

MCP9808 Generated Driver Header File.

Version: MCP98xx Driver Version 1.0.0
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.3 Detailed Description

This contains the I2C API implementation for the MCP9808 driver, which the user can edit based on the specific I2C hardware used.

MCP9808 Generated Driver I2C Interface File.

Version: MCP98xx Driver Version 1.0.0
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.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
4.4.3.7.2 Typedefs
4.4.3.7.3 Enumerations
4.4.3.7.4 Detailed Description

This contains the MCP98xx driver types.

MCP98XX Generated Driver Types Header File.

Version: MCP98xx Driver Version 1.0.0
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