ADXL355

Committer:
ppcanuck2
Date:
Thu Feb 06 19:25:43 2020 +0000
Revision:
0:df16df7ba53f
Data dumps to UART but really slowly

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ppcanuck2 0:df16df7ba53f 1 /*!
ppcanuck2 0:df16df7ba53f 2 *****************************************************************************
ppcanuck2 0:df16df7ba53f 3 * @file: ADXL355.h
ppcanuck2 0:df16df7ba53f 4 * @brief: ADXL355 accelerometer IC
ppcanuck2 0:df16df7ba53f 5 * @version: $Revision$
ppcanuck2 0:df16df7ba53f 6 * @date: $Date$
ppcanuck2 0:df16df7ba53f 7 *-----------------------------------------------------------------------------
ppcanuck2 0:df16df7ba53f 8 *
ppcanuck2 0:df16df7ba53f 9 Copyright (c) 2016-2017 Analog Devices, Inc.
ppcanuck2 0:df16df7ba53f 10
ppcanuck2 0:df16df7ba53f 11 All rights reserved.
ppcanuck2 0:df16df7ba53f 12
ppcanuck2 0:df16df7ba53f 13 Redistribution and use in source and binary forms, with or without modification,
ppcanuck2 0:df16df7ba53f 14 are permitted provided that the following conditions are met:
ppcanuck2 0:df16df7ba53f 15 - Redistributions of source code must retain the above copyright notice,
ppcanuck2 0:df16df7ba53f 16 this list of conditions and the following disclaimer.
ppcanuck2 0:df16df7ba53f 17 - Redistributions in binary form must reproduce the above copyright notice,
ppcanuck2 0:df16df7ba53f 18 this list of conditions and the following disclaimer in the documentation
ppcanuck2 0:df16df7ba53f 19 and/or other materials provided with the distribution.
ppcanuck2 0:df16df7ba53f 20 - Modified versions of the software must be conspicuously marked as such.
ppcanuck2 0:df16df7ba53f 21 - This software is licensed solely and exclusively for use with processors
ppcanuck2 0:df16df7ba53f 22 manufactured by or for Analog Devices, Inc.
ppcanuck2 0:df16df7ba53f 23 - This software may not be combined or merged with other code in any manner
ppcanuck2 0:df16df7ba53f 24 that would cause the software to become subject to terms and conditions
ppcanuck2 0:df16df7ba53f 25 which differ from those listed here.
ppcanuck2 0:df16df7ba53f 26 - Neither the name of Analog Devices, Inc. nor the names of its
ppcanuck2 0:df16df7ba53f 27 contributors may be used to endorse or promote products derived
ppcanuck2 0:df16df7ba53f 28 from this software without specific prior written permission.
ppcanuck2 0:df16df7ba53f 29 - The use of this software may or may not infringe the patent rights of one
ppcanuck2 0:df16df7ba53f 30 or more patent holders. This license does not release you from the
ppcanuck2 0:df16df7ba53f 31 requirement that you obtain separate licenses from these patent holders
ppcanuck2 0:df16df7ba53f 32 to use this software.
ppcanuck2 0:df16df7ba53f 33
ppcanuck2 0:df16df7ba53f 34 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY
ppcanuck2 0:df16df7ba53f 35 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
ppcanuck2 0:df16df7ba53f 36 TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
ppcanuck2 0:df16df7ba53f 37 NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
ppcanuck2 0:df16df7ba53f 38 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES
ppcanuck2 0:df16df7ba53f 39 (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL
ppcanuck2 0:df16df7ba53f 40 PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
ppcanuck2 0:df16df7ba53f 41 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
ppcanuck2 0:df16df7ba53f 42 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
ppcanuck2 0:df16df7ba53f 43 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
ppcanuck2 0:df16df7ba53f 44 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ppcanuck2 0:df16df7ba53f 45 *
ppcanuck2 0:df16df7ba53f 46 *****************************************************************************/
ppcanuck2 0:df16df7ba53f 47
ppcanuck2 0:df16df7ba53f 48 #ifndef ADXL355_H_
ppcanuck2 0:df16df7ba53f 49 #define ADXL355_H_
ppcanuck2 0:df16df7ba53f 50
ppcanuck2 0:df16df7ba53f 51 /********************************* Definitions ********************************/
ppcanuck2 0:df16df7ba53f 52
ppcanuck2 0:df16df7ba53f 53 /* ADXL355 registers addresses */
ppcanuck2 0:df16df7ba53f 54 #define DEVID_AD 0x00
ppcanuck2 0:df16df7ba53f 55 #define DEVID_MST 0x01
ppcanuck2 0:df16df7ba53f 56 #define PARTID 0x02
ppcanuck2 0:df16df7ba53f 57 #define REVID 0x03
ppcanuck2 0:df16df7ba53f 58 #define STATUS 0x04
ppcanuck2 0:df16df7ba53f 59 #define FIFO_ENTRIES 0x05
ppcanuck2 0:df16df7ba53f 60 #define TEMP2 0x06
ppcanuck2 0:df16df7ba53f 61 #define TEMP1 0x07
ppcanuck2 0:df16df7ba53f 62 #define XDATA3 0x08
ppcanuck2 0:df16df7ba53f 63 #define XDATA2 0x09
ppcanuck2 0:df16df7ba53f 64 #define XDATA1 0x0A
ppcanuck2 0:df16df7ba53f 65 #define YDATA3 0x0B
ppcanuck2 0:df16df7ba53f 66 #define YDATA2 0x0C
ppcanuck2 0:df16df7ba53f 67 #define YDATA1 0x0D
ppcanuck2 0:df16df7ba53f 68 #define ZDATA3 0x0E
ppcanuck2 0:df16df7ba53f 69 #define ZDATA2 0x0F
ppcanuck2 0:df16df7ba53f 70 #define ZDATA1 0x10
ppcanuck2 0:df16df7ba53f 71 #define FIFO_DATA 0x11
ppcanuck2 0:df16df7ba53f 72 #define OFFSET_X_H 0x1E
ppcanuck2 0:df16df7ba53f 73 #define OFFSET_X_L 0x1F
ppcanuck2 0:df16df7ba53f 74 #define OFFSET_Y_H 0x20
ppcanuck2 0:df16df7ba53f 75 #define OFFSET_Y_L 0x21
ppcanuck2 0:df16df7ba53f 76 #define OFFSET_Z_H 0x22
ppcanuck2 0:df16df7ba53f 77 #define OFFSET_Z_L 0x23
ppcanuck2 0:df16df7ba53f 78 #define ACT_EN 0x24
ppcanuck2 0:df16df7ba53f 79 #define ACT_THRESH_H 0x25
ppcanuck2 0:df16df7ba53f 80 #define ACT_THRESH_L 0x26
ppcanuck2 0:df16df7ba53f 81 #define ACT_COUNT 0x27
ppcanuck2 0:df16df7ba53f 82 #define FILTER 0x28
ppcanuck2 0:df16df7ba53f 83 #define FIFO_SAMPLES 0x29
ppcanuck2 0:df16df7ba53f 84 #define INT_MAP 0x2A
ppcanuck2 0:df16df7ba53f 85 #define SYNC 0x2B
ppcanuck2 0:df16df7ba53f 86 #define RANGE 0x2C
ppcanuck2 0:df16df7ba53f 87 #define POWER_CTL 0x2D
ppcanuck2 0:df16df7ba53f 88 #define SELF_TEST 0x2E
ppcanuck2 0:df16df7ba53f 89 #define RESET 0x2F
ppcanuck2 0:df16df7ba53f 90
ppcanuck2 0:df16df7ba53f 91 /**************************** Configuration parameters **********************/
ppcanuck2 0:df16df7ba53f 92
ppcanuck2 0:df16df7ba53f 93 /* Temperature parameters */
ppcanuck2 0:df16df7ba53f 94 #define ADXL355_TEMP_BIAS (float)1852.0 /* Accelerometer temperature bias(in ADC codes) at 25 Deg C */
ppcanuck2 0:df16df7ba53f 95 #define ADXL355_TEMP_SLOPE (float)-9.05 /* Accelerometer temperature change from datasheet (LSB/degC) */
ppcanuck2 0:df16df7ba53f 96
ppcanuck2 0:df16df7ba53f 97 /* Accelerometer parameters */
ppcanuck2 0:df16df7ba53f 98 #define ADXL_RANGE 2 /* ADXL362 sensitivity: 2, 4, 8 [g] */
ppcanuck2 0:df16df7ba53f 99
ppcanuck2 0:df16df7ba53f 100 #define ACT_VALUE 50 /* Activity threshold value */
ppcanuck2 0:df16df7ba53f 101
ppcanuck2 0:df16df7ba53f 102 #define INACT_VALUE 50 /* Inactivity threshold value */
ppcanuck2 0:df16df7ba53f 103
ppcanuck2 0:df16df7ba53f 104 #define ACT_TIMER 100 /* Activity timer value in ms */
ppcanuck2 0:df16df7ba53f 105
ppcanuck2 0:df16df7ba53f 106 #define INACT_TIMER 10 /* Inactivity timer value in seconds */
ppcanuck2 0:df16df7ba53f 107
ppcanuck2 0:df16df7ba53f 108 /****************************** Global Data ***********************************/
ppcanuck2 0:df16df7ba53f 109
ppcanuck2 0:df16df7ba53f 110 extern volatile int32_t i32SensorX;
ppcanuck2 0:df16df7ba53f 111 extern volatile int32_t i32SensorY;
ppcanuck2 0:df16df7ba53f 112 extern volatile int32_t i32SensorZ;
ppcanuck2 0:df16df7ba53f 113
ppcanuck2 0:df16df7ba53f 114 extern volatile uint32_t ui32SensorX;
ppcanuck2 0:df16df7ba53f 115 extern volatile uint32_t ui32SensorY;
ppcanuck2 0:df16df7ba53f 116 extern volatile uint32_t ui32SensorZ;
ppcanuck2 0:df16df7ba53f 117 extern volatile uint32_t ui32SensorT;
ppcanuck2 0:df16df7ba53f 118
ppcanuck2 0:df16df7ba53f 119 extern volatile uint32_t ui32timer_counter;
ppcanuck2 0:df16df7ba53f 120
ppcanuck2 0:df16df7ba53f 121
ppcanuck2 0:df16df7ba53f 122 /*************************** Functions prototypes *****************************/
ppcanuck2 0:df16df7ba53f 123
ppcanuck2 0:df16df7ba53f 124 void ADXL355_Init(void);
ppcanuck2 0:df16df7ba53f 125 void ADXL355_Start_Sensor(void);
ppcanuck2 0:df16df7ba53f 126 void ADXL355_Stop_Sensor(void);
ppcanuck2 0:df16df7ba53f 127 void ADXL355_Data_Scan(void);
ppcanuck2 0:df16df7ba53f 128 int32_t ADXL355_Acceleration_Data_Conversion (uint32_t ui32SensorData);
ppcanuck2 0:df16df7ba53f 129
ppcanuck2 0:df16df7ba53f 130 #endif /* ADXL355_H_ */