| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC2091A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC2091A Demonstration Board.
3 LTC5599: 130 to 1300MHz IQ Modulator.
4
5 @verbatim
6
7 NOTES
8 Setup:
9 Set the terminal baud rate to 115200 and select the newline terminator.
10
11 USER INPUT DATA FORMAT:
12 decimal : 1024
13 hex : 0x400
14 octal : 02000 (leading 0 "zero")
15 binary : B10000000000
16 float : 1024.0
17
18 @endverbatim
19
20 http://www.linear.com/product/LTC5599
21
22 http://www.linear.com/product/LTC5599#demoboards
23
24
25 Copyright 2018(c) Analog Devices, Inc.
26
27 All rights reserved.
28
29 Redistribution and use in source and binary forms, with or without
30 modification, are permitted provided that the following conditions are met:
31 - Redistributions of source code must retain the above copyright
32 notice, this list of conditions and the following disclaimer.
33 - Redistributions in binary form must reproduce the above copyright
34 notice, this list of conditions and the following disclaimer in
35 the documentation and/or other materials provided with the
36 distribution.
37 - Neither the name of Analog Devices, Inc. nor the names of its
38 contributors may be used to endorse or promote products derived
39 from this software without specific prior written permission.
40 - The use of this software may or may not infringe the patent rights
41 of one or more patent holders. This license does not release you
42 from the requirement that you obtain separate licenses from these
43 patent holders to use this software.
44 - Use of the software either in source or binary form, must be run
45 on or directly connected to an Analog Devices Inc. component.
46
47 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
48 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
49 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
51 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
53 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 */
58
59 /*! @file
60 @ingroup LTC5599
61 */
62
63 #include <Arduino.h>
64 #include <stdint.h>
65 #include "Linduino.h"
66 #include "LT_SPI.h"
67 #include "UserInterface.h"
68 #include "LT_I2C.h"
69 #include "QuikEval_EEPROM.h"
70 #include "LTC5599.h"
71 #include <SPI.h>
72 #include <Wire.h>
73
74 // Function Declaration
75 void print_title(); // Print the title block
76 void print_prompt(); // Prompt the user for an input command
77 void print_user_command(uint8_t menu); // Display selected differential channels
78
79 void menu_1_read_register();
80 void menu_2_write_register();
81
82 //Global variables
83 uint8_t address;
84 uint8_t rw;
85
86 //! Initialize Linduino
87 void setup()
88 {
89 char demo_name[]="DC2091"; //!< Demo Board Name stored in QuikEval EEPROM
90 quikeval_I2C_init(); // Configure the EEPROM I2C port for 100kHz
91 quikeval_SPI_init(); // Configure the spi port for 4MHz SCK
92 quikeval_SPI_connect(); // Connect SPI to main data port
93 Serial.begin(115200); // Initialize the serial port to the PC
94 print_title();
95 print_prompt();
96 }
97
98
99 //! Repeats Linduino loop
100 void loop()
101 {
102 uint16_t user_command;
103
104 if (Serial.available())
105 {
106 user_command = read_int(); // Read the user command
107 if (user_command != 'm')
108 Serial.println(user_command); // Prints the user command to com port
109 switch (user_command)
110 {
111 case 1:
112 menu_1_read_register();
113 break;
114 case 2:
115 menu_2_write_register();
116 break;
117 default:
118 Serial.println("Invalid Option");
119 break;
120 }
121 Serial.println();
122 print_prompt();
123 }
124 }
125
126
127 // Function Definitions
128 //! Read register
129 //! @ return void
130 void menu_1_read_register()
131 {
132 uint8_t write_byte = 0;
133 uint8_t readback_byte;
134 // uint8_t address;
135
136 Serial.println();
137 Serial.print(F("Enter the desired register address in HEX (precede with '0x'): "));
138 address = read_int();
139 Serial.println(address, HEX);
140 Serial.println(F(""));
141
142 rw = LTC5599_READ; //set to read
143 LTC5599_write_read(LTC5599_CS, address, rw, write_byte, &readback_byte);
144
145 Serial.println(F(""));
146 Serial.print(F("Readback byte (in hex): "));
147 Serial.println(readback_byte, HEX);
148 Serial.print(F("Readback byte (in binary): "));
149 Serial.println(readback_byte, BIN);
150 }
151
152
153 //! Write to register & readback
154 //! @ return void
155 void menu_2_write_register()
156 {
157 uint8_t write_byte;
158 uint8_t readback_byte;
159 // uint8_t address;
160
161 Serial.println();
162 Serial.print(F("Enter the desired register address in HEX (precede with '0x'): "));
163 address = read_int();
164 Serial.println(address, HEX);
165 Serial.println(F(""));
166
167 Serial.println();
168 Serial.print(F("Enter the desired register byte in HEX: "));
169 write_byte = read_int();
170 Serial.println(write_byte, HEX);
171 Serial.println(F(""));
172
173 rw = LTC5599_WRITE; //set to write
174 LTC5599_write_read(LTC5599_CS, address, rw, write_byte, &readback_byte);
175
176 rw = LTC5599_READ; //set to read
177 LTC5599_write_read(LTC5599_CS, address, rw, write_byte, &readback_byte);
178
179 Serial.print(F("Readback byte (in hex): "));
180 Serial.println(readback_byte, HEX);
181 Serial.print(F("Readback byte (in binary): "));
182 Serial.println(readback_byte, BIN);
183 }
184
185
186 //! Prints the title block when program first starts.
187 void print_title()
188 {
189 Serial.println();
190 Serial.println(F("*****************************************************************"));
191 Serial.println(F("* DC2091A Demonstration Program *"));
192 Serial.println(F("* *"));
193 Serial.println(F("* This program demonstrates how to send data *"));
194 Serial.println(F("* to the LTC5599 IQ modulator. *"));
195 Serial.println(F("* *"));
196 Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
197 Serial.println(F("* *"));
198 Serial.println(F("*****************************************************************"));
199 }
200
201
202 //! Prints main menu.
203 void print_prompt()
204 {
205 Serial.println(F(" 1-Read Register"));
206 Serial.println(F(" 2-Write Register"));
207 Serial.println();
208 Serial.print(F("Enter a command: "));
209 }
210
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
setup
static void setup()
Initialize Linduino.
Definition: DC2091A.ino:87
Linduino.h
Header File for Linduino Libraries and Demo Code.
address
static uint8_t address
Definition: DC2091A.ino:83
print_user_command
static void print_user_command(uint8_t menu)
LTC5599_write_read
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
LTC5599_WRITE
#define LTC5599_WRITE
Definition: LTC5599.h:66
QuikEval_EEPROM.h
QuikEval EEPROM Library.
print_prompt
static void print_prompt()
Prints main menu.
Definition: DC2091A.ino:203
menu_1_read_register
static void menu_1_read_register()
Read register @ return void.
Definition: DC2091A.ino:130
quikeval_SPI_init
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
Definition: LT_SPI.cpp:151
LTC5599.h
LTC5599: 140 to 1000MHz IQ modulator.
print_title
static void print_title()
Prints the title block when program first starts.
Definition: DC2091A.ino:187
menu_2_write_register
static void menu_2_write_register()
Write to register & readback @ return void.
Definition: DC2091A.ino:155
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LTC5599_READ
#define LTC5599_READ
Definition: LTC5599.h:68
LTC5599_CS
#define LTC5599_CS
Define the SPI CS pin.
Definition: LTC5599.h:60
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
demo_name
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
quikeval_SPI_connect
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
Definition: LT_SPI.cpp:138
UserInterface.h
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
loop
static void loop()
Repeats Linduino loop.
Definition: DC2091A.ino:100
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
rw
static uint8_t rw
Definition: DC2091A.ino:84