Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
adxl345.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Felix Ruess <felix.ruess@gmail.com>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
28 #ifndef ADXL345_H
29 #define ADXL345_H
30 
31 #include "std.h"
32 
33 /* Include address and register definition */
35 
43 };
44 
45 struct Adxl345Config {
46  bool_t drdy_int_enable;
47  bool_t int_invert;
48  bool_t full_res;
49  bool_t justify_msb;
50  bool_t self_test;
51  bool_t spi_3_wire;
54 };
55 
56 static inline void adxl345_set_default_config(struct Adxl345Config *c)
57 {
59  c->int_invert = TRUE;
60  c->full_res = TRUE;
61  c->justify_msb = FALSE;
62  c->self_test = FALSE;
63  c->spi_3_wire = FALSE;
64 
67 }
68 
69 static inline uint8_t adxl345_data_format(struct Adxl345Config *c)
70 {
71  return ((c->self_test << 7) | (c->spi_3_wire << 6) | (c->int_invert << 5) |
72  (c->full_res << 3) | (c->justify_msb << 2) | (c->range));
73 }
74 
75 #endif // ADXL345_H
Adxl345Ranges
Selectable range in ADXL345_REG_DATA_FORMAT.
Definition: adxl345_regs.h:65
bool_t int_invert
Invert Interrupt FALSE: active high, TRUE: active low.
Definition: adxl345.h:47
static uint8_t adxl345_data_format(struct Adxl345Config *c)
Definition: adxl345.h:69
bool_t spi_3_wire
Set 3-wire SPI mode, if FALSE: 4-wire SPI mode.
Definition: adxl345.h:51
bool_t self_test
Enable self-test-force causing shift in output data.
Definition: adxl345.h:50
enum Adxl345Ranges range
g Range
Definition: adxl345.h:52
#define FALSE
Definition: imu_chimu.h:141
Register and address definitions for ADXL345 accelerometer.
Adxl345Rates
Selectable data rates in ADXL345_REG_BW_RATE bandwith is always half of data rate.
Definition: adxl345_regs.h:51
#define TRUE
Definition: imu_chimu.h:144
bool_t full_res
Full Resolution: FALSE: 10bit, TRUE: full with 4mg/LSB.
Definition: adxl345.h:48
Adxl345ConfStatus
Definition: adxl345.h:36
unsigned char uint8_t
Definition: types.h:14
static void adxl345_set_default_config(struct Adxl345Config *c)
Definition: adxl345.h:56
bool_t justify_msb
justify: FALSE: right with sign-extension, TRUE: MSB (left)
Definition: adxl345.h:49
enum Adxl345Rates rate
Data Output Rate.
Definition: adxl345.h:53
bool_t drdy_int_enable
Enable Data Ready Interrupt.
Definition: adxl345.h:46