no-OS
Loading...
Searching...
No Matches
ad51xx_cmd.h
Go to the documentation of this file.
1/*******************************************************************************
2 * @file ad51xx_cmd.h
3 * @brief Header file for the AD51xx digital potentiometer drivers commands.
4********************************************************************************
5Copyright 2025(c) Analog Devices, Inc.
6
7Redistribution and use in source and binary forms, with or without
8modification, are permitted provided that the following conditions are met:
9
101. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
173. Neither the name of Analog Devices, Inc. nor the names of its
18 contributors may be used to endorse or promote products derived from this
19 software without specific prior written permission.
20
21THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
22IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
24EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
25INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
27OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*******************************************************************************/
32#ifndef AD51XX_CMD_H_
33#define AD51XX_CMD_H_
34/*
35 * Command format of the Digipot family AD51xx
36 * C[3-1] ==> Command Bits
37 * A[3-1] ==> address Bits
38 * D[7-1] ==> data Bits
39 * +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
40 * | C3 | C2 | C1 | C0 | A3 | A2 | A1 | A0 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
41 * +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
42 */
43/* Bit mask and position for the command bits */
44#define CMD_BITS_POSITION 12
45#define CMD_BITS_MASK 0xF000
46
47#define ADS_BITS_POSITION 8
48#define ADS_BITS_MASK 0x0F00
49
50
51#define DATA_BITS_POSITION 0
52#define DATA_BITS_MASK 0x00FF
53
54#define OPERATING_MODE_BIT_MASK 0XFB
55#define OPERATING_MODE_BIT_POSITION 0x02
56
57
58#define EXTRACT_CMD_BITS(x) (x&CMD_BITS_MASK)>>CMD_BITS_POSITION
59#define EXTRACT_ADS_BITS(x) (x&ADS_BITS_MASK)>>ADS_BITS_POSITION
60#define EXTRACT_DATA_BITS(x) (x&DATA_BITS_MASK)>>DATA_BITS_POSITION
61
62#define AD51XX_CMD_SW_RESET (0x0B<<CMD_BITS_POSITION|0x00)
63
64#define AD51XX_CMD_WRITE_RDAC_REG (0x01<<CMD_BITS_POSITION|0x00)
65#define AD51XX_CMD_WRITE_INP_REG (0x02<<CMD_BITS_POSITION|0x00)
66
67#define AD51XX_CMD_READ_INP_REG (0x03<<CMD_BITS_POSITION|0x00)
68#define AD51XX_CMD_READ_EEPROM (0x03<<CMD_BITS_POSITION|0x01)
69#define AD51XX_CMD_READ_CTL_REG (0x03<<CMD_BITS_POSITION|0x02)
70#define AD51XX_CMD_READ_RDAC_REG (0x03<<CMD_BITS_POSITION|0x03)
71
72#define AD51XX_CMD_LRDAC_INC (0x04<<CMD_BITS_POSITION|0x01)
73#define AD51XX_CMD_LRDAC_DEC (0x04<<CMD_BITS_POSITION|0x00)
74#define AD51XX_CMD_LRDAC_6DB_INC (0x05<<CMD_BITS_POSITION|0x01)
75#define AD51XX_CMD_LRDAC_6DB_DEC (0x05<<CMD_BITS_POSITION|0x00)
76#define AD51XX_CMD_COPY_INP_REG_TO_RDAC (0x06<<CMD_BITS_POSITION|0x00)
77#define AD51XX_CMD_COPY_RDAC_TO_EEPROM (0x07<<CMD_BITS_POSITION|0x01)
78#define AD51XX_CMD_COPY_EEPROM_TO_RDAC (0x07<<CMD_BITS_POSITION|0x00)
79
80#define AD51XX_CMD_TOP_SCALE_ENTER (0x09<<CMD_BITS_POSITION|0x81)
81#define AD51XX_CMD_TOP_SCALE_EXIT (0x09<<CMD_BITS_POSITION|0x80)
82
83#define AD51XX_CMD_BOTTOM_SCALE_ENTER (0x09<<CMD_BITS_POSITION|0x01)
84#define AD51XX_CMD_BOTTOM_SCALE_EXIT (0x09<<CMD_BITS_POSITION|0x00)
85
86
87#define AD51XX_CMD_ENTER_SHUTDOWN (0x0C<<CMD_BITS_POSITION|0x01)
88#define AD51XX_CMD_ENTER_NORMAL_MODE (0x0C<<CMD_BITS_POSITION|0x00)
89
90#define AD51XX_CMD_WRITE_TO_EEPROM (0x08<<CMD_BITS_POSITION|0x00)
91#define AD51XX_CMD_WRITE_SERIAL_REG_TO_CTL (0x0D<<CMD_BITS_POSITION|0x00)
92
93#endif // AD51XX_CMD_H_