LP-551 Remove popup - Increase neutral diff levels for alarm
[librepilot.git] / flight / pios / inc / pios_adxl345.h
blob4385a05b3b6106c37eb8c9510d95934903d68d75
1 /**
2 ******************************************************************************
3 * @addtogroup PIOS PIOS Core hardware abstraction layer
4 * @{
5 * @addtogroup PIOS_ADXL345 ADXL345 Functions
6 * @brief Data from the ADXL345 sensors
7 * @{
8 * @file pios_adxl345.h
9 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
10 * @brief PiOS SPI ADXL345
11 * @see The GNU Public License (GPL) Version 3
13 *****************************************************************************/
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * for more details.
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef PIOS_ADXL345_H
30 #define PIOS_ADXL345_H
32 // Defined by data rate, not BW
34 #define ADXL_READ_BIT 0x80
35 #define ADXL_MULTI_BIT 0x40
37 #define ADXL_WHOAMI 0x00
38 #define ADXL_DEVICE_ID 0xE5
39 #define ADXL_X0_ADDR 0x32
40 #define ADXL_FIFOSTATUS_ADDR 0x39
42 #define ADXL_RATE_ADDR 0x2C
43 #define ADXL_RATE_100 0x0A
44 #define ADXL_RATE_200 0x0B
45 #define ADXL_RATE_400 0x0C
46 #define ADXL_RATE_800 0x0D
47 #define ADXL_RATE_1600 0x0E
48 #define ADXL_RATE_3200 0x0F
50 #define ADXL_POWER_ADDR 0x2D
51 #define ADXL_MEAURE 0x08
53 #define ADXL_FORMAT_ADDR 0x31
54 #define ADXL_FULL_RES 0x08
55 #define ADXL_4WIRE 0x00
56 #define ADXL_RANGE_2G 0x00
57 #define ADXL_RANGE_4G 0x01
58 #define ADXL_RANGE_8G 0x02
59 #define ADXL_RANGE_16G 0x03
61 #define ADXL_FIFO_ADDR 0x38
62 #define ADXL_FIFO_STREAM 0x80
65 struct pios_adxl345_data {
66 int16_t x;
67 int16_t y;
68 int16_t z;
71 int32_t PIOS_ADXL345_SelectRate(uint8_t rate);
72 int32_t PIOS_ADXL345_SetRange(uint8_t range);
73 int32_t PIOS_ADXL345_Init(uint32_t spi_id, uint32_t slave_num);
74 uint8_t PIOS_ADXL345_Read(struct pios_adxl345_data *data);
75 int8_t PIOS_ADXL345_ReadAndAccumulateSamples(struct pios_adxl345_data *data, uint8_t samples);
76 int32_t PIOS_ADXL345_FifoElements();
77 int32_t PIOS_ADXL345_Test();
79 #endif /* PIOS_ADXL345_H */
81 /**
82 * @}
83 * @}