📄 lm75.h
字号:
/****************************************Copyright (c)**************************************************
** Guangzhou ZHIYUAN ELECTRONIC CO.,LTD.
** Research centre
** http://www.zyinside.com, http://www.zlgmcu.com
**
**---------------------------------------File Info-----------------------------------------------------
** File name: lm75.c
** Latest modified Date: 2006-2-20
** Latest Version: 1.0
** Descriptions: Provide I2C accessor Marco for read or write a byte data.
** and LM75 device class definition
** and function declaration
**
**------------------------------------------------------------------------------------------------------
** Created by: Zhou Shuwu
** Created date: 2006-2-20
** Version: 1.0
** Descriptions: The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#ifndef __LM75_H__
#define __LM75_H__
#include <stddef.h>
#include <sys/termios.h>
#include "alt_types.h"
#include "oc_i2c_regs.h"
#include "sys/alt_dev.h"
#include "sys/alt_warning.h"
#include "os/alt_sem.h"
#ifdef __GLOBAL_DEF__
#define __EXT__
#else
#define __EXT__ extern
#endif
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
/************************************************************************************
** Registers in LM75 defined here *
*************************************************************************************/
#define LM75_ADDRESS 0x90 //LM75 device address
//Offset of the registers defined here
#define LM75_TEMP 0x00 //Temperature Register.
#define LM75_CONFIG 0x01 //Configuration Register.
#define LM75_THYST 0x02 //Hysteresis Register.
#define LM75_TOS 0x03 //Over-temp Shutdown threshold Register.
#define NO_INT 0x00 //No interrupt event
#define INT_EVENT 0x01 //interrupt event occur
/* LM75 device class definition */
typedef struct
{
alt_u32 base; /* base address of open i2c core */
alt_u32 pio_base; /* base address of PIO related to LM75_INT */
alt_u32 irq; /* LM75_INT PIO interrupt number */
alt_u8 dev_addr; /* device address of LM75 */
alt_u8 int_flag; /* interrupt flag,1:interrupt; 0: no interrupt*/
} LM75_dev;
/* This function is responsible for performing all the run time initialization
* for a device instance
*/
__EXT__ int LM75_Init(LM75_dev* dev, alt_u32 i2c_freq);
__EXT__ int LM75_ReadReg(LM75_dev* dev, alt_u8 reg, alt_u8* content, alt_u16 num);
__EXT__ int LM75_WriteReg(LM75_dev* dev, alt_u8 reg, alt_u8* content, alt_u16 num);
extern void TemperatureInit(void);
extern int TempertureGet(alt_u8* temperBuf);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LM75_H__ */
/**********************end****************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -