Sunshine Grace Cabatan
/
EVAL-AD910x
Example program for EVAL-AD9106 and EVAL-AD9102
Diff: main.cpp
- Revision:
- 0:3c9cc352dbfc
- Child:
- 1:b9d129e45c30
diff -r 000000000000 -r 3c9cc352dbfc main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jul 06 16:29:51 2020 +0000 @@ -0,0 +1,125 @@ +/* Copyright (c) 2019 Analog Devices, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + - Modified versions of the software must be conspicuously marked as such. + - This software is licensed solely and exclusively for use with processors/products + manufactured by or for Analog Devices, Inc. + - This software may not be combined or merged with other code in any manner + that would cause the software to become subject to terms and conditions which + differ from those listed here. + - Neither the name of Analog Devices, Inc. nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + - The use of this software ma y or may not infringe the patent rights of one or + more patent holders. This license does not release you from the requirement + that you obtain separate licenses from these patent holders to use this software. + +THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, +TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL +PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +2019-01-10-7CBSD SLA + +*/ + +/***Libraries***/ +#include <stdio.h> /*Standard Library*/ +#include "mbed.h" /*mbed header file*/ + +/***Defines for UART Protocol***/ +#define BAUD_RATE 115200 /*Baud Rate*/ + +/*Configure and instantiate UART protocol + and baud rate*/ +Serial port(USBTX, USBRX, BAUD_RATE); + +/***Function Declarations***/ + +/*Print Information about Program's purpose*/ +static void print_title(void); + +/*Print Instructions on how to use Program*/ +static void print_prompt(void); + +int main() +{ + uint8_t user_command; /*User input variable*/ + uint8_t connected = 1; /*Initialize SPI*/ + + print_title(); + + while(connected == 1) { + print_prompt(); + port.scanf("%2d", (int *) &user_command); + switch (user_command) { + case 1: + port.printf("Case 1\n\n"); + break; + + case 2: + port.printf("Case 2\n\n"); + //menu_item_1_conversion_read(dev); + break; + + default: + port.printf(" ***Illegal Entry****\n\n"); + break; + + } + } + return 0; +} + +/***Function Definitions***/ + + +/*Function to print the title block when program first starts. + Parameters: None + Return Value: None*/ +void print_title() +{ + port.printf("\n*****************************************************************\n"); + port.printf("* EVAL-AD1234 Demonstration Program *\n"); + port.printf("* *\n"); + port.printf("* This program demonstrates how to measure strain gauge or *\n"); + port.printf("* other form of a Wheatstone bridge sensors with the AD1234 *\n"); + port.printf("* *\n"); + port.printf("* *\n"); + port.printf("* Set the baud rate to 115200 and select the newline terminator.*\n"); + port.printf("* *\n"); + port.printf("*****************************************************************\n"); +} + +/*Function to Print Command Summary + Parameters: None + Return Value: None */ +static void print_prompt() { + port.printf("Command Summary\n"); + port.printf(" 1 - Select ADC\n"); + port.printf(" 2 - Select Power Mode\n"); + port.printf(" x - Put More Menu Items Here\n"); +} + +void menu_1_function1() +{ + port.printf("In function 1\n"); +} + +void menu_2_function2() +{ + port.printf("In function 2\n"); +}