Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC5599.cpp
Go to the documentation of this file.
1 /*!
2 LTC5599: 140 to 1000MHz IQ modulator
3 
4 @verbatim
5 
6 The LTC5599 is an IQ modulator with
7 serial I/O.
8 
9 @endverbatim
10 
11 http://www.linear.com/product/LTC5599
12 
13 http://www.linear.com/product/LTC5599#demoboards
14 
15 
16 Copyright 2018(c) Analog Devices, Inc.
17 
18 All rights reserved.
19 
20 Redistribution and use in source and binary forms, with or without
21 modification, are permitted provided that the following conditions are met:
22  - Redistributions of source code must retain the above copyright
23  notice, this list of conditions and the following disclaimer.
24  - Redistributions in binary form must reproduce the above copyright
25  notice, this list of conditions and the following disclaimer in
26  the documentation and/or other materials provided with the
27  distribution.
28  - Neither the name of Analog Devices, Inc. nor the names of its
29  contributors may be used to endorse or promote products derived
30  from this software without specific prior written permission.
31  - The use of this software may or may not infringe the patent rights
32  of one or more patent holders. This license does not release you
33  from the requirement that you obtain separate licenses from these
34  patent holders to use this software.
35  - Use of the software either in source or binary form, must be run
36  on or directly connected to an Analog Devices Inc. component.
37 
38 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
39 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
40 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
41 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
42 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
44 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 */
49 
50 //! @ingroup RF_Timing
51 //! @{
52 //! @defgroup LTC5599 LTC5599: Direct Conversion I/Q Modulator
53 //! @}
54 
55 /*! @file
56  @ingroup LTC5599
57  Library for LTC5599: Direct Conversion I/Q Modulator
58 */
59 
60 #include <Arduino.h>
61 #include <stdint.h>
62 #include "Linduino.h"
63 #include "LT_SPI.h"
64 #include "LTC5599.h"
65 #include <SPI.h>
66 #include <math.h>
67 
68 
69 // Reads and returns 8-bit data
70 void LTC5599_write_read(uint8_t cs, uint8_t address, uint8_t rw, uint8_t tx, uint8_t *rx)
71 {
72  address = address << 1;
73  union
74  {
75  uint8_t b[2];
76  uint16_t w;
77  } command, data;
78 
79  if (rw == 0) //write
80  {
81  command.b[1] = address;
82  command.b[0] = tx; //write this command byte
83 
84  spi_transfer_word(cs,command.w,&data.w); //write an address byte and a command byte to the device
85  }
86  else
87  {
88  address = address + 0x01;
89  command.b[1] = address;
90  command.b[0] = 0x00; //read into this data byte
91 
92  spi_transfer_word(cs,command.w,&data.w); //write an address byte to the device and read back a byte
93  *rx = data.b[0];
94  }
95 }
Header File for Linduino Libraries and Demo Code.
static uint8_t address
Definition: DC2091A.ino:83
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
void LTC5599_write_read(uint8_t cs, uint8_t address, uint8_t rw, uint8_t tx, uint8_t *rx)
Reads the modulator register and returns 8-bit data.
Definition: LTC5599.cpp:70
void spi_transfer_word(uint8_t cs_pin, uint16_t tx, uint16_t *rx)
Reads and sends a word.
Definition: LT_SPI.cpp:98
LTC5599: 140 to 1000MHz IQ modulator.
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
static uint8_t rw
Definition: DC2091A.ino:84