no-OS
Loading...
Searching...
No Matches
lm75.h File Reference

Header file of LM75 Driver. More...

#include "no_os_util.h"
#include "no_os_i2c.h"
Include dependency graph for lm75.h:

Classes

struct  lm75_init_param
 
struct  lm75_dev
 

Macros

#define LM75_DEVICE_SIGNATURE   0x7f4c4d75
 
#define LM75_HW_ADDR   0b1001000
 
#define LM75_FRAME_SIZE   3
 
#define LM75_ADDR_MASK   0xFFFF
 
#define LM75_SENSOR_DATA_MASK   0xFF80
 
#define LM75_MIN_TEMP   -55
 
#define LM75_MAX_TEMP   125
 
#define LM75_MIN_TEMP_MILLICEL   (LM75_MIN_TEMP * 1000)
 
#define LM75_MAX_TEMP_MILLICEL   (LM75_MAX_TEMP * 1000)
 
#define LM75_CONFIG_SHUTDOWN   NO_OS_BIT(0)
 
#define LM75_CONFIG_INT_EN   NO_OS_BIT(1)
 
#define LM75_CONFIG_OS_POLARITY   NO_OS_BIT(2)
 
#define LM75_CONFIG_FAULT_QUEUE   NO_OS_GENMASK(4, 3)
 
#define LM75_HYST_POR_VALUE   0x4b00
 
#define LM75_OS_POR_VALUE   0x5000
 
#define LM75_TEMP_MASK   NO_OS_GENMASK(15, 7)
 

Enumerations

enum  lm75_register {
  lm75_temperature_reg = 0x00 ,
  lm75_configuration_reg = 0x01 ,
  lm75_hyst_reg = 0x02 ,
  lm75_os_reg = 0x03
}
 
enum  lm75_os_polarity {
  lm75_os_active_low = 0 ,
  lm75_os_active_high
}
 
enum  lm75_temperature_type {
  lm75_die_temperature = 0 ,
  lm75_hysteresis_temperature ,
  lm75_over_temperature
}
 
enum  lm75_mode {
  lm75_comparator_mode = 0 ,
  lm75_interrupt_mode
}
 
enum  lm75_fault_queue {
  lm75_1_fault = 0 ,
  lm75_2_fault ,
  lm75_4_fault ,
  lm75_6_fault
}
 

Functions

int lm75_init (struct lm75_dev **devpp, struct lm75_init_param *ip)
 Initialize LM75 device driver.
 
int lm75_remove (struct lm75_dev *dev)
 Uninitialize LM75 device driver.
 
int lm75_read_temperature (struct lm75_dev *dev, enum lm75_temperature_type whence, uint16_t *val)
 Read temperature data.
 
int lm75_write_temperature (struct lm75_dev *dev, enum lm75_temperature_type whence, uint16_t val)
 Write temperature data.
 
int lm75_raw_to_millicelsius (const uint16_t raw_temp)
 Convert a raw sensor data to milliCelsius value.
 
uint16_t lm75_millicelsius_to_raw (const int millicelsius)
 Convert a milliCelsius value to raw sensor data that can be written to an LM75 device.
 
int lm75_is_shutdown (struct lm75_dev *dev, bool *flag)
 Read if LM75 is in shutdown or normal operation.
 
int lm75_shutdown (struct lm75_dev *dev, bool flag)
 Put the LM75 into normal or shutdown operation.
 
int lm75_read_mode (struct lm75_dev *dev, enum lm75_mode *mode)
 Read the event mode of LM75, whether interrupt based or comparator.
 
int lm75_write_mode (struct lm75_dev *dev, enum lm75_mode mode)
 Change the event mode of LM75, whether interrupt based or comparator.
 
int lm75_read_os_polarity (struct lm75_dev *dev, enum lm75_os_polarity *pol)
 Read the over temperature line polarity setting.
 
int lm75_write_os_polarity (struct lm75_dev *dev, enum lm75_os_polarity pol)
 Write the polarity of the over temperature line.
 
int lm75_read_fault_queue (struct lm75_dev *dev, enum lm75_fault_queue *fq)
 Read fault count.
 
int lm75_write_fault_queue (struct lm75_dev *dev, enum lm75_fault_queue fq)
 Write fault count.
 

Detailed Description

Header file of LM75 Driver.

Author
Niel Acuna (niel..nosp@m.acun.nosp@m.a@ana.nosp@m.log..nosp@m.com)

Copyright 2025(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ LM75_ADDR_MASK

#define LM75_ADDR_MASK   0xFFFF

◆ LM75_CONFIG_FAULT_QUEUE

#define LM75_CONFIG_FAULT_QUEUE   NO_OS_GENMASK(4, 3)

◆ LM75_CONFIG_INT_EN

#define LM75_CONFIG_INT_EN   NO_OS_BIT(1)

◆ LM75_CONFIG_OS_POLARITY

#define LM75_CONFIG_OS_POLARITY   NO_OS_BIT(2)

◆ LM75_CONFIG_SHUTDOWN

#define LM75_CONFIG_SHUTDOWN   NO_OS_BIT(0)

◆ LM75_DEVICE_SIGNATURE

#define LM75_DEVICE_SIGNATURE   0x7f4c4d75

◆ LM75_FRAME_SIZE

#define LM75_FRAME_SIZE   3

◆ LM75_HW_ADDR

#define LM75_HW_ADDR   0b1001000

◆ LM75_HYST_POR_VALUE

#define LM75_HYST_POR_VALUE   0x4b00

◆ LM75_MAX_TEMP

#define LM75_MAX_TEMP   125

◆ LM75_MAX_TEMP_MILLICEL

#define LM75_MAX_TEMP_MILLICEL   (LM75_MAX_TEMP * 1000)

◆ LM75_MIN_TEMP

#define LM75_MIN_TEMP   -55

◆ LM75_MIN_TEMP_MILLICEL

#define LM75_MIN_TEMP_MILLICEL   (LM75_MIN_TEMP * 1000)

◆ LM75_OS_POR_VALUE

#define LM75_OS_POR_VALUE   0x5000

◆ LM75_SENSOR_DATA_MASK

#define LM75_SENSOR_DATA_MASK   0xFF80

◆ LM75_TEMP_MASK

#define LM75_TEMP_MASK   NO_OS_GENMASK(15, 7)

Enumeration Type Documentation

◆ lm75_fault_queue

Enumerator
lm75_1_fault 
lm75_2_fault 
lm75_4_fault 
lm75_6_fault 

◆ lm75_mode

enum lm75_mode
Enumerator
lm75_comparator_mode 
lm75_interrupt_mode 

◆ lm75_os_polarity

Enumerator
lm75_os_active_low 
lm75_os_active_high 

◆ lm75_register

Enumerator
lm75_temperature_reg 
lm75_configuration_reg 
lm75_hyst_reg 
lm75_os_reg 

◆ lm75_temperature_type

Enumerator
lm75_die_temperature 
lm75_hysteresis_temperature 
lm75_over_temperature 

Function Documentation

◆ lm75_init()

int lm75_init ( struct lm75_dev ** devpp,
struct lm75_init_param * ip )

Initialize LM75 device driver.

Creates an LM75 device driver descriptor and puts the LM75 device into comparator mode initially.

Parameters
[out]devppthe newly create LM75 device descriptor.
[in]iplm75 initialization parameter structure.
Returns
0 on success, negative value on error.

◆ lm75_is_shutdown()

int lm75_is_shutdown ( struct lm75_dev * dev,
bool * flag )

Read if LM75 is in shutdown or normal operation.

Parameters
[in]devThe LM75 device structure.
[out]flagtrue shuts down the LM75. false puts the LM75 into normal operation.
Returns
0 in case of success
-ENODEV if dev is NULL
-EINVAL if flag is NULL

◆ lm75_millicelsius_to_raw()

uint16_t lm75_millicelsius_to_raw ( const int millicelsius)

Convert a milliCelsius value to raw sensor data that can be written to an LM75 device.

Used primarily to update hyst and over temperature.

Parameters
[in]millicelsiusmilliCelsius value to convert to raw sensor data.
Returns
raw converted sensor value from millicelsius.

◆ lm75_raw_to_millicelsius()

int lm75_raw_to_millicelsius ( const uint16_t raw_temp)

Convert a raw sensor data to milliCelsius value.

Parameters
[in]raw_tempraw sensor data to convert to MilliCelsius.
Returns
converted MilliCelsius value from raw sensor data.

◆ lm75_read_fault_queue()

int lm75_read_fault_queue ( struct lm75_dev * dev,
enum lm75_fault_queue * fq )

Read fault count.

Parameters
[in]devThe LM75 device structure.
[out]fqbuffer where fault queue number will be written.
Returns
0 in case of success, negative error code otherwise.

◆ lm75_read_mode()

int lm75_read_mode ( struct lm75_dev * dev,
enum lm75_mode * mode )

Read the event mode of LM75, whether interrupt based or comparator.

Parameters
[in]devThe LM75 device structure.
[out]modebuffer where mode will be written.
Returns
0 in case of success, negative error code otherwise.

◆ lm75_read_os_polarity()

int lm75_read_os_polarity ( struct lm75_dev * dev,
enum lm75_os_polarity * pol )

Read the over temperature line polarity setting.

Parameters
[in]devThe LM75 device structure.
[out]polbuffer where fault queue number will be written.
Returns
0 in case of success, negative error code otherwise.

◆ lm75_read_temperature()

int lm75_read_temperature ( struct lm75_dev * dev,
enum lm75_temperature_type whence,
uint16_t * val )

Read temperature data.

Used to read die, hysteresis and over temperature.

Parameters
[in]devthe LM75 device.
[in]whencethe type of temperature to update, can be lm75_die_temperature, lm75_hysteresis_temperature or lm75_over_temperature.
[out]valraw sensor temperature data defined by whence parameter.
Returns
0 on success, negative value on error.

◆ lm75_remove()

int lm75_remove ( struct lm75_dev * dev)

Uninitialize LM75 device driver.

Put LM75 into shutdown (low power mode) and release resources back to system.

Parameters
[in]devthe LM75 device.
Returns
0 on success, negative value on fail.

◆ lm75_shutdown()

int lm75_shutdown ( struct lm75_dev * dev,
bool flag )

Put the LM75 into normal or shutdown operation.

Parameters
[in]devThe LM75 device structure.
[in]flagtrue shuts down the LM75. false puts the LM75 into normal operation.
Returns
0 in case of success, negative error code otherwise.

◆ lm75_write_fault_queue()

int lm75_write_fault_queue ( struct lm75_dev * dev,
enum lm75_fault_queue fq )

Write fault count.

Parameters
[in]devThe LM75 device structure.
[in]fqfault queue number.
Returns
0 in case of success, negative error code otherwise.

◆ lm75_write_mode()

int lm75_write_mode ( struct lm75_dev * dev,
enum lm75_mode mode )

Change the event mode of LM75, whether interrupt based or comparator.

Parameters
[in]devThe LM75 device structure.
[in]modeeither lm75_comparator_mode or lm75_interrupt_mode
Returns
0 in case of success, negative error code otherwise.

◆ lm75_write_os_polarity()

int lm75_write_os_polarity ( struct lm75_dev * dev,
enum lm75_os_polarity pol )

Write the polarity of the over temperature line.

Parameters
[in]devThe LM75 device structure.
[out]pollm75_os_active_low or lm75_os_active_high.
Returns
0 in case of success, negative error code otherwise.

◆ lm75_write_temperature()

int lm75_write_temperature ( struct lm75_dev * dev,
enum lm75_temperature_type whence,
uint16_t val )

Write temperature data.

Used to update hysteresis and over temperature. Die temperature is read-only.

Parameters
[in]devthe LM75 device.
[in]whencethe type of temperature to update, can be either lm75_hysteresis_temperature or lm75_over_temperature only.
[in]valthe raw sensor data to write.
Returns
0 on success, negative value on error.