Paparazzi UAS  v5.18.0_stable
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 
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 
65  c->rate = ADXL345_RATE_100HZ;
66  c->range = ADXL345_RANGE_16G;
67 }
68 
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
c
VIC slots used for the LPC2148 define name e g gps UART1_VIC_SLOT e g modem SPI1_VIC_SLOT SPI1 in mcu_periph spi_arch c or spi_slave_hs_arch c(and some others not using the SPI peripheral yet..) I2C0_VIC_SLOT 8 mcu_periph/i2c_arch.c I2C1_VIC_SLOT 9 mcu_periph/i2c_arch.c USB_VIC_SLOT 10 usb
Adxl345Config::justify_msb
bool justify_msb
justify: FALSE: right with sign-extension, TRUE: MSB (left)
Definition: adxl345.h:49
Adxl345Config::range
enum Adxl345Ranges range
g Range
Definition: adxl345.h:52
Adxl345Config::drdy_int_enable
bool drdy_int_enable
Enable Data Ready Interrupt.
Definition: adxl345.h:46
ADXL_CONF_INT
@ ADXL_CONF_INT
Definition: adxl345.h:39
adxl345_regs.h
Adxl345Config::spi_3_wire
bool spi_3_wire
Set 3-wire SPI mode, if FALSE: 4-wire SPI mode.
Definition: adxl345.h:51
ADXL_CONF_FORMAT
@ ADXL_CONF_FORMAT
Definition: adxl345.h:40
Adxl345Config::rate
enum Adxl345Rates rate
Data Output Rate.
Definition: adxl345.h:53
ADXL_CONF_DONE
@ ADXL_CONF_DONE
Definition: adxl345.h:42
Adxl345Config::self_test
bool self_test
Enable self-test-force causing shift in output data.
Definition: adxl345.h:50
ADXL_CONF_ENABLE
@ ADXL_CONF_ENABLE
Definition: adxl345.h:41
ADXL_CONF_UNINIT
@ ADXL_CONF_UNINIT
Definition: adxl345.h:37
ADXL345_RANGE_16G
@ ADXL345_RANGE_16G
Definition: adxl345_regs.h:69
std.h
ADXL345_RATE_100HZ
@ ADXL345_RATE_100HZ
Definition: adxl345_regs.h:54
Adxl345Rates
Adxl345Rates
Selectable data rates in ADXL345_REG_BW_RATE bandwith is always half of data rate.
Definition: adxl345_regs.h:51
uint8_t
unsigned char uint8_t
Definition: types.h:14
Adxl345Config::full_res
bool full_res
Full Resolution: FALSE: 10bit, TRUE: full with 4mg/LSB.
Definition: adxl345.h:48
Adxl345ConfStatus
Adxl345ConfStatus
Definition: adxl345.h:36
ADXL_CONF_RATE
@ ADXL_CONF_RATE
Definition: adxl345.h:38
adxl345_set_default_config
static void adxl345_set_default_config(struct Adxl345Config *c)
Definition: adxl345.h:56
Adxl345Config::int_invert
bool int_invert
Invert Interrupt FALSE: active high, TRUE: active low.
Definition: adxl345.h:47
adxl345_data_format
static uint8_t adxl345_data_format(struct Adxl345Config *c)
Definition: adxl345.h:69
Adxl345Config
Definition: adxl345.h:45
Adxl345Ranges
Adxl345Ranges
Selectable range in ADXL345_REG_DATA_FORMAT.
Definition: adxl345_regs.h:65