2012-01-05 02:29:29 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
|
|
|
* @{
|
|
|
|
* @addtogroup PIOS_ADXL345 ADXL345 Functions
|
|
|
|
* @brief Data from the ADXL345 sensors
|
|
|
|
* @{
|
|
|
|
* @file pios_adxl345.h
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
|
|
|
* @brief PiOS SPI ADXL345
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-01-17 09:45:40 +01:00
|
|
|
/*
|
2012-01-05 02:29:29 +01:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2011-01-17 09:45:40 +01:00
|
|
|
*
|
2012-01-05 02:29:29 +01:00
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
2011-01-17 09:45:40 +01:00
|
|
|
*
|
2012-01-05 02:29:29 +01:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2011-01-17 09:45:40 +01:00
|
|
|
*/
|
|
|
|
#ifndef PIOS_ADXL345_H
|
|
|
|
#define PIOS_ADXL345_H
|
|
|
|
|
|
|
|
// Defined by data rate, not BW
|
|
|
|
|
|
|
|
#define ADXL_READ_BIT 0x80
|
|
|
|
#define ADXL_MULTI_BIT 0x40
|
|
|
|
|
2012-01-24 08:26:29 +01:00
|
|
|
#define ADXL_WHOAMI 0x00
|
|
|
|
#define ADXL_DEVICE_ID 0xE5
|
2011-01-17 09:45:40 +01:00
|
|
|
#define ADXL_X0_ADDR 0x32
|
2011-08-14 01:44:19 +02:00
|
|
|
#define ADXL_FIFOSTATUS_ADDR 0x39
|
2011-01-17 09:45:40 +01:00
|
|
|
|
|
|
|
#define ADXL_RATE_ADDR 0x2C
|
|
|
|
#define ADXL_RATE_100 0x0A
|
|
|
|
#define ADXL_RATE_200 0x0B
|
|
|
|
#define ADXL_RATE_400 0x0C
|
2011-01-24 08:52:08 +01:00
|
|
|
#define ADXL_RATE_800 0x0D
|
|
|
|
#define ADXL_RATE_1600 0x0E
|
|
|
|
#define ADXL_RATE_3200 0x0F
|
2011-01-17 09:45:40 +01:00
|
|
|
|
|
|
|
#define ADXL_POWER_ADDR 0x2D
|
|
|
|
#define ADXL_MEAURE 0x08
|
|
|
|
|
|
|
|
#define ADXL_FORMAT_ADDR 0x31
|
|
|
|
#define ADXL_FULL_RES 0x08
|
|
|
|
#define ADXL_4WIRE 0x00
|
|
|
|
#define ADXL_RANGE_2G 0x00
|
|
|
|
#define ADXL_RANGE_4G 0x01
|
|
|
|
#define ADXL_RANGE_8G 0x02
|
|
|
|
#define ADXL_RANGE_16G 0x03
|
|
|
|
|
|
|
|
#define ADXL_FIFO_ADDR 0x38
|
|
|
|
#define ADXL_FIFO_STREAM 0x80
|
|
|
|
|
|
|
|
|
|
|
|
struct pios_adxl345_data {
|
|
|
|
int16_t x;
|
|
|
|
int16_t y;
|
|
|
|
int16_t z;
|
|
|
|
};
|
|
|
|
|
2012-01-24 06:29:17 +01:00
|
|
|
int32_t PIOS_ADXL345_SelectRate(uint8_t rate);
|
|
|
|
int32_t PIOS_ADXL345_SetRange(uint8_t range);
|
|
|
|
int32_t PIOS_ADXL345_Init(uint32_t spi_id, uint32_t slave_num);
|
2011-01-17 09:45:40 +01:00
|
|
|
uint8_t PIOS_ADXL345_Read(struct pios_adxl345_data * data);
|
2012-01-24 08:26:29 +01:00
|
|
|
int32_t PIOS_ADXL345_FifoElements();
|
|
|
|
int32_t PIOS_ADXL345_Test();
|
2011-01-17 09:45:40 +01:00
|
|
|
|
2011-02-12 23:19:50 +01:00
|
|
|
#endif
|
2012-01-05 02:29:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
* @}
|
|
|
|
*/
|