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

Source file of LM75 Driver. More...

#include <errno.h>
#include "no_os_alloc.h"
#include "lm75.h"
Include dependency graph for lm75.c:

Classes

struct  lm75_reg_permissions
 

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

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

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

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