A collection of Analog Devices drivers for the mbed platform

For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all

Revision:
21:a8023e5e97be
Parent:
20:9790e53d6e26
--- a/examples/adxl362_example/main.cpp	Tue May 17 15:15:19 2016 +0300
+++ b/examples/adxl362_example/main.cpp	Tue May 17 18:15:28 2016 +0300
@@ -44,19 +44,16 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ********************************************************************************/
+
 #include "mbed.h"
 #include "ADXL362.h"
 #include "lcd.h"
+#include "EVAL_ADXL362_ARDZ.h"
 
 Serial pc(USBTX, USBRX); ///< Serial interface to the pc
 Lcd lcd;
 ADXL362 adxl362(D9);
-
-static const uint16_t INACT_VAL = 50;
-static const uint16_t INACT_TIMER = 10 * 100;
-static const uint16_t ACT_VAL = 50;
-static const uint8_t ACT_TIMER = 100;
-static const uint16_t SCAN_SENSOR_TIME = 500;
+EVAL_ADXL362_ARDZ adxl362_board(lcd, adxl362);
 
 void flush_serial_buffer(void)
 {
@@ -67,172 +64,25 @@
 
 int main()
 {
-    uint8_t ui8s[22];
-    uint8_t ui8xu = 0;
-    uint8_t ui8xd = 0;
-    uint8_t ui8yu = 0;
-    uint8_t ui8yd = 0;
-    uint8_t ui8all = 0;
 
-    lcd.init();
-    adxl362.reset();
-    wait_us(500);
-    adxl362.set_activity_threshold(ACT_VAL);
-    adxl362.set_activity_time(ACT_TIMER / 10);
-
-    adxl362.set_inactivity_threshold(INACT_VAL);
-    adxl362.set_inactivity_time(INACT_TIMER);
-    adxl362.set_act_inact_ctl_reg(0x3f);
-#if(ADXL_INT_SEL == INTACC_PIN_1)
-    adxl362.set_polling_interrupt1_pin(D2, 0x40);
-#elif(ADXL_INT_SEL == INTACC_PIN_2)
-    adxl362.set_polling_interrupt2_pin(D2, 0x40); /* Map the awake status to INT2 pin */
-#endif
-    // interrupt ?
-
-    adxl362.set_mode(ADXL362::MEASUREMENT);
-
-    uint8_t ui8awake = 0;
+    adxl362_board.LCD_setup();
+    adxl362_board.ADXL_setup();
 
     /* Infinite loop */
     while (1) {
-#if(ADXL_INT_SEL == INTACC_PIN_1)
-        if (adxl362.get_int1()) {
-#elif(ADXL_INT_SEL == INTACC_PIN_2)
-        if(adxl362.get_int2()) {
-#endif
-                if (ui8awake == 0) {
-                    ui8awake = 1;
-
-                    /* Set BLLCD pin - turn on LCD backlight */
-                    lcd.bl_enable();
-
-                    lcd.display_string(0, 60, (int8_t *) "[mG]");
-                    lcd.display_string(1, 60, (int8_t *) "[mG]");
-                    lcd.display_string(2, 60, (int8_t *) "[mG]");
-
-#if (TEMP_ADC == 1)
-                    lcd.display_string(3, 60, (int8_t *)"[ADC]");
-#else
-                    lcd.display_string(3, 60, (int8_t *) "[C]");
-#endif
-                    ui8xu = 0;
-                    ui8xd = 0;
-                    ui8yu = 0;
-                    ui8yd = 0;
-                    ui8all = 0;
-
-                    lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8RecInv8x8);
-                    lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8RecInv8x8);
-                    lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8RecInv8x8);
-                    lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8RecInv8x8);
-                    lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8RecInv8x8);
-                }
-
-            } else {
-                if (ui8awake == 1) {
-                    ui8awake = 0;
-
-                    /* Clear BLLCD pin - turn off LCD backlight */
-                    lcd.bl_disable();
-
-                    /* Clear screen */
-                    lcd.fill_pages(0, 4, 0x00);
-                }
-            }
-
-            if (ui8awake == 1) {
-                wait_ms(100);
-                uint64_t acc = adxl362.scan();
-                int16_t i16SensorX = static_cast<uint16_t>((acc & 0xffff000000000000) >> 48);
-                int16_t i16SensorY = static_cast<uint16_t>((acc & 0x0000ffff00000000) >> 32);
-                int16_t i16SensorZ = static_cast<uint16_t>((acc & 0x00000000ffff0000) >> 16);
-                int16_t i16SensorT = static_cast<uint16_t> (acc & 0x000000000000ffff);
-
-                sprintf((char *) ui8s, "x = % 5d", i16SensorX);
-                lcd.display_string(0, 0, (int8_t *) ui8s);
-
-                sprintf((char *) ui8s, "y = % 5d", i16SensorY);
-                lcd.display_string(1, 0, (int8_t *) ui8s);
-
-                sprintf((char *) ui8s, "z = % 5d", i16SensorZ);
-                lcd.display_string(2, 0, (int8_t *) ui8s);
+        if(adxl362_board.ADXL_get_int()) { // ADXL362 is AWAKE ?
 
-#if TEMP_ADC == 1
-                sprintf((char *)ui8s, "t = % 5d", i16SensorT);
-                lcd.display_string(3, 0, (int8_t *)ui8s);
-#else
-                float f32temp = ((float) i16SensorT + Lcd::ACC_TEMP_BIAS)
-                                / (1 / Lcd::ACC_TEMP_SENSITIVITY);   // -34.625
-                sprintf((char *) ui8s, "t = % 4.1f", f32temp);
-                lcd.display_string(3, 0, (int8_t *) ui8s);
-#endif
-
-                if (i16SensorY > Lcd::ACC_LIMIT) {
-                    if (ui8xu == 0) {
-                        ui8xu = 1;
-                        lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8Rec8x8);
-                    }
-
-                } else {
-                    if (ui8xu == 1) {
-                        ui8xu = 0;
-                        lcd.display_symbol(0, Lcd::UP_X, 8, Lcd::pui8RecInv8x8);
-                    }
-                }
-
-                if (i16SensorY < -Lcd::ACC_LIMIT) {
-                    if (ui8xd == 0) {
-                        ui8xd = 1;
-                        lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8Rec8x8);
-                    }
-
-                } else {
-                    if (ui8xd == 1) {
-                        ui8xd = 0;
-                        lcd.display_symbol(2, Lcd::DOWN_X, 8, Lcd::pui8RecInv8x8);
-                    }
-                }
+            adxl362_board.LCD_init_display(); // will only turn on if it's off
+            wait_ms(100);
+            adxl362_board.ADXL_scan_xyzt();
+            adxl362_board.LCD_display_values();
+            adxl362_board.LCD_display_level();
 
-                if (i16SensorX > Lcd::ACC_LIMIT) {
-                    if (ui8yu == 0) {
-                        ui8yu = 1;
-                        lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8Rec8x8);
-                    }
-
-                } else {
-                    if (ui8yu == 1) {
-                        ui8yu = 0;
-                        lcd.display_symbol(1, Lcd::RIGHT_X, 8, Lcd::pui8RecInv8x8);
-                    }
-                }
-
-                if (i16SensorX < -Lcd::ACC_LIMIT) {
-                    if (ui8yd == 0) {
-                        ui8yd = 1;
-                        lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8Rec8x8);
-                    }
+        } else {
 
-                } else {
-                    if (ui8yd == 1) {
-                        ui8yd = 0;
-                        lcd.display_symbol(1, Lcd::LEFT_X, 8, Lcd::pui8RecInv8x8);
-                    }
-                }
+            adxl362_board.LCD_deinit_display(); // will only turn off it it's on
 
-                if ((ui8xu == 0) && (ui8xd == 0) && (ui8yu == 0) && (ui8yd == 0)) {
-                    if (ui8all == 0) {
-                        ui8all = 1;
-                        lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8Rec8x8);
-                    }
-
-                } else {
-                    if (ui8all == 1) {
-                        ui8all = 0;
-                        lcd.display_symbol(1, Lcd::CENTER_X, 8, Lcd::pui8RecInv8x8);
-                    }
-                }
-            }
         }
     }
+}