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

Committer:
Adrian Suciu
Date:
Tue May 17 18:15:28 2016 +0300
Revision:
21:a8023e5e97be
Parent:
20:9790e53d6e26
Created EVAL_ADXL362_ARDZ component and restructured code around it

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Adrian Suciu 19:fb92949e59c9 1 /**
Adrian Suciu 19:fb92949e59c9 2 * @file main.cpp
Adrian Suciu 19:fb92949e59c9 3 * @brief Main file for the ADXL362-example project
Adrian Suciu 19:fb92949e59c9 4 * @author Analog Devices Inc.
Adrian Suciu 19:fb92949e59c9 5 *
Adrian Suciu 19:fb92949e59c9 6 * For support please go to:
Adrian Suciu 19:fb92949e59c9 7 * Github: https://github.com/analogdevicesinc/mbed-adi
Adrian Suciu 19:fb92949e59c9 8 * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
Adrian Suciu 19:fb92949e59c9 9 * Product: www.analog.com/EVAL-ADXL362-ARDZ
Adrian Suciu 19:fb92949e59c9 10 * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
Adrian Suciu 19:fb92949e59c9 11
Adrian Suciu 19:fb92949e59c9 12 ********************************************************************************
Adrian Suciu 19:fb92949e59c9 13 * Copyright 2016(c) Analog Devices, Inc.
Adrian Suciu 19:fb92949e59c9 14 *
Adrian Suciu 19:fb92949e59c9 15 * All rights reserved.
Adrian Suciu 19:fb92949e59c9 16 *
Adrian Suciu 19:fb92949e59c9 17 * Redistribution and use in source and binary forms, with or without
Adrian Suciu 19:fb92949e59c9 18 * modification, are permitted provided that the following conditions are met:
Adrian Suciu 19:fb92949e59c9 19 * - Redistributions of source code must retain the above copyright
Adrian Suciu 19:fb92949e59c9 20 * notice, this list of conditions and the following disclaimer.
Adrian Suciu 19:fb92949e59c9 21 * - Redistributions in binary form must reproduce the above copyright
Adrian Suciu 19:fb92949e59c9 22 * notice, this list of conditions and the following disclaimer in
Adrian Suciu 19:fb92949e59c9 23 * the documentation and/or other materials provided with the
Adrian Suciu 19:fb92949e59c9 24 * distribution.
Adrian Suciu 19:fb92949e59c9 25 * - Neither the name of Analog Devices, Inc. nor the names of its
Adrian Suciu 19:fb92949e59c9 26 * contributors may be used to endorse or promote products derived
Adrian Suciu 19:fb92949e59c9 27 * from this software without specific prior written permission.
Adrian Suciu 19:fb92949e59c9 28 * - The use of this software may or may not infringe the patent rights
Adrian Suciu 19:fb92949e59c9 29 * of one or more patent holders. This license does not release you
Adrian Suciu 19:fb92949e59c9 30 * from the requirement that you obtain separate licenses from these
Adrian Suciu 19:fb92949e59c9 31 * patent holders to use this software.
Adrian Suciu 19:fb92949e59c9 32 * - Use of the software either in source or binary form, must be run
Adrian Suciu 19:fb92949e59c9 33 * on or directly connected to an Analog Devices Inc. component.
Adrian Suciu 19:fb92949e59c9 34 *
Adrian Suciu 19:fb92949e59c9 35 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
Adrian Suciu 19:fb92949e59c9 36 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
Adrian Suciu 19:fb92949e59c9 37 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Adrian Suciu 19:fb92949e59c9 38 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
Adrian Suciu 19:fb92949e59c9 39 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Adrian Suciu 19:fb92949e59c9 40 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
Adrian Suciu 19:fb92949e59c9 41 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Adrian Suciu 19:fb92949e59c9 42 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Adrian Suciu 19:fb92949e59c9 43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Adrian Suciu 19:fb92949e59c9 44 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Adrian Suciu 19:fb92949e59c9 45 *
Adrian Suciu 19:fb92949e59c9 46 ********************************************************************************/
Adrian Suciu 21:a8023e5e97be 47
Adrian Suciu 19:fb92949e59c9 48 #include "mbed.h"
Adrian Suciu 19:fb92949e59c9 49 #include "ADXL362.h"
Adrian Suciu 19:fb92949e59c9 50 #include "lcd.h"
Adrian Suciu 21:a8023e5e97be 51 #include "EVAL_ADXL362_ARDZ.h"
Adrian Suciu 19:fb92949e59c9 52
Adrian Suciu 19:fb92949e59c9 53 Serial pc(USBTX, USBRX); ///< Serial interface to the pc
Adrian Suciu 19:fb92949e59c9 54 Lcd lcd;
Adrian Suciu 19:fb92949e59c9 55 ADXL362 adxl362(D9);
Adrian Suciu 21:a8023e5e97be 56 EVAL_ADXL362_ARDZ adxl362_board(lcd, adxl362);
Adrian Suciu 19:fb92949e59c9 57
Adrian Suciu 19:fb92949e59c9 58 void flush_serial_buffer(void)
Adrian Suciu 19:fb92949e59c9 59 {
Adrian Suciu 19:fb92949e59c9 60 while (pc.readable())
Adrian Suciu 19:fb92949e59c9 61 pc.getc();
Adrian Suciu 19:fb92949e59c9 62 return;
Adrian Suciu 19:fb92949e59c9 63 }
Adrian Suciu 19:fb92949e59c9 64
Adrian Suciu 19:fb92949e59c9 65 int main()
Adrian Suciu 19:fb92949e59c9 66 {
Adrian Suciu 19:fb92949e59c9 67
Adrian Suciu 21:a8023e5e97be 68 adxl362_board.LCD_setup();
Adrian Suciu 21:a8023e5e97be 69 adxl362_board.ADXL_setup();
Adrian Suciu 19:fb92949e59c9 70
Adrian Suciu 19:fb92949e59c9 71 /* Infinite loop */
Adrian Suciu 19:fb92949e59c9 72 while (1) {
Adrian Suciu 21:a8023e5e97be 73 if(adxl362_board.ADXL_get_int()) { // ADXL362 is AWAKE ?
Adrian Suciu 19:fb92949e59c9 74
Adrian Suciu 21:a8023e5e97be 75 adxl362_board.LCD_init_display(); // will only turn on if it's off
Adrian Suciu 21:a8023e5e97be 76 wait_ms(100);
Adrian Suciu 21:a8023e5e97be 77 adxl362_board.ADXL_scan_xyzt();
Adrian Suciu 21:a8023e5e97be 78 adxl362_board.LCD_display_values();
Adrian Suciu 21:a8023e5e97be 79 adxl362_board.LCD_display_level();
Adrian Suciu 19:fb92949e59c9 80
Adrian Suciu 21:a8023e5e97be 81 } else {
Adrian Suciu 19:fb92949e59c9 82
Adrian Suciu 21:a8023e5e97be 83 adxl362_board.LCD_deinit_display(); // will only turn off it it's on
Adrian Suciu 19:fb92949e59c9 84
Adrian Suciu 19:fb92949e59c9 85 }
Adrian Suciu 19:fb92949e59c9 86 }
Adrian Suciu 21:a8023e5e97be 87 }
Adrian Suciu 19:fb92949e59c9 88