55
66#ifndef p3t1755_H
77#define p3t1755_H
8- #include <stdint.h>
98#include <math.h>
9+ #include <stdint.h>
1010
1111// REGISTERS
12- // Temperature register: contains two 8-bit data bytes; to store the measured Temp data.
12+ // Temperature register: contains two 8-bit data bytes; to store the measured
13+ // Temp data.
1314#define p3t1755_TEMPERATURE 0x00 // read only
14- // Configuration register: contains a single 8-bit data byte; to set the device operating condition
15+ // Configuration register: contains a single 8-bit data byte; to set the device
16+ // operating condition
1517#define p3t1755_CONFIGURATION 0x01
16- // T_low register: Hysteresis register, it contains two 8-bit data bytes to store the hysteresis T_low limit; default = 75 °C.
18+ // T_low register: Hysteresis register, it contains two 8-bit data bytes to
19+ // store the hysteresis T_low limit; default = 75 °C.
1720#define p3t1755_T_LOW 0x02
18- // T_high register: Overtemperature shut down threshold register, it contains two 8-bit data bytes to
19- // store the overtemperature shutdown T_high limit; default = 80 °C.
21+ // T_high register: Overtemperature shut down threshold register, it contains
22+ // two 8-bit data bytes to store the overtemperature shutdown T_high limit;
23+ // default = 80 °C.
2024#define p3t1755_T_HIGH 0x03
2125
2226// TEMPERATURE REGISTER FORMAT
5054#define p3t1755_220MS_CONVERSION_TIME 0x60
5155
5256// Function Pointers
53- typedef int (* WritePtr )(uint16_t dev_addr , uint16_t reg , uint16_t * data );
54- typedef int (* ReadPtr )(uint16_t dev_addr , uint16_t reg , uint16_t * data );
57+ typedef int32_t (* WritePtr )(uint16_t dev_addr , uint16_t reg , uint8_t * data ,
58+ uint8_t length );
59+ typedef int32_t (* ReadPtr )(uint16_t dev_addr , uint16_t reg , uint8_t * data ,
60+ uint8_t length );
5561
5662typedef struct {
5763 uint16_t dev_addr ;
5864 WritePtr write ;
5965 ReadPtr read ;
6066} p3t1755_t ;
6167
68+ float p3t1755_raw_to_celsius (uint16_t raw );
69+
6270void p3t1755_init (p3t1755_t * p3t , WritePtr write , ReadPtr read ,
6371 uint16_t dev_addr );
6472
65- int p3t1755_read_reg (p3t1755_t * p3t , uint16_t reg , uint16_t * data );
66- int p3t1755_write_reg (p3t1755_t * p3t , uint16_t reg , uint16_t * data );
73+ int p3t1755_read_reg (p3t1755_t * p3t , uint16_t reg , uint8_t * data ,
74+ uint8_t length );
75+ int p3t1755_write_reg (p3t1755_t * p3t , uint16_t reg , uint8_t * data ,
76+ uint8_t length );
6777
6878// Reads current temp in celcius
6979int p3t1755_read_temperature (p3t1755_t * p3t , float * temp_c );
@@ -86,4 +96,4 @@ int p3t1755_read_low_temp(p3t1755_t *p3t, float *temp_c);
8696int p3t1755_set_high_temp (p3t1755_t * p3t , float temp_c );
8797int p3t1755_set_low_temp (p3t1755_t * p3t , float temp_c );
8898
89- #endif
99+ #endif
0 commit comments