Paparazzi UAS
v6.1.0_stable
Paparazzi is a free software Unmanned Aircraft System.
lsm303d.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2011 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3
* 2013 Felix Ruess <felix.ruess@gmail.com>
4
*
5
* This file is part of paparazzi.
6
*
7
* paparazzi is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2, or (at your option)
10
* any later version.
11
*
12
* paparazzi is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with paparazzi; see the file COPYING. If not, write to
19
* the Free Software Foundation, 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
21
*/
22
28
#ifndef LSM303D_H
29
#define LSM303D_H
30
31
#include "
std.h
"
32
/* Address and register definitions */
33
#include "
peripherals/lsm303d_regs.h
"
34
35
/* LSM303D default conf */
36
#ifndef LSM303D_DEFAULT_AODR
37
#define LSM303D_DEFAULT_AODR (LSM303D_ACC_RATE_1600HZ << 4) //acc 1600 Hz
38
#endif
39
40
#ifndef LSM303D_DEFAULT_AFS
41
#define LSM303D_DEFAULT_AFS (LSM303D_ACC_RANGE_16G << 3) // acc +- 16G
42
#endif
43
44
#ifndef LSM303D_DEFAULT_MODR
45
#define LSM303D_DEFAULT_MODR (LSM303D_MAG_RATE_100HZ << 2) // Magneto Data Output Rate (100Hz)
46
#endif
47
48
#ifndef LSM303D_DEFAULT_MFS
49
#define LSM303D_DEFAULT_MFS (LSM303D_MAG_RANGE_2GAUSS << 5) // Magneto gain configuration (+/- 2 Gauss)
50
#endif
51
52
#ifndef LSM303D_DEFAULT_MD
53
#define LSM303D_DEFAULT_MD (LSM303D_MAG_MODE_CONTINOUS_CONVERSION << 0) // Magneto continious conversion mode
54
#endif
55
56
struct
Lsm303dConfig
{
57
uint8_t
acc_rate
;
58
uint8_t
acc_scale
;
59
60
uint8_t
mag_rate
;
61
uint8_t
mag_scale
;
62
uint8_t
mag_mode
;
63
};
64
65
67
enum
Lsm303dConfStatus
{
68
LSM303D_CONF_UNINIT
,
69
LSM303D_CONF_WHO_AM_I
,
70
LSM303D_CONF_CTRL_REG1
,
71
LSM303D_CONF_CTRL_REG2
,
72
LSM303D_CONF_CTRL_REG3
,
73
LSM303D_CONF_CTRL_REG4
,
74
LSM303D_CONF_CTRL_REG5
,
75
LSM303D_CONF_CTRL_REG6
,
76
LSM303D_CONF_CTRL_REG7
,
77
LSM303D_CONF_DONE
78
};
79
80
enum
Lsm303dTarget
{
81
LSM303D_TARGET_ACC
,
82
LSM303D_TARGET_MAG
83
};
84
85
static
inline
void
lsm303d_set_default_config
(
struct
Lsm303dConfig
*c)
86
{
87
c->
acc_rate
=
LSM303D_DEFAULT_AODR
;
88
c->
acc_scale
=
LSM303D_DEFAULT_AFS
;
89
c->
mag_rate
=
LSM303D_DEFAULT_MODR
;
90
c->
mag_scale
=
LSM303D_DEFAULT_MFS
;
91
c->
mag_mode
=
LSM303D_DEFAULT_MD
;
92
}
93
94
#endif // LSM303D_H
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition:
vl53l1_types.h:98
LSM303D_CONF_CTRL_REG1
@ LSM303D_CONF_CTRL_REG1
Definition:
lsm303d.h:70
Lsm303dTarget
Lsm303dTarget
Definition:
lsm303d.h:80
LSM303D_DEFAULT_MODR
#define LSM303D_DEFAULT_MODR
Definition:
lsm303d.h:45
LSM303D_CONF_CTRL_REG6
@ LSM303D_CONF_CTRL_REG6
Definition:
lsm303d.h:75
LSM303D_DEFAULT_AFS
#define LSM303D_DEFAULT_AFS
Definition:
lsm303d.h:41
lsm303d_set_default_config
static void lsm303d_set_default_config(struct Lsm303dConfig *c)
Definition:
lsm303d.h:85
Lsm303dConfig::mag_mode
uint8_t mag_mode
Measurement mode.
Definition:
lsm303d.h:62
std.h
Lsm303dConfig
Definition:
lsm303d.h:56
LSM303D_CONF_CTRL_REG7
@ LSM303D_CONF_CTRL_REG7
Definition:
lsm303d.h:76
Lsm303dConfStatus
Lsm303dConfStatus
config status states
Definition:
lsm303d.h:67
Lsm303dConfig::acc_scale
uint8_t acc_scale
full scale selection (m/s²)
Definition:
lsm303d.h:58
LSM303D_TARGET_ACC
@ LSM303D_TARGET_ACC
Definition:
lsm303d.h:81
Lsm303dConfig::acc_rate
uint8_t acc_rate
Data Output Rate (Hz)
Definition:
lsm303d.h:57
Lsm303dConfig::mag_scale
uint8_t mag_scale
Full scale gain configuration (Gauss)
Definition:
lsm303d.h:61
LSM303D_CONF_WHO_AM_I
@ LSM303D_CONF_WHO_AM_I
Definition:
lsm303d.h:69
LSM303D_CONF_DONE
@ LSM303D_CONF_DONE
Definition:
lsm303d.h:77
Lsm303dConfig::mag_rate
uint8_t mag_rate
Data Output Rate Bits (Hz)
Definition:
lsm303d.h:60
LSM303D_CONF_UNINIT
@ LSM303D_CONF_UNINIT
Definition:
lsm303d.h:68
LSM303D_DEFAULT_MD
#define LSM303D_DEFAULT_MD
Definition:
lsm303d.h:53
LSM303D_DEFAULT_MFS
#define LSM303D_DEFAULT_MFS
Definition:
lsm303d.h:49
LSM303D_CONF_CTRL_REG5
@ LSM303D_CONF_CTRL_REG5
Definition:
lsm303d.h:74
LSM303D_TARGET_MAG
@ LSM303D_TARGET_MAG
Definition:
lsm303d.h:82
LSM303D_CONF_CTRL_REG3
@ LSM303D_CONF_CTRL_REG3
Definition:
lsm303d.h:72
LSM303D_CONF_CTRL_REG4
@ LSM303D_CONF_CTRL_REG4
Definition:
lsm303d.h:73
LSM303D_CONF_CTRL_REG2
@ LSM303D_CONF_CTRL_REG2
Definition:
lsm303d.h:71
lsm303d_regs.h
LSM303D_DEFAULT_AODR
#define LSM303D_DEFAULT_AODR
Definition:
lsm303d.h:37
sw
airborne
peripherals
lsm303d.h
Generated on Tue Feb 1 2022 13:08:46 for Paparazzi UAS by
1.8.17