ADE1202 Example proegram using ADE120x library files

Dependencies:   ADE120x

Revision:
1:cff2074f52d5
Parent:
0:4b7ec1ec0c7a
Child:
2:2ebdd709cec0
--- a/main.cpp	Mon Jul 29 16:39:40 2019 +0000
+++ b/main.cpp	Mon Jul 29 23:59:40 2019 +0000
@@ -16,7 +16,7 @@
   - 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 may or may not infringe the patent rights of one or 
+  - 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.
 
@@ -34,25 +34,93 @@
 
 2019-01-10-7CBSD SLA
 
- */
+*/
 
-#include "mbed.h"
+/***Libraries***/
+#include <stdio.h> /*Standard Library*/
+#include "mbed.h" /*mbed header file*/
+
+/***Defines for UART Protocol***/
+#define BAUD_RATE                   115200                    /*Baud Rate*/
 
-Serial pc(USBTX, USBRX); // tx, rx
-DigitalOut awakeSignal(LED4);
-DigitalOut led1(LED1);
+/*Configure and instantiate UART protocol
+  and baud rate*/
+Serial port(USBTX, USBRX, BAUD_RATE);
+
+/***Function Declarations***/
 
-#define SLEEP_TIME                  500 // (msec)
+/*Print Information about Program's purpose*/
+static void print_title(void);
 
-// main() runs in its own thread in the OS
+/*Print Instructions on how to use Program*/
+static void print_prompt(void);
+
 int main()
 {
-    awakeSignal = 1;
-    pc.printf("Hello World!");
-    while (true) {
-        // Blink LED and wait 0.5 seconds
-        led1 = !led1;
-        wait_ms(SLEEP_TIME); 
+    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");
+}
+