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