precision-converters-firmware
adt7xxx_support.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * @file adt7xxx_support.h
3  * @brief Support Header File for adt7xxx
4 ******************************************************************************
5  * Copyright (c) 2021-2022 Analog Devices, Inc.
6  * All rights reserved.
7  *
8  * This software is proprietary to Analog Devices, Inc. and its licensors.
9  * By using this software you agree to the terms of the associated
10  * Analog Devices Software License Agreement.
11 *****************************************************************************/
12 
13 #ifndef _ADT7XXX_SUPPORT_H
14 #define _ADT7XXX_SUPPORT_H
15 
16 /******************************************************************************/
17 /********************** Macros and Constants Definition ***********************/
18 /******************************************************************************/
19 
20 /* ADT7420 bit mask */
21 #define ADT7420_LSB_MASK 0x00FF
22 #define ADT7420_MSB_MASK 0xFF00
23 #define ADT7420_LSB_OFFSET 0
24 #define ADT7420_MSB_OFFSET 8
25 #define ADT7420_CONFIG_CT_POL NO_OS_BIT(2)
26 #define ADT7420_CONFIG_FAULT_QUEUE(x) ((x) & 0x3)
27 #define ADT7420_CONFIG_INT_POL NO_OS_BIT(3)
28 #define ADT7420_CONFIG_INT_CT_MODE NO_OS_BIT(4)
29 #define ADT7420_MASK_SET_PT_REGISTER 0x00
30 
31 /* ADT7420_CONFIG_FAULT_QUEUE(x) options */
32 #define ADT7420_FAULT_QUEUE_1_FAULT 0
33 #define ADT7420_FAULT_QUEUE_2_FAULTS 1
34 #define ADT7420_FAULT_QUEUE_3_FAULTS 2
35 #define ADT7420_FAULT_QUEUE_4_FAULTS 3
36 
37 /* ADT7xxx default ID */
38 #define ADT7320_DEFAULT_ID 0xC3
39 #define ADT7420_DEFAULT_ID 0xCB
40 
41 /******************************************************************************/
42 /******************** Variables and User Defined Data Types *******************/
43 /******************************************************************************/
44 
45 typedef enum {
46  REG_TEMP, // Temperature value
47  REG_STATUS, // status info
48  REG_CONFIG, // Configuration
49  REG_T_CRIT, // Temperature CRIT setpoint (147'C)
50  REG_HIST, // Temperature HYST setpoint (5'C)
51  REG_T_HIGH, // Temperature HIGH setpoint (64'C)
52  REG_T_LOW, // Temperature LOW setpoint (10'C)
53  REG_ID, // ID value
54  REG_RESET
56 
57 /******************************************************************************/
58 /************************** Functions Declarations ****************************/
59 /******************************************************************************/
60 
62 int32_t adt7420_set_fault_queue(struct adt7420_dev *dev,
63  uint8_t mode);
64 
66 int32_t adt7420_set_ct_int_mode(struct adt7420_dev *dev,
67  uint8_t setting);
68 
70 int32_t adt7420_set_ct_int_polarity(struct adt7420_dev *dev,
71  uint8_t polarity);
72 
74 int32_t adt7420_wr_setpoint_reg(struct adt7420_dev *device,
75  uint16_t register_value,
76  uint16_t data);
77 
79 uint16_t configure_write_type_registers(struct adt7420_dev *dev,
80  uint16_t register_address);
81 
83 int32_t adt7420_get_register_address_and_value(struct adt7420_dev *dev,
84  uint16_t register_address, uint16_t *reg_val);
85 #endif // _ADT7XXX_SUPPORT_H
struct ad5933_dev * device
Definition: main.c:77
int32_t adt7420_get_register_address_and_value(struct adt7420_dev *dev, uint16_t register_address, uint16_t *reg_val)
Reads the value of a register SPI/I2C.
Definition: adt7xxx_support.c:39
int32_t adt7420_wr_setpoint_reg(struct adt7420_dev *device, uint16_t register_value, uint16_t data)
Write to a setpoint register.
Definition: adt7xxx_support.c:225
int32_t adt7420_set_ct_int_polarity(struct adt7420_dev *dev, uint8_t polarity)
Sets output polarity for the pins CT/INT (Critical Temp - Over/Under Temp).
Definition: adt7xxx_support.c:330
int32_t adt7420_set_ct_int_mode(struct adt7420_dev *dev, uint8_t setting)
Sets comparator/interrupt (CT/INT) mode for ADT7420/ADT7320.
Definition: adt7xxx_support.c:298
registers_e
Definition: adt7xxx_support.h:45
@ REG_CONFIG
Definition: adt7xxx_support.h:48
@ REG_T_HIGH
Definition: adt7xxx_support.h:51
@ REG_TEMP
Definition: adt7xxx_support.h:46
@ REG_ID
Definition: adt7xxx_support.h:53
@ REG_RESET
Definition: adt7xxx_support.h:54
@ REG_T_LOW
Definition: adt7xxx_support.h:52
@ REG_T_CRIT
Definition: adt7xxx_support.h:49
@ REG_HIST
Definition: adt7xxx_support.h:50
@ REG_STATUS
Definition: adt7xxx_support.h:47
int32_t adt7420_set_fault_queue(struct adt7420_dev *dev, uint8_t mode)
Sets the Fault Queue option for ADT7420/ADT7320.
Definition: adt7xxx_support.c:265
uint16_t configure_write_type_registers(struct adt7420_dev *dev, uint16_t register_address)
Configure write typev register based on communication interface.
Definition: adt7xxx_support.c:152