lm75.h

来自「LM75温度侦测芯片」· C头文件 代码 · 共 48 行

H
48
字号
#ifndef LM75_H#define	LM75_H/* *  lm75.h * *  Copyright (C) 2006  Apple zeng * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. *//* straight from the datasheet */#define LM75_TEMP_MIN (-55000)#define LM75_TEMP_MAX 125000/* This macro is used to scale user-input to sensible values in almost all   chip drivers. */static inline int SENSORS_LIMIT(long value, long low, long high){    if (value < low)        return low;    else if (value > high)        return high;    else        return value;}/* TEMP: 0.001C/bit (-55C to +125C)   REG: (0.5C/bit, two's complement) << 7 */static inline unsigned short LM75_TEMP_TO_REG(int temp){    int ntemp = SENSORS_LIMIT(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);    ntemp += (ntemp<0 ? -250 : 250);    return (unsigned short)((ntemp / 500) << 7);}static inline int LM75_TEMP_FROM_REG(unsigned short reg){    /* use integer division instead of equivalent right shift to       guarantee arithmetic shift and preserve the sign */    return ((unsigned short)reg / 128) * 500;}#define I2C_LM75 		0x96#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?