| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC6954.h
Go to the documentation of this file.
1 /*!
2 LTC6954: Low Phase Noise, Triple Output Clock Distribution Divider/Driver
3
4 @verbatim
5 SPI DATA FORMAT (MSB First):
6
7 Write Sequence:
8 Byte #1 Byte #2
9 MOSI: A6 A5 A4 A3 A2 A1 A0 W D7 D6 D5 D4 D3 D2 D1 D0
10 MISO: X X X X X X X X X X X X X X X X
11
12 Read Sequence:
13 Byte #1 Byte #2
14 MOSI: A6 A5 A4 A3 A2 A1 A0 R X X X X X X X X
15 MISO: X X X X X X X X D7 D6 D5 D4 D3 D2 D1 D0
16
17 W : SPI Write (0)
18 R : SPI Read (1)
19 Ax : Address
20 Dx : Data Bits
21 X : Don't care
22
23 @endverbatim
24
25 http://www.linear.com/product/LTC6954
26
27 http://www.linear.com/product/LTC6954#demoboards
28
29
30 Copyright 2018(c) Analog Devices, Inc.
31
32 All rights reserved.
33
34 Redistribution and use in source and binary forms, with or without
35 modification, are permitted provided that the following conditions are met:
36 - Redistributions of source code must retain the above copyright
37 notice, this list of conditions and the following disclaimer.
38 - Redistributions in binary form must reproduce the above copyright
39 notice, this list of conditions and the following disclaimer in
40 the documentation and/or other materials provided with the
41 distribution.
42 - Neither the name of Analog Devices, Inc. nor the names of its
43 contributors may be used to endorse or promote products derived
44 from this software without specific prior written permission.
45 - The use of this software may or may not infringe the patent rights
46 of one or more patent holders. This license does not release you
47 from the requirement that you obtain separate licenses from these
48 patent holders to use this software.
49 - Use of the software either in source or binary form, must be run
50 on or directly connected to an Analog Devices Inc. component.
51
52 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
53 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
54 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
55 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
56 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
58 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
59 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
60 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 */
63
64 /*! @file
65 @ingroup LTC6954
66 Header for LTC6954: Low Phase Noise, Triple Output Clock Distribution Divider/Driver
67 */
68
69 #ifndef LTC6954_H
70
71 #define LTC6954_H
72
73
74 //! Define the SPI CS pin
75 #ifndef LTC6954_CS
76 #define LTC6954_CS QUIKEVAL_CS //! SPI Chip Select Pin
77 #endif
78
79
80 /*! @name LTC6954 Registers Fields in Alphabetical Order */
81 #define LTC6954_CMSINV0 1 //!< for spi_map array, defines location for field specific information used to create the spi map
82 #define LTC6954_CMSINV1 2 //!< for spi_map array, defines location for field specific information used to create the spi map
83 #define LTC6954_CMSINV2 3 //!< for spi_map array, defines location for field specific information used to create the spi map
84 #define LTC6954_DEL0 4 //!< for spi_map array, defines location for field specific information used to create the spi map
85 #define LTC6954_DEL1 5 //!< for spi_map array, defines location for field specific information used to create the spi map
86 #define LTC6954_DEL2 6 //!< for spi_map array, defines location for field specific information used to create the spi map
87 #define LTC6954_LVCS0 7 //!< for spi_map array, defines location for field specific information used to create the spi map
88 #define LTC6954_LVCS1 8 //!< for spi_map array, defines location for field specific information used to create the spi map
89 #define LTC6954_LVCS2 9 //!< for spi_map array, defines location for field specific information used to create the spi map
90 #define LTC6954_M0 10 //!< for spi_map array, defines location for field specific information used to create the spi map
91 #define LTC6954_M1 11 //!< for spi_map array, defines location for field specific information used to create the spi map
92 #define LTC6954_M2 12 //!< for spi_map array, defines location for field specific information used to create the spi map
93 #define LTC6954_PART 13 //!< for spi_map array, defines location for field specific information used to create the spi map
94 #define LTC6954_PDALL 14 //!< for spi_map array, defines location for field specific information used to create the spi map
95 #define LTC6954_PD_DIV0 15 //!< for spi_map array, defines location for field specific information used to create the spi map
96 #define LTC6954_PD_DIV1 16 //!< for spi_map array, defines location for field specific information used to create the spi map
97 #define LTC6954_PD_DIV2 17 //!< for spi_map array, defines location for field specific information used to create the spi map
98 #define LTC6954_PD_OUT0 18 //!< for spi_map array, defines location for field specific information used to create the spi map
99 #define LTC6954_PD_OUT1 19 //!< for spi_map array, defines location for field specific information used to create the spi map
100 #define LTC6954_PD_OUT2 20 //!< for spi_map array, defines location for field specific information used to create the spi map
101 #define LTC6954_REV 21 //!< for spi_map array, defines location for field specific information used to create the spi map
102 #define LTC6954_SYNC_EN0 22 //!< for spi_map array, defines location for field specific information used to create the spi map
103 #define LTC6954_SYNC_EN1 23 //!< for spi_map array, defines location for field specific information used to create the spi map
104 #define LTC6954_SYNC_EN2 24 //!< for spi_map array, defines location for field specific information used to create the spi map
105
106 #define LTC6954_NUM_REGADDR 8 //!< Defines number of LTC6954 SPI registers, used in spi_map array
107 #define LTC6954_NUM_REGFIELD 24 //!< Defines number of LTC6954 SPI fields, used in spi_map array
108
109 #define ADDRx 0 //!< used for 2nd dim of 2d spi_map array
110 #define DxMSB 1 //!< used for 2nd dim of 2d spi_map array
111 #define NUMBITS 2 //!< used for 2nd dim of 2d spi_map array
112 #define R_ONLY 3 //!< used for 2nd dim of 2d spi_map array
113
114
115 //! @} */
116
117 /* ------------------------------------------------------------------------- */
118 //! LTC6954 Read Single Address
119 //! reads 8 bit Data field to LTC6954.
120 //! has to shift data by one bit to account for RW bit
121 //! @return data that was read from address
122 uint8_t LTC6954_read(uint8_t cs, //!< Chip Select Pin
123 int8_t address //!< Register address for the LTC6954.
124 );
125
126
127 /* ------------------------------------------------------------------------- */
128 //! LTC6954 Read Single Field
129 //! For SPI FIELDS located in 1 or multiple address locations
130 //! reads specific address locations
131 //! identifies and returns specific field in question
132 //! can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
133 //! @return data that was read from field
134 long LTC6954_read_field(uint8_t cs, //!< Chip Select Pin
135 uint8_t address, //!< Register address for the LTC6954.
136 uint8_t MSB_loc, //!< MSB bit location of field
137 uint8_t numbits //!< length of field (i.e. number of bits in field)
138 );
139
140
141 /* ------------------------------------------------------------------------- */
142 //! Gets the LTC6954 SPI field value
143 //! calls function LTC6954_read_field, which
144 //! reads specific address locations
145 //! identifies and returns specific field in question
146 //! can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
147 //! @return data that was read from field
148 long get_LTC6954_SPI_FIELD(uint8_t cs, //!< Chip Select Pin
149 uint8_t f //!< SPI field number
150 );
151
152
153 /* ------------------------------------------------------------------------- */
154 //! LTC6954 Write Single Address
155 //! writes 8 bit Data field to LTC6954.
156 //! has to shift data by one bit to account for RW bit
157 //! @return void
158 void LTC6954_write(uint8_t cs, //!< Chip Select Pin
159 uint8_t address, //!< Register address for the LTC6954.
160 uint8_t Data //!< 8-bit data to be written to register
161 );
162
163
164 /* ------------------------------------------------------------------------- */
165 //! LTC6954 Write Single Field
166 //! For SPI FIELDS in 1 or multiple address locations
167 //! reads specific address/field location then writes to specific field
168 //! can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
169 //! @return void
170 uint8_t LTC6954_write_field(uint8_t cs, //!< Chip Select Pin
171 long field_data, //!< Value field value to be set to
172 uint8_t address, //!< Register address for the LTC6954.
173 uint8_t MSB_loc, //!< MSB bit location of field
174 uint8_t numbits //!< length of field (i.e. number of bits in field)
175 );
176
177
178 /* ------------------------------------------------------------------------- */
179 //! Sets the LTC6954 SPI field value
180 //! calls function LTC6954_read_field, which
181 //! reads specific address/field location then writes to specific field
182 //! can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
183 //! @return void
184 void set_LTC6954_SPI_FIELD(uint8_t cs, //!< Chip Select Pin
185 uint8_t f, //!< SPI field number
186 long field_data //!< Value field value to be set to
187 );
188
189
190 /* ------------------------------------------------------------------------- */
191 //! Writes values to ALL LTC6954 RW address
192 //! @return void
193 void set_LTC6954_ALLREGS(uint8_t cs, //!< Chip Select Pin
194 uint8_t reg00, //!< LTC6954 register 0
195 uint8_t reg01, //!< LTC6954 register 1
196 uint8_t reg02, //!< LTC6954 register 2
197 uint8_t reg03, //!< LTC6954 register 3
198 uint8_t reg04, //!< LTC6954 register 4
199 uint8_t reg05, //!< LTC6954 register 5
200 uint8_t reg06 //!< LTC6954 register 6
201 );
202
203 /* ------------------------------------------------------------------------- */
204 //! Initializes the SPI MAP arrays
205 //! The values set in initialization are used all the LTC6954 SPI/WRITE and
206 //! read functions (set_LTC6954_SPI_FIELD, get_LTC6954_SPI_FIELD,
207 //! LTC6954_read, LTC6954_write, etc, etc)
208 //! @return void
209 void LTC6954_init();
210
211
212 /* ------------------------------------------------------------------------- */
213 //! returns # of addresses in parts register map (array size)
214 //! @return # of addresses in parts register map
215 uint8_t get_LTC6954_REGSIZE();
216
217
218 /* ------------------------------------------------------------------------- */
219 //! returns the number of bits for a given field name in the SPI map
220 //! @return the number of bits for a given field name in the SPI map
221 uint8_t get_LTC6954_SPI_FIELD_NUMBITS(uint8_t f //!< SPI field number
222 );
223
224
225 /* ------------------------------------------------------------------------- */
226 //! returns if the given field name is (0)read/write or (1)read_only field
227 //! @return if the given field is a (0)read/write or (1)read_only field
228 uint8_t get_LTC6954_SPI_FIELD_RW(uint8_t f //!< SPI field number
229 ) ;
230
231
232
233 #endif // LTC6954_H
set_LTC6954_SPI_FIELD
void set_LTC6954_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
Sets the LTC6954 SPI field value calls function LTC6954_read_field, which reads specific address/fiel...
Definition: LTC6954.cpp:272
LTC6954_init
void LTC6954_init()
Initializes the SPI MAP arrays The values set in initialization are used all the LTC6954 SPI/WRITE an...
Definition: LTC6954.cpp:304
get_LTC6954_SPI_FIELD_NUMBITS
uint8_t get_LTC6954_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in the SPI map
Definition: LTC6954.cpp:249
get_LTC6954_SPI_FIELD
long get_LTC6954_SPI_FIELD(uint8_t cs, uint8_t f)
Gets the LTC6954 SPI field value calls function LTC6954_read_field, which reads specific address loca...
Definition: LTC6954.cpp:161
set_LTC6954_ALLREGS
void set_LTC6954_ALLREGS(uint8_t cs, uint8_t reg00, uint8_t reg01, uint8_t reg02, uint8_t reg03, uint8_t reg04, uint8_t reg05, uint8_t reg06)
Writes values to ALL LTC6954 RW address.
Definition: LTC6954.cpp:282
get_LTC6954_SPI_FIELD_RW
uint8_t get_LTC6954_SPI_FIELD_RW(uint8_t f)
returns if the given field name is (0)read/write or (1)read_only field
Definition: LTC6954.cpp:259
address
static uint8_t address
Definition: DC2091A.ino:83
LTC6954_write
void LTC6954_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6954 Write Single Address writes 8 bit Data field to LTC6954.
Definition: LTC6954.cpp:172
LTC6954_read
uint8_t LTC6954_read(uint8_t cs, int8_t address)
LTC6954 Read Single Address reads 8 bit Data field to LTC6954.
Definition: LTC6954.cpp:105
LTC6954_write_field
uint8_t LTC6954_write_field(uint8_t cs, long field_data, uint8_t address, uint8_t MSB_loc, uint8_t numbits)
LTC6954 Write Single Field For SPI FIELDS in 1 or multiple address locations reads specific address/f...
Definition: LTC6954.cpp:188
get_LTC6954_REGSIZE
uint8_t get_LTC6954_REGSIZE()
returns # of addresses in parts register map (array size)
Definition: LTC6954.cpp:239
LTC6954_read_field
long LTC6954_read_field(uint8_t cs, uint8_t address, uint8_t MSB_loc, uint8_t numbits)
LTC6954 Read Single Field For SPI FIELDS located in 1 or multiple address locations reads specific ad...
Definition: LTC6954.cpp:125