Go to the documentation of this file.
50 #define ADT7420_A0_PIN(x) (((x) & 0x1) << 0) // I2C Serial Bus Address Selection Pin
51 #define ADT7420_A1_PIN(x) (((x) & 0x1) << 1) // I2C Serial Bus Address Selection Pin
52 #define ADT7420_ADDRESS(x,y) (0x48 + ADT7420_A1_PIN(x) + ADT7420_A0_PIN(y))
53 #define ADT7320_L16 NO_OS_BIT(8) //indicator that register is 16-bit
54 #define ADT7320_ADDR_MSK NO_OS_GENMASK(7,0)
57 #define ADT7320_REG_STATUS 0x00 // Status
58 #define ADT7320_REG_CONFIG 0x01 // Configuration
59 #define ADT7320_REG_TEMP (ADT7320_L16 | 0x02) // Temperature value
60 #define ADT7320_REG_ID 0x03 // ID
61 #define ADT7320_REG_T_CRIT (ADT7320_L16 | 0x04) // Temperature CRIT setpoint (147'C)
62 #define ADT7320_REG_HIST 0x05 // Temperature HYST setpoint (5'C)
63 #define ADT7320_REG_T_HIGH (ADT7320_L16 | 0x06) // Temperature HIGH setpoint (64'C)
64 #define ADT7320_REG_T_LOW (ADT7320_L16 | 0x07) // Temperature LOW setpoint (10'C)
67 #define ADT7320_WRITE_MASK_CMD 0b00111000 // SPI write command
68 #define ADT7320_READ_CMD 0b01000000 // SPI read command
71 #define ADT7420_REG_TEMP_MSB (ADT7320_L16 |0x00) // Temperature value MSB
72 #define ADT7420_REG_TEMP_LSB 0x01 // Temperature value LSB
73 #define ADT7420_REG_STATUS 0x02 // Status
74 #define ADT7420_REG_CONFIG 0x03 // Configuration
75 #define ADT7420_REG_T_HIGH_MSB (ADT7320_L16 |0x04 )// Temperature HIGH setpoint MSB
76 #define ADT7420_REG_T_HIGH_LSB 0x05 // Temperature HIGH setpoint LSB
77 #define ADT7420_REG_T_LOW_MSB (ADT7320_L16 |0x06) // Temperature LOW setpoint MSB
78 #define ADT7420_REG_T_LOW_LSB 0x07 // Temperature LOW setpoint LSB
79 #define ADT7420_REG_T_CRIT_MSB (ADT7320_L16 |0x08) // Temperature CRIT setpoint MSB
80 #define ADT7420_REG_T_CRIT_LSB 0x09 // Temperature CRIT setpoint LSB
81 #define ADT7420_REG_HIST 0x0A // Temperature HYST setpoint
82 #define ADT7420_REG_ID 0x0B // ID
83 #define ADT7420_REG_RESET 0x2F // Software reset
86 #define ADT7420_STATUS_T_LOW NO_OS_BIT(4)
87 #define ADT7420_STATUS_T_HIGH NO_OS_BIT(5)
88 #define ADT7420_STATUS_T_CRIT NO_OS_BIT(6)
89 #define ADT7420_STATUS_RDY NO_OS_BIT(7)
92 #define ADT7420_CONFIG_OP_MODE(x) ((x) << 5) & (NO_OS_GENMASK(6,5))
93 #define ADT7420_CONFIG_RESOLUTION NO_OS_BIT(7)
96 #define ADT7420_16BIT_NEG NO_OS_BIT(16)
97 #define ADT7420_16BIT_SIGN 0x8000
98 #define ADT7420_16BIT_DIV 128
99 #define ADT7420_13BIT_NEG NO_OS_BIT(13)
100 #define ADT7420_13BIT_SIGN 0x1000
101 #define ADT7420_13BIT_DIV 16
104 #define ADT7420_OP_MODE_CONT_CONV 0
105 #define ADT7420_OP_MODE_ONE_SHOT 1
106 #define ADT7420_OP_MODE_1_SPS 2
107 #define ADT7420_OP_MODE_SHUTDOWN 3
110 #define ADT7xxx_ID 0xC
112 #define ADT7420_RESET_DELAY 1
172 uint16_t register_address, uint16_t *data);
176 uint16_t register_address, uint8_t mask, uint8_t value);
188 uint16_t register_address,
214 uint16_t register_address, uint16_t *data);
218 uint16_t register_address, uint16_t *data);
int32_t adt7420_remove(struct adt7420_dev *dev)
Free the resources allocated by adt7420_init().
Definition: adt7420.c:264
#define ADT7320_ADDR_MSK
Definition: adt7420.h:54
struct no_os_i2c_init_param i2c_init
Definition: adt7420.h:154
float adt7420_get_temperature(struct adt7420_dev *dev)
Reads the temperature data and converts it to Celsius degrees.
Definition: adt7420.c:370
int32_t adt7420_init(struct adt7420_dev **device, struct adt7420_init_param init_param)
Initializes the communication peripheral and checks if the device is present.
Definition: adt7420.c:202
#define ADT7320_REG_CONFIG
Definition: adt7420.h:58
#define ADT7420_13BIT_DIV
Definition: adt7420.h:101
int32_t adt7420_remove(struct adt7420_dev *dev)
Free the resources allocated by adt7420_init().
Definition: adt7420.c:264
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
int adt7420_spi_reg_write(struct adt7420_dev *dev, uint16_t register_address, uint32_t data)
Write a value of a register via SPI.
Definition: adt7420.c:116
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
#define ADT7xxx_ID
Definition: adt7420.h:110
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:159
int adt7420_i2c_reg_write(struct adt7420_dev *dev, uint16_t register_address, uint32_t data)
Write a value of a register via I2C.
Definition: adt7420.c:147
Header file of SPI Interface.
@ ID_ADT7422
Definition: adt7420.h:132
#define ADT7420_RESET_DELAY
Definition: adt7420.h:112
int adt7420_i2c_reg_write(struct adt7420_dev *dev, uint16_t register_address, uint32_t data)
Write a value of a register via I2C.
Definition: adt7420.c:147
int adt7420_i2c_reg_read(struct adt7420_dev *dev, uint16_t register_address, uint16_t *data)
Reads the value of a register I2C interface device.
Definition: adt7420.c:445
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
float adt7420_get_temperature(struct adt7420_dev *dev)
Reads the temperature data and converts it to Celsius degrees.
Definition: adt7420.c:370
@ ID_ADT7420
Definition: adt7420.h:131
Definition: adt7420.h:152
uint8_t resolution_setting
Definition: adt7420.h:147
@ ID_ADT7410
Definition: adt7420.h:130
uint8_t resolution_setting
Definition: adt7420.h:159
#define ADT7420_16BIT_NEG
Definition: adt7420.h:96
int32_t adt7420_reset(struct adt7420_dev *dev)
Resets the SPI or I2C inteface for the ADT7420/ADT7320.
Definition: adt7420.c:340
@ ID_ADT7310
Definition: adt7420.h:133
Definition: ad9361_util.h:69
#define ADT7320_READ_CMD
Definition: adt7420.h:68
int adt7420_reg_read(struct adt7420_dev *dev, uint16_t register_address, uint16_t *data)
Reads the value of a register.
Definition: adt7420.c:75
struct no_os_spi_desc * spi_desc
Definition: adt7420.h:143
@ ID_ADT7312
Definition: adt7420.h:135
const struct adt7420_chip_info chip_info[]
Definition: adt7420.c:43
#define ADT7320_REG_ID
Definition: adt7420.h:60
#define ADT7320_REG_TEMP
Definition: adt7420.h:59
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
@ I2C
Definition: adt7420.h:121
#define ADT7320_L16
Definition: adt7420.h:53
@ I2C
Definition: adxl372.h:317
#define ADT7420_16BIT_DIV
Definition: adt7420.h:98
const struct adt7420_chip_info chip_info[]
Definition: max538x.c:46
@ SPI
Definition: adt7420.h:120
int adt7420_reg_update_bits(struct adt7420_dev *dev, uint16_t register_address, uint8_t mask, uint8_t value)
Sets the value of a register SPI/I2C.
Definition: adt7420.c:94
bool adt7420_is_spi(struct adt7420_dev *dev)
Check if the interface of the selected device is SPI.
Definition: adt7420.c:477
#define ADT7420_CONFIG_RESOLUTION
Definition: adt7420.h:93
#define ADT7420_OP_MODE_SHUTDOWN
Definition: adt7420.h:107
#define ADT7420_13BIT_NEG
Definition: adt7420.h:99
int adt7420_reg_update_bits(struct adt7420_dev *dev, uint16_t register_address, uint8_t mask, uint8_t value)
Sets the value of a register SPI/I2C.
Definition: adt7420.c:94
int adt7420_spi_reg_read(struct adt7420_dev *dev, uint16_t register_address, uint16_t *data)
Reads the value of a register SPI interface device.
Definition: adt7420.c:411
adt7420_type
Definition: adt7420.h:129
int adt7420_set_operation_mode(struct adt7420_dev *dev, uint8_t mode)
Sets the operational mode for ADT7420/ADT7320.
Definition: adt7420.c:289
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
#define ADT7420_REG_ID
Definition: adt7420.h:82
int adt7420_spi_reg_write(struct adt7420_dev *dev, uint16_t register_address, uint32_t data)
Write a value of a register via SPI.
Definition: adt7420.c:116
int adt7420_spi_reg_read(struct adt7420_dev *dev, uint16_t register_address, uint16_t *data)
Reads the value of a register SPI interface device.
Definition: adt7420.c:411
@ ID_ADT7320
Definition: adt7420.h:136
dev_interface
Definition: adt7420.h:119
#define ADT7420_REG_CONFIG
Definition: adt7420.h:74
int adt7420_set_resolution(struct adt7420_dev *dev, uint8_t resolution)
Sets the resolution for ADT7420/ADT7320.
Definition: adt7420.c:315
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
Definition: adt7420.h:151
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
int adt7420_i2c_reg_read(struct adt7420_dev *dev, uint16_t register_address, uint16_t *data)
Reads the value of a register I2C interface device.
Definition: adt7420.c:445
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:43
@ ID_ADT7311
Definition: adt7420.h:134
Header file of I2C Interface.
#define ADT7420_CONFIG_OP_MODE(x)
Definition: adt7420.h:92
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
union adt7420_init_param::interface_type interface_init
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
struct no_os_spi_init_param spi_init
Definition: adt7420.h:156
int32_t adt7420_reset(struct adt7420_dev *dev)
Resets the SPI or I2C inteface for the ADT7420/ADT7320.
Definition: adt7420.c:340
uint8_t resolution
Definition: adt7420.h:125
struct no_os_i2c_desc * i2c_desc
Definition: adt7420.h:141
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
Definition: adt7420.h:124
enum dev_interface communication
Definition: adt7420.h:126
int adt7420_reg_read(struct adt7420_dev *dev, uint16_t register_address, uint16_t *data)
Reads the value of a register.
Definition: adt7420.c:75
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
Definition: adt7420.h:139
enum adt7420_type active_device
Definition: adt7420.h:145
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
#define ADT7320_WRITE_MASK_CMD
Definition: adt7420.h:67
int adt7420_set_operation_mode(struct adt7420_dev *dev, uint8_t mode)
Sets the operational mode for ADT7420/ADT7320.
Definition: adt7420.c:289
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
#define ADT7420_REG_TEMP_MSB
Definition: adt7420.h:71
enum adt7420_type active_device
Definition: adt7420.h:161
Header file of utility functions.
int32_t adt7420_init(struct adt7420_dev **device, struct adt7420_init_param init_param)
Initializes the communication peripheral and checks if the device is present.
Definition: adt7420.c:202
@ SPI
Definition: adxl372.h:316
#define ADT7420_REG_RESET
Definition: adt7420.h:83
int adt7420_reg_write(struct adt7420_dev *dev, uint16_t register_address, uint32_t data)
Sets the value of a register SPI/I2C.
Definition: adt7420.c:178
#define ADT7420_16BIT_SIGN
Definition: adt7420.h:97
int adt7420_set_resolution(struct adt7420_dev *dev, uint8_t resolution)
Sets the resolution for ADT7420/ADT7320.
Definition: adt7420.c:315
int adt7420_reg_write(struct adt7420_dev *dev, uint16_t register_address, uint32_t data)
Sets the value of a register SPI/I2C.
Definition: adt7420.c:178
#define ADT7420_13BIT_SIGN
Definition: adt7420.h:100
bool adt7420_is_spi(struct adt7420_dev *dev)
Check if the interface of the selected device is SPI.
Definition: adt7420.c:477
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
Header file of ADT7420 Driver.