| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

sandbox.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology Sandbox
3 @verbatim
4
5 NOTES
6 Setup:
7 Set the terminal baud rate to 115200 and select the newline terminator.
8
9 @endverbatim
10
11 http://www.linear.com/product/LTC3880
12
13 http://www.linear.com/product/LTC2974
14
15 http://www.linear.com/product/LTC2977
16
17 http://www.linear.com/demo/DC1962C
18
19 Copyright 2018(c) Analog Devices, Inc.
20
21 All rights reserved.
22
23 Redistribution and use in source and binary forms, with or without
24 modification, are permitted provided that the following conditions are met:
25 - Redistributions of source code must retain the above copyright
26 notice, this list of conditions and the following disclaimer.
27 - Redistributions in binary form must reproduce the above copyright
28 notice, this list of conditions and the following disclaimer in
29 the documentation and/or other materials provided with the
30 distribution.
31 - Neither the name of Analog Devices, Inc. nor the names of its
32 contributors may be used to endorse or promote products derived
33 from this software without specific prior written permission.
34 - The use of this software may or may not infringe the patent rights
35 of one or more patent holders. This license does not release you
36 from the requirement that you obtain separate licenses from these
37 patent holders to use this software.
38 - Use of the software either in source or binary form, must be run
39 on or directly connected to an Analog Devices Inc. component.
40
41 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
42 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
43 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
45 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
47 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
48 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 */
52
53 /*! @file
54 @ingroup Sandbox
55 */
56
57 #include <Arduino.h>
58 #include <stdint.h>
59 #include <Linduino.h>
60 #include <UserInterface.h>
61 #include <LT_Wire.h>
62 #include <LT_I2CBus.h>
63 #include <LT_SMBus.h>
64 #include <LT_SMBusBase.h>
65 #include <LT_SMBusNoPec.h>
66 #include <LT_SMBusGroup.h>
67 #include <LT_SMBusPec.h>
68 #include <LT_PMBusMath.h>
69 #include <LT_PMBus.h>
70
71 // Global variables
72 static LT_SMBus *smbus = new LT_SMBusNoPec();
73 static LT_PMBus *pmbus = new LT_PMBus(smbus);
74 static LT_I2CBus *i2cbus = smbus->i2cbus();
75
76 //! Initialize Linduino
77 //! @return void
78 void setup()
79 {
80 Serial.begin(115200); //! Initialize the serial port to the PC
81 print_title();
82 print_prompt();
83 }
84
85 //! Repeats Linduino loop
86 //! @return void
87 void loop()
88 {
89 uint8_t user_command;
90
91 if (Serial.available()) //! Checks for user input
92 {
93 user_command = read_int(); //! Reads the user command
94 if (user_command != 'm')
95 Serial.println(user_command);
96
97 switch (user_command) //! Prints the appropriate submenu
98 {
99 case 1:
100 // Add code here by pasting code snippets from LTpowerPlay
101 break;
102 default:
103 Serial.println(F("Incorrect Option"));
104 break;
105 }
106 print_prompt();
107 }
108
109 }
110
111 //! Prints the title block when program first starts.
112 //! @return void
113 void print_title()
114 {
115 Serial.print(F("\n*****************************************************************\n"));
116 Serial.print(F("* Sandbox Demonstration Program *\n"));
117 Serial.print(F("* *\n"));
118 Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
119 Serial.print(F("* *\n"));
120 Serial.print(F("*****************************************************************\n"));
121 }
122
123 //! Prints main menu.
124 //! @return void
125 void print_prompt()
126 {
127 Serial.print(F("\n 1-Command\n"));
128 Serial.print(F("\nEnter a command:"));
129 }
130
131
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
LT_SMBus.h
LTC SMBus Support: API for a shared SMBus layer.
LT_SMBusGroup.h
LTC SMBus Support: Implementation for a shared SMBus layer.
LT_SMBusPec.h
LTC SMBus Support: Implementation for a shared SMBus layer.
print_title
static void print_title()
Prints the title block when program first starts.
Definition: sandbox.ino:113
Linduino.h
Header File for Linduino Libraries and Demo Code.
LT_SMBusNoPec
Definition: LT_SMBusNoPec.h:60
print_prompt
static void print_prompt()
Prints main menu.
Definition: sandbox.ino:125
LT_Wire.h
TwoWire.h - TWI/I2C library for Arduino & Wiring Copyright (c) 2006 Nicholas Zambetti.
LT_SMBus
Definition: LT_SMBus.h:61
LT_I2CBus.h
LT_I2CBus: Routines to communicate to I2C by Wire Library.
LT_I2CBus
Definition: LT_I2CBus.h:50
i2cbus
static LT_I2CBus * i2cbus
Definition: sandbox.ino:74
pmbus
static LT_PMBus * pmbus
Definition: sandbox.ino:73
setup
static void setup()
Initialize Linduino.
Definition: sandbox.ino:78
LT_SMBusNoPec.h
LTC SMBus Support: Implementation for a shared SMBus layer.
LT_SMBus::i2cbus
virtual LT_I2CBus * i2cbus(void)=0
UserInterface.h
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
smbus
static LT_SMBus * smbus
Definition: sandbox.ino:72
loop
static void loop()
Repeats Linduino loop.
Definition: sandbox.ino:87
LT_PMBus.h
LTC PMBus Support.
LT_PMBusMath.h
LTC PMBus Support: Math conversion routines.
LT_SMBusBase.h
LTC SMBus Support: Implementation for a shared SMBus layer.
LT_PMBus
PMBus communication.
Definition: LT_PMBus.h:370