Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 
42  ADXL_CONF_DONE = 5
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;
52  enum Adxl345Ranges range;
53  enum Adxl345Rates rate;
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
bool self_test
Enable self-test-force causing shift in output data.
Definition: adxl345.h:50
bool drdy_int_enable
Enable Data Ready Interrupt.
Definition: adxl345.h:46
bool full_res
Full Resolution: FALSE: 10bit, TRUE: full with 4mg/LSB.
Definition: adxl345.h:48
enum Adxl345Rates rate
Data Output Rate.
Definition: adxl345.h:53
static void adxl345_set_default_config(struct Adxl345Config *c)
Definition: adxl345.h:56
enum Adxl345Ranges range
g Range
Definition: adxl345.h:52
bool int_invert
Invert Interrupt FALSE: active high, TRUE: active low.
Definition: adxl345.h:47
Adxl345ConfStatus
Definition: adxl345.h:36
@ ADXL_CONF_FORMAT
Definition: adxl345.h:40
@ ADXL_CONF_DONE
Definition: adxl345.h:42
@ ADXL_CONF_RATE
Definition: adxl345.h:38
@ ADXL_CONF_INT
Definition: adxl345.h:39
@ ADXL_CONF_ENABLE
Definition: adxl345.h:41
@ ADXL_CONF_UNINIT
Definition: adxl345.h:37
bool spi_3_wire
Set 3-wire SPI mode, if FALSE: 4-wire SPI mode.
Definition: adxl345.h:51
static uint8_t adxl345_data_format(struct Adxl345Config *c)
Definition: adxl345.h:69
bool justify_msb
justify: FALSE: right with sign-extension, TRUE: MSB (left)
Definition: adxl345.h:49
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
@ ADXL345_RATE_100HZ
Definition: adxl345_regs.h:54
Adxl345Ranges
Selectable range in ADXL345_REG_DATA_FORMAT.
Definition: adxl345_regs.h:65
@ ADXL345_RANGE_16G
Definition: adxl345_regs.h:69
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98