Example showing how to integrate EASE with proximity Sensor and Base board

Dependencies:   mbed EsmacatShield X_NUCLEO_6180XA1

Information about Esmacat and EASE is provided in the link below. https://os.mbed.com/users/pratima_hb/code/EASE_Example/wiki/Homepage

Information about the hardware needs and setup is provided in the link below. https://os.mbed.com/users/pratima_hb/code/EASE_Example/wiki/Hardware-Setup

Information about the structure of the system and it's software is provided in the link below. https://os.mbed.com/users/pratima_hb/code/EASE_Example/wiki/Software

Files at this revision

API Documentation at this revision

Comitter:
pratima_hb
Date:
Fri Feb 07 23:15:39 2020 +0000
Parent:
5:6935fab2a92b
Commit message:
Example code explaining how to use EASE with Proximity sensor and a base board

Changed in this revision

EsmacatShield.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 6935fab2a92b -r 318b85f6e6a5 EsmacatShield.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EsmacatShield.lib	Fri Feb 07 23:15:39 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/pratima_hb/code/EsmacatShield/#77c2a6061e77
diff -r 6935fab2a92b -r 318b85f6e6a5 main.cpp
--- a/main.cpp	Mon Aug 21 15:52:57 2017 +0000
+++ b/main.cpp	Fri Feb 07 23:15:39 2020 +0000
@@ -1,3 +1,36 @@
+/**
+ ******************************************************************************
+ * @file    main.cpp
+ * @date    February 07, 2020
+ * @brief   mbed test application Esmacat Shield working together with 
+ *          STMicroelectronics X-NUCLEO-6180XA1
+ *          The Expansion Board for range measurement and als measurement.
+ *The original code is by STMicroelectronics which is modified to integrate EASE.
+ *The Copyright of STMicroelectronics is retained below.
+ ******************************************************************************
+ 
+  Copyright (c) 2020 https://www.esmacat.com/
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+  EsmacatShield.h - Library for using EtherCAT Arduino Shield by Esmacat(EASE).
+  Created by Esmacat, 01/22/2020
+  
+*******************************************************************************
+* @file EsmacatShield.h
+*******************************************************************************
+*/
+
 /*
    This VL6180X Expansion board test application performs a range measurement
    and an als measurement in interrupt mode on the onboard embedded top sensor. 
@@ -26,6 +59,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
+#include <EsmacatShield.h>    //Esmacat : Include Esmacat Shield Library
+
 
 
 /* Definitions ---------------------------------------------------------------*/
@@ -41,6 +76,15 @@
 
 /* Types ---------------------------------------------------------------------*/
 
+
+/* Esmacat communication------------------------------------------------------*/
+DigitalOut selectPin(D10); // D10 is used to drive chip enable low 
+SPI spi(D11, D12, D13); // mosi, miso, sclk 
+EsmacatShield slave(spi, selectPin); // EsmacatShield Slave object creation
+int sendToEsmacat; 
+bool led_on; 
+/* Esmacat communication------------------------------------------------------*/
+
 /* Operating mode */
 operating_mode_t operating_mode, prev_operating_mode;
 enum op_mode_int_poll_t {
@@ -84,17 +128,31 @@
     if (op_mode==range_continuous_interrupt || op_mode==range_continuous_polling) {
         if (data_sensor_top.range_mm!=0xFFFFFFFF) {
             sprintf(str,"%d",data_sensor_top.range_mm);
+            /*Copy Sensor data to be sent to EASE*/
+            sendToEsmacat = data_sensor_top.range_mm; 
         } else {
+            /*Copy Sensor data to be sent to EASE*/
+            sendToEsmacat = 0; // Esmacat
             sprintf(str,"%s","----");
         }
     } else if (op_mode==als_continuous_interrupt || op_mode==als_continuous_polling) {
         if (data_sensor_top.lux!=0xFFFFFFFF) {
             sprintf(str,"%d",data_sensor_top.lux);
+            /*Copy Sensor data to be sent to EASE*/
+            sendToEsmacat = data_sensor_top.lux; // Esmacat
         } else {
+            /*If not valid data then send 0 to EASE*/
+            sendToEsmacat = 0; // Esmacat
             sprintf(str,"%s","----");
         }
     }
-    board->display->display_string(str, strlen(str));       
+  
+    /*Toggle the LED on EASE board*/
+    led_on = !led_on; 
+    printf("sendToEsmacat value %d \n", sendToEsmacat); // Esmacat
+    slave.write_reg_value(0,sendToEsmacat, led_on); //  Write data to EASE
+          
+    board->display->display_string(str, strlen(str));
 }
 
 /* On board red slider position check */
@@ -159,13 +217,14 @@
 
 /* Handle continuous ALS or Range measurement. */
 void int_continous_als_or_range_measure (DevI2C *device_i2c) {
+   
     int status;
 
     /* Creates the 6180XA1 expansion board singleton obj */
 #ifdef TARGET_STM32F429
-    board = XNucleo6180XA1::instance(device_i2c, A5, A2, D13, D2);
+    board = XNucleo6180XA1::instance(device_i2c, A5, A2, D7, D2);//Pratima D13 -> D7
 #else
-    board = XNucleo6180XA1::instance(device_i2c, A3, A2, D13, D2);
+    board = XNucleo6180XA1::instance(device_i2c, A3, A2, D7, D2);//Pratima D13 -> D7
 #endif
     display_msg("INT");
     
@@ -213,11 +272,14 @@
             } else {
                 display_refresh(operating_mode);
             }
+            
         }
     }
     display_msg("BYE");
+
 }
 
+
 /*=================================== Main ==================================
  Move the VL6180X Expansion board red slider to switch between ALS or Range
  measures.
@@ -225,6 +287,12 @@
 =============================================================================*/
 int main()
 {   
+/* Esmacat communication*/
+   
+    slave.setup_spi();           //Setup SPI for EASE
+
+
+
 #if USER_BUTTON==PC_13  // Cross compiling for Nucleo-F401
     InterruptIn stop_button (USER_BUTTON);
     stop_button.rise (&stop_measure_irq);  
@@ -234,3 +302,5 @@
     /* Start continous measures Interrupt based */
     int_continous_als_or_range_measure (device_i2c);
 }
+
+
diff -r 6935fab2a92b -r 318b85f6e6a5 mbed.bld
--- a/mbed.bld	Mon Aug 21 15:52:57 2017 +0000
+++ b/mbed.bld	Fri Feb 07 23:15:39 2020 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/mbed_official/code/mbed/builds/e2bfab296f20
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file