Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ak8963.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freek van Tienen <freek.v.tienen@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 AK8963_H
29 #define AK8963_H
30 
31 #include "std.h"
32 #include "mcu_periph/i2c.h"
33 #include "math/pprz_algebra_int.h"
34 
35 /* Address and register definitions */
37 
43 };
44 
50 };
51 
53 struct Ak8963 {
54  struct i2c_periph *i2c_p;
56  bool initialized;
57 
60 
61  volatile bool data_available;
62  union {
63  struct Int16Vect3 vect;
64  int16_t value[3];
65  } data;
66 };
67 
68 // Functions
69 extern void ak8963_init(struct Ak8963 *ak, struct i2c_periph *i2c_p, uint8_t addr);
70 extern void ak8963_configure(struct Ak8963 *ak);
71 extern void ak8963_event(struct Ak8963 *ak);
72 extern void ak8963_read(struct Ak8963 *ak);
73 
75 static inline void ak8963_periodic(struct Ak8963 *ak)
76 {
77  if (ak->initialized) {
78  ak8963_read(ak);
79  } else {
80  ak8963_configure(ak);
81  }
82 }
83 
84 #endif /* AK8963_H */
Ak8963ConfStatus
Config status states.
Definition: ak8963.h:39
void ak8963_configure(struct Ak8963 *ak)
Definition: ak8963.c:46
bool initialized
config done flag
Definition: ak8963.h:56
enum Ak8963Status status
main status
Definition: ak8963.h:58
Default Ak8963 structure.
Definition: ak8963.h:53
struct i2c_periph * i2c_p
peripheral used for communcation
Definition: ak8963.h:54
enum Ak8963ConfStatus init_status
init status
Definition: ak8963.h:59
Ak8963Status
Normal status states.
Definition: ak8963.h:46
signed short int16_t
Definition: types.h:17
I2C transaction structure.
Definition: i2c.h:93
I2C peripheral structure.
Definition: i2c.h:138
unsigned char uint8_t
Definition: types.h:14
static void ak8963_periodic(struct Ak8963 *ak)
convenience function: read or start configuration if not already initialized
Definition: ak8963.h:75
void ak8963_read(struct Ak8963 *ak)
Definition: ak8963.c:83
volatile bool data_available
data ready flag
Definition: ak8963.h:61
void ak8963_init(struct Ak8963 *ak, struct i2c_periph *i2c_p, uint8_t addr)
Initialize AK8963 struct.
Definition: ak8963.c:34
struct i2c_transaction i2c_trans
i2c transaction used for communication with the ak8936
Definition: ak8963.h:55
union Ak8963::@295 data
void ak8963_event(struct Ak8963 *ak)
Definition: ak8963.c:95
Paparazzi fixed point algebra.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.