no-OS
adt75.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef _ADT75_H
34 #define _ADT75_H
35 
36 #include <stdint.h>
37 #include "no_os_i2c.h"
38 
40 #define ADT75_ADDR(x) (0x48 + (x))
41 #define ADT75_CONV_DELAY_MS 40
42 #define ADT75_FRAME_SIZE 3
43 
44 #define ADT75_TEMP_VALUE_REG 0x0
45 #define ADT75_CONF_REG 0x1
46 #define ADT75_HYST_REG 0x2
47 #define ADT75_OS_REG 0x3
48 #define ADT75_ONE_SHOT_REG 0x4
49 
50 #define ADT75_DATA_REG_MASK NO_OS_GENMASK(2, 0)
51 #define ADT75_CONFIG_REG_MASK NO_OS_GENMASK(7, 0)
52 
53 #define ADT75_TEMP_MASK NO_OS_GENMASK(15, 4)
54 #define ADT75_SIGN_BIT 11
55 
57 #define ADT75_SHUTDOWN_MASK NO_OS_BIT(0)
58 #define ADT75_COMP_INT_MASK NO_OS_BIT(1)
59 #define ADT75_ALERT_POL_MASK NO_OS_BIT(2)
60 #define ADT75_FAULT_QUEUE_MASK NO_OS_GENMASK(4, 3)
61 #define ADT75_ONESHOT_MASK NO_OS_BIT(5)
62 
63 #define ADT75_HYST_MASK NO_OS_GENMASK(15, 4)
64 #define ADT75_OVER_TEMP_MASK NO_OS_GENMASK(15, 4)
65 
67 #define ADT75_TEMP_DIV 16
68 
74 };
75 
79 struct adt75_desc {
81 };
82 
84 int adt75_get_single_temp(struct adt75_desc *, int32_t *);
85 
87 int adt75_reg_read(struct adt75_desc *, uint32_t, uint16_t *);
88 
90 int adt75_reg_write(struct adt75_desc *, uint32_t, uint16_t);
91 
93 int adt75_init(struct adt75_desc **, struct adt75_init_param *);
94 
96 int adt75_remove(struct adt75_desc *);
97 
98 #endif // _ADT75_H
no_os_put_unaligned_be16
void no_os_put_unaligned_be16(uint16_t val, uint8_t *buf)
ADT75_CONV_DELAY_MS
#define ADT75_CONV_DELAY_MS
Definition: adt75.h:41
no_os_alloc.h
ADT75_FRAME_SIZE
#define ADT75_FRAME_SIZE
Definition: adt75.h:42
adt75_init
int adt75_init(struct adt75_desc **, struct adt75_init_param *)
Initialize the device structure.
Definition: adt75.c:132
no_os_i2c_write
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
no_os_i2c_init
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
adt75_reg_read
int adt75_reg_read(struct adt75_desc *, uint32_t, uint16_t *)
Read the raw value of a register.
Definition: adt75.c:56
adt75_reg_read
int adt75_reg_read(struct adt75_desc *desc, uint32_t addr, uint16_t *val)
Read the raw value of a register.
Definition: adt75.c:56
no_os_i2c_remove
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
no_os_units.h
Header file of Units.
adt75_remove
int adt75_remove(struct adt75_desc *desc)
Free the device descriptor.
Definition: adt75.c:160
no_os_delay.h
Header file of Delay functions.
MILLIDEGREE_PER_DEGREE
#define MILLIDEGREE_PER_DEGREE
Definition: no_os_units.h:71
adt75_reg_write
int adt75_reg_write(struct adt75_desc *desc, uint32_t addr, uint16_t val)
Write a raw value to a register.
Definition: adt75.c:88
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
ADT75_SIGN_BIT
#define ADT75_SIGN_BIT
Definition: adt75.h:54
ADT75_DATA_REG_MASK
#define ADT75_DATA_REG_MASK
Definition: adt75.h:50
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
no_os_error.h
Error codes definition.
adt75_init
int adt75_init(struct adt75_desc **desc, struct adt75_init_param *init_param)
Initialize the device structure.
Definition: adt75.c:132
adt75_reg_write
int adt75_reg_write(struct adt75_desc *, uint32_t, uint16_t)
Write a raw value to a register.
Definition: adt75.c:88
adt75_get_single_temp
int adt75_get_single_temp(struct adt75_desc *desc, int32_t *val)
Read the current temperature sample (in milliCelsius)
Definition: adt75.c:107
ADT75_TEMP_DIV
#define ADT75_TEMP_DIV
Definition: adt75.h:67
adt75_init_param::comm_param
struct no_os_i2c_init_param comm_param
Definition: adt75.h:73
no_os_i2c_desc
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
no_os_i2c_read
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
ADT75_TEMP_VALUE_REG
#define ADT75_TEMP_VALUE_REG
Definition: adt75.h:44
no_os_i2c.h
Header file of I2C Interface.
ADT75_TEMP_MASK
#define ADT75_TEMP_MASK
Definition: adt75.h:53
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
ADT75_CONF_REG
#define ADT75_CONF_REG
Definition: adt75.h:45
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
adt75_remove
int adt75_remove(struct adt75_desc *)
Free the device descriptor.
Definition: adt75.c:160
adt75.h
Header file of ADT75 Driver.
adt75_init_param
Initialization parameter for the device descriptor.
Definition: adt75.h:72
no_os_get_unaligned_be16
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
no_os_util.h
Header file of utility functions.
no_os_sign_extend32
int32_t no_os_sign_extend32(uint32_t value, int index)
adt75_desc
ADT75 device descriptor.
Definition: adt75.h:79
adt75_get_single_temp
int adt75_get_single_temp(struct adt75_desc *, int32_t *)
Read the current temperature sample (in milliCelsius)
Definition: adt75.c:107
adt75_desc::comm_desc
struct no_os_i2c_desc * comm_desc
Definition: adt75.h:80