Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces 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 {
47  bool int_invert;
48  bool full_res;
49  bool justify_msb;
50  bool self_test;
51  bool spi_3_wire;
54 };
55 
56 static inline void adxl345_set_default_config(struct Adxl345Config *c)
57 {
58  c->drdy_int_enable = false;
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
static uint8_t adxl345_data_format(struct Adxl345Config *c)
Definition: adxl345.h:69
bool spi_3_wire
Set 3-wire SPI mode, if FALSE: 4-wire SPI mode.
Definition: adxl345.h:51
bool self_test
Enable self-test-force causing shift in output data.
Definition: adxl345.h:50
bool justify_msb
justify: FALSE: right with sign-extension, TRUE: MSB (left)
Definition: adxl345.h:49
bool drdy_int_enable
Enable Data Ready Interrupt.
Definition: adxl345.h:46
enum Adxl345Rates rate
Data Output Rate.
Definition: adxl345.h:53
Register and address definitions for ADXL345 accelerometer.
bool full_res
Full Resolution: FALSE: 10bit, TRUE: full with 4mg/LSB.
Definition: adxl345.h:48
Adxl345Rates
Selectable data rates in ADXL345_REG_BW_RATE bandwith is always half of data rate.
Definition: adxl345_regs.h:51
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 int_invert
Invert Interrupt FALSE: active high, TRUE: active low.
Definition: adxl345.h:47
enum Adxl345Ranges range
g Range
Definition: adxl345.h:52