Sunshine Grace Cabatan
/
EVAL-AD910x
Example program for EVAL-AD9106 and EVAL-AD9102
main.cpp@0:3c9cc352dbfc, 2020-07-06 (annotated)
- Committer:
- Kjansen45
- Date:
- Mon Jul 06 16:29:51 2020 +0000
- Revision:
- 0:3c9cc352dbfc
- Child:
- 1:b9d129e45c30
Repository Created
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kjansen45 | 0:3c9cc352dbfc | 1 | /* Copyright (c) 2019 Analog Devices, Inc. All rights reserved. |
Kjansen45 | 0:3c9cc352dbfc | 2 | |
Kjansen45 | 0:3c9cc352dbfc | 3 | Redistribution and use in source and binary forms, with or without modification, |
Kjansen45 | 0:3c9cc352dbfc | 4 | are permitted provided that the following conditions are met: |
Kjansen45 | 0:3c9cc352dbfc | 5 | - Redistributions of source code must retain the above copyright notice, |
Kjansen45 | 0:3c9cc352dbfc | 6 | this list of conditions and the following disclaimer. |
Kjansen45 | 0:3c9cc352dbfc | 7 | - Redistributions in binary form must reproduce the above copyright notice, |
Kjansen45 | 0:3c9cc352dbfc | 8 | this list of conditions and the following disclaimer in the documentation |
Kjansen45 | 0:3c9cc352dbfc | 9 | and/or other materials provided with the distribution. |
Kjansen45 | 0:3c9cc352dbfc | 10 | - Modified versions of the software must be conspicuously marked as such. |
Kjansen45 | 0:3c9cc352dbfc | 11 | - This software is licensed solely and exclusively for use with processors/products |
Kjansen45 | 0:3c9cc352dbfc | 12 | manufactured by or for Analog Devices, Inc. |
Kjansen45 | 0:3c9cc352dbfc | 13 | - This software may not be combined or merged with other code in any manner |
Kjansen45 | 0:3c9cc352dbfc | 14 | that would cause the software to become subject to terms and conditions which |
Kjansen45 | 0:3c9cc352dbfc | 15 | differ from those listed here. |
Kjansen45 | 0:3c9cc352dbfc | 16 | - Neither the name of Analog Devices, Inc. nor the names of its contributors |
Kjansen45 | 0:3c9cc352dbfc | 17 | may be used to endorse or promote products derived from this software without |
Kjansen45 | 0:3c9cc352dbfc | 18 | specific prior written permission. |
Kjansen45 | 0:3c9cc352dbfc | 19 | - The use of this software ma y or may not infringe the patent rights of one or |
Kjansen45 | 0:3c9cc352dbfc | 20 | more patent holders. This license does not release you from the requirement |
Kjansen45 | 0:3c9cc352dbfc | 21 | that you obtain separate licenses from these patent holders to use this software. |
Kjansen45 | 0:3c9cc352dbfc | 22 | |
Kjansen45 | 0:3c9cc352dbfc | 23 | THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND |
Kjansen45 | 0:3c9cc352dbfc | 24 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
Kjansen45 | 0:3c9cc352dbfc | 25 | TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
Kjansen45 | 0:3c9cc352dbfc | 26 | NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
Kjansen45 | 0:3c9cc352dbfc | 27 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES |
Kjansen45 | 0:3c9cc352dbfc | 28 | (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL |
Kjansen45 | 0:3c9cc352dbfc | 29 | PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
Kjansen45 | 0:3c9cc352dbfc | 30 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
Kjansen45 | 0:3c9cc352dbfc | 31 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
Kjansen45 | 0:3c9cc352dbfc | 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
Kjansen45 | 0:3c9cc352dbfc | 33 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Kjansen45 | 0:3c9cc352dbfc | 34 | |
Kjansen45 | 0:3c9cc352dbfc | 35 | 2019-01-10-7CBSD SLA |
Kjansen45 | 0:3c9cc352dbfc | 36 | |
Kjansen45 | 0:3c9cc352dbfc | 37 | */ |
Kjansen45 | 0:3c9cc352dbfc | 38 | |
Kjansen45 | 0:3c9cc352dbfc | 39 | /***Libraries***/ |
Kjansen45 | 0:3c9cc352dbfc | 40 | #include <stdio.h> /*Standard Library*/ |
Kjansen45 | 0:3c9cc352dbfc | 41 | #include "mbed.h" /*mbed header file*/ |
Kjansen45 | 0:3c9cc352dbfc | 42 | |
Kjansen45 | 0:3c9cc352dbfc | 43 | /***Defines for UART Protocol***/ |
Kjansen45 | 0:3c9cc352dbfc | 44 | #define BAUD_RATE 115200 /*Baud Rate*/ |
Kjansen45 | 0:3c9cc352dbfc | 45 | |
Kjansen45 | 0:3c9cc352dbfc | 46 | /*Configure and instantiate UART protocol |
Kjansen45 | 0:3c9cc352dbfc | 47 | and baud rate*/ |
Kjansen45 | 0:3c9cc352dbfc | 48 | Serial port(USBTX, USBRX, BAUD_RATE); |
Kjansen45 | 0:3c9cc352dbfc | 49 | |
Kjansen45 | 0:3c9cc352dbfc | 50 | /***Function Declarations***/ |
Kjansen45 | 0:3c9cc352dbfc | 51 | |
Kjansen45 | 0:3c9cc352dbfc | 52 | /*Print Information about Program's purpose*/ |
Kjansen45 | 0:3c9cc352dbfc | 53 | static void print_title(void); |
Kjansen45 | 0:3c9cc352dbfc | 54 | |
Kjansen45 | 0:3c9cc352dbfc | 55 | /*Print Instructions on how to use Program*/ |
Kjansen45 | 0:3c9cc352dbfc | 56 | static void print_prompt(void); |
Kjansen45 | 0:3c9cc352dbfc | 57 | |
Kjansen45 | 0:3c9cc352dbfc | 58 | int main() |
Kjansen45 | 0:3c9cc352dbfc | 59 | { |
Kjansen45 | 0:3c9cc352dbfc | 60 | uint8_t user_command; /*User input variable*/ |
Kjansen45 | 0:3c9cc352dbfc | 61 | uint8_t connected = 1; /*Initialize SPI*/ |
Kjansen45 | 0:3c9cc352dbfc | 62 | |
Kjansen45 | 0:3c9cc352dbfc | 63 | print_title(); |
Kjansen45 | 0:3c9cc352dbfc | 64 | |
Kjansen45 | 0:3c9cc352dbfc | 65 | while(connected == 1) { |
Kjansen45 | 0:3c9cc352dbfc | 66 | print_prompt(); |
Kjansen45 | 0:3c9cc352dbfc | 67 | port.scanf("%2d", (int *) &user_command); |
Kjansen45 | 0:3c9cc352dbfc | 68 | switch (user_command) { |
Kjansen45 | 0:3c9cc352dbfc | 69 | case 1: |
Kjansen45 | 0:3c9cc352dbfc | 70 | port.printf("Case 1\n\n"); |
Kjansen45 | 0:3c9cc352dbfc | 71 | break; |
Kjansen45 | 0:3c9cc352dbfc | 72 | |
Kjansen45 | 0:3c9cc352dbfc | 73 | case 2: |
Kjansen45 | 0:3c9cc352dbfc | 74 | port.printf("Case 2\n\n"); |
Kjansen45 | 0:3c9cc352dbfc | 75 | //menu_item_1_conversion_read(dev); |
Kjansen45 | 0:3c9cc352dbfc | 76 | break; |
Kjansen45 | 0:3c9cc352dbfc | 77 | |
Kjansen45 | 0:3c9cc352dbfc | 78 | default: |
Kjansen45 | 0:3c9cc352dbfc | 79 | port.printf(" ***Illegal Entry****\n\n"); |
Kjansen45 | 0:3c9cc352dbfc | 80 | break; |
Kjansen45 | 0:3c9cc352dbfc | 81 | |
Kjansen45 | 0:3c9cc352dbfc | 82 | } |
Kjansen45 | 0:3c9cc352dbfc | 83 | } |
Kjansen45 | 0:3c9cc352dbfc | 84 | return 0; |
Kjansen45 | 0:3c9cc352dbfc | 85 | } |
Kjansen45 | 0:3c9cc352dbfc | 86 | |
Kjansen45 | 0:3c9cc352dbfc | 87 | /***Function Definitions***/ |
Kjansen45 | 0:3c9cc352dbfc | 88 | |
Kjansen45 | 0:3c9cc352dbfc | 89 | |
Kjansen45 | 0:3c9cc352dbfc | 90 | /*Function to print the title block when program first starts. |
Kjansen45 | 0:3c9cc352dbfc | 91 | Parameters: None |
Kjansen45 | 0:3c9cc352dbfc | 92 | Return Value: None*/ |
Kjansen45 | 0:3c9cc352dbfc | 93 | void print_title() |
Kjansen45 | 0:3c9cc352dbfc | 94 | { |
Kjansen45 | 0:3c9cc352dbfc | 95 | port.printf("\n*****************************************************************\n"); |
Kjansen45 | 0:3c9cc352dbfc | 96 | port.printf("* EVAL-AD1234 Demonstration Program *\n"); |
Kjansen45 | 0:3c9cc352dbfc | 97 | port.printf("* *\n"); |
Kjansen45 | 0:3c9cc352dbfc | 98 | port.printf("* This program demonstrates how to measure strain gauge or *\n"); |
Kjansen45 | 0:3c9cc352dbfc | 99 | port.printf("* other form of a Wheatstone bridge sensors with the AD1234 *\n"); |
Kjansen45 | 0:3c9cc352dbfc | 100 | port.printf("* *\n"); |
Kjansen45 | 0:3c9cc352dbfc | 101 | port.printf("* *\n"); |
Kjansen45 | 0:3c9cc352dbfc | 102 | port.printf("* Set the baud rate to 115200 and select the newline terminator.*\n"); |
Kjansen45 | 0:3c9cc352dbfc | 103 | port.printf("* *\n"); |
Kjansen45 | 0:3c9cc352dbfc | 104 | port.printf("*****************************************************************\n"); |
Kjansen45 | 0:3c9cc352dbfc | 105 | } |
Kjansen45 | 0:3c9cc352dbfc | 106 | |
Kjansen45 | 0:3c9cc352dbfc | 107 | /*Function to Print Command Summary |
Kjansen45 | 0:3c9cc352dbfc | 108 | Parameters: None |
Kjansen45 | 0:3c9cc352dbfc | 109 | Return Value: None */ |
Kjansen45 | 0:3c9cc352dbfc | 110 | static void print_prompt() { |
Kjansen45 | 0:3c9cc352dbfc | 111 | port.printf("Command Summary\n"); |
Kjansen45 | 0:3c9cc352dbfc | 112 | port.printf(" 1 - Select ADC\n"); |
Kjansen45 | 0:3c9cc352dbfc | 113 | port.printf(" 2 - Select Power Mode\n"); |
Kjansen45 | 0:3c9cc352dbfc | 114 | port.printf(" x - Put More Menu Items Here\n"); |
Kjansen45 | 0:3c9cc352dbfc | 115 | } |
Kjansen45 | 0:3c9cc352dbfc | 116 | |
Kjansen45 | 0:3c9cc352dbfc | 117 | void menu_1_function1() |
Kjansen45 | 0:3c9cc352dbfc | 118 | { |
Kjansen45 | 0:3c9cc352dbfc | 119 | port.printf("In function 1\n"); |
Kjansen45 | 0:3c9cc352dbfc | 120 | } |
Kjansen45 | 0:3c9cc352dbfc | 121 | |
Kjansen45 | 0:3c9cc352dbfc | 122 | void menu_2_function2() |
Kjansen45 | 0:3c9cc352dbfc | 123 | { |
Kjansen45 | 0:3c9cc352dbfc | 124 | port.printf("In function 2\n"); |
Kjansen45 | 0:3c9cc352dbfc | 125 | } |