-
Notifications
You must be signed in to change notification settings - Fork 1
/
lm75a.h
53 lines (43 loc) · 1.48 KB
/
lm75a.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* lm75a.h
*
* Created on: Jul 26, 2018
* Author: Cyberarea
*/
#ifndef LM75A_H_
#define LM75A_H_
#include <stdint.h>
#include "i2c_bus.h"
#define LM75A_I2C_ADDRESS (0x48 << 1)
#define LM75A_DEGREES_RESOLUTION 0.125;
//-- register map for LM75A -----------------------------------------------------
#define LM75A_REG_TEMP 0x00
#define LM75A_REG_CFG 0x01
#define LM75A_REG_T_HYST 0x02 //-- default Thyst = 75 DegC
#define LM75A_REG_T_OS 0x03 //-- default Tos = 80 DegC
#define LM75A_REG_ID 0x07 //-- not working good
//-- LM75A Configuration structure ----------------------------------------------
typedef struct {
unsigned :3; //-- reserved [7:5]
unsigned FAULT_QUEUE: 2; //-- FAULT_QUEUE[2]
unsigned OSPOLARITY: 1; //-- alert polarity (1:active high, 0:active low
unsigned MODE:1; //-- mode (Cmp/Int) (1:interrupt mode, 0: comparator)
unsigned SHUTDOWN:1; //-- shudown -> low poer shutdown mode
} lm75a_cfgbits_t;
typedef union {
lm75a_cfgbits_t cfgbits;
unsigned char cfgchar;
} lm75a_cfg_t;
//-- LM75A configuration structure ---------------------------------------------
lm75a_cfg_t lm75a_cfg;
//-- function prototypes --------------------------------------------------------
int get_id(void);
void get_tempByte(uint8_t* input);
float convert_temp(uint8_t* input);
float get_temp(void);
int get_T_hyst(void);
int set_T_hyst(int8_t hyst_setpoint);
int get_T_os(void);
int set_T_os(int8_t os_setpoint);
unsigned char get_config(void);
#endif /* LM75A_H_ */