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

  1. Launch MCC and select MCC Melody
  2. 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.
    Figure 2-3 2-7. I2C Temp Sensor MCP98xx and I2C Color Sensor VEML3328 Default Setup
  3. Assign an I2C instance to only one of the loaded I2C-dependent modules (refer to Figure 2-4 2-8).
    Figure 2-4 2-8. Assigning an I2C instance on I2C Temp Sensor MCP98xx
  4. 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”.
  5. 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.
    Figure 2-5 2-9. Notifications on I2C Color Sensor VEML3328
  6. Generate the code.
  7. Modify the generated C-code by assigning the generated I2C driver APIs.
    Figure 2-6 2-10. Generated Code for I2C Color Sensor VEML3328

2.6.3 I2C Temp Sensor MCP98xx Driver Documentation

2.6.3.1 Module Documentation

2.6.3.1.1 MCP9808

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

Module description

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

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

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_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_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.

Enumeration Type Documentation

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.

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.

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.

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.

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

2.6.3.1.4 How to Host Multiple Clients on a Single I2C Bus

  1. Launch MCC and select MCC Melody
  2. 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.
    Figure 2-3 2-7. I2C Temp Sensor MCP98xx and I2C Color Sensor VEML3328 Default Setup
  3. Assign an I2C instance to only one of the loaded I2C-dependent modules (refer to Figure 2-4 2-8).
    Figure 2-4 2-8. Assigning an I2C instance on I2C Temp Sensor MCP98xx
  4. 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”.
  5. 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.
    Figure 2-5 2-9. Notifications on I2C Color Sensor VEML3328
  6. Generate the code.
  7. Modify the generated C-code by assigning the generated I2C driver APIs.
    Figure 2-6 2-10. Generated Code for I2C Color Sensor VEML3328

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/

mcp9808.h

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/

mcp9808.h

2.6.3.2.3 MCP98XX_DEVICE_CONTEXT Struct Reference

Structure containing the MCP98xx driver context that can be used in the processes.

Member Data Documentation

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

source/

mcp98xx_types.h

i2cAddress

uint16_t MCP98XX_DEVICE_CONTEXT::i2cAddress

rxBuffer

uint8_t MCP98XX_DEVICE_CONTEXT::rxBuffer[2]

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>

Member Data Documentation

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

source/

mcp98xx_types.h

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.

Member Data Documentation

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

source/

mcp98xx_types.h

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.

Member Data Documentation

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

source/

mcp98xx_interface.h

2.6.3.2.7 MCP98XX_SENSOR_CONFIG_REG Struct Reference

Structure containing the MCP98xx driver Sensor Configuration bit register settings.

Member Data Documentation

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

source/

mcp98xx_types.h

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
Macros
Custom Driver Type Macros
MCC-Generated Macros
Detailed Description

MCP9808 Generated Driver API Header File.

Macro Definition Documentation
MCP9808_ALERT_CNTRL_INIT

#define MCP9808_ALERT_CNTRL_INIT (0U)

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_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_HYSTERESIS_INIT

#define MCP9808_HYSTERESIS_INIT HYSTERESIS_0

MCP9808_INT_CLEAR_INIT

#define MCP9808_INT_CLEAR_INIT (1U)

MCP9808_LOWER_TEMP_BOUNDARY_INIT

#define MCP9808_LOWER_TEMP_BOUNDARY_INIT (0)

MCP9808_SHDN_MODE_INIT

#define MCP9808_SHDN_MODE_INIT (0U)

MCP9808_UPPER_TEMP_BOUNDARY_INIT

#define MCP9808_UPPER_TEMP_BOUNDARY_INIT (0)

MCP9808_WIN_LOCK_INIT

#define MCP9808_WIN_LOCK_INIT (0U)

2.6.3.3.2 source/mcp9808_config.h File Reference

This contains macros for device-specific configuration.

Mask Macros

Macros used in masking the MCP9808 registers:

Detailed Description

This contains macros for device-specific configuration.

MCP9808 Generated Driver Header File.

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

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.

Typedefs
Enumerations
Detailed Description

This contains the MCP98xx driver types.

MCP98XX Generated Driver Types Header File.

Version: MCP98xx Driver Version 1.0.0
Typedef Documentation

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

This contains the API implementation for the MCP9808 driver.

MCP9808 Generated Driver File.

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

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.

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
Variable Documentation
MCP9808_I2C_Host

const i2c_host_interface_t MCP9808_I2C_Host

Initial value:

= {
    .Write = TWI1_Write,
    .WriteRead = TWI1_WriteRead,
    .IsBusy = TWI1_IsBusy,
}