Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 */
Int16Vect3
Definition: pprz_algebra_int.h:62
Ak8963
Default Ak8963 structure.
Definition: ak8963.h:53
AK_STATUS_READ
@ AK_STATUS_READ
Definition: ak8963.h:48
ak8963_configure
void ak8963_configure(struct Ak8963 *ak)
Definition: ak8963.c:46
Ak8963::data
union Ak8963::@306 data
ak8963_read
void ak8963_read(struct Ak8963 *ak)
Definition: ak8963.c:83
ak8963_regs.h
AK_CONF_MODE
@ AK_CONF_MODE
Definition: ak8963.h:41
ak8963_event
void ak8963_event(struct Ak8963 *ak)
Definition: ak8963.c:95
Ak8963::init_status
enum Ak8963ConfStatus init_status
init status
Definition: ak8963.h:59
AK_CONF_UNINIT
@ AK_CONF_UNINIT
Definition: ak8963.h:40
pprz_algebra_int.h
Paparazzi fixed point algebra.
std.h
AK_STATUS_DONE
@ AK_STATUS_DONE
Definition: ak8963.h:49
Ak8963Status
Ak8963Status
Normal status states.
Definition: ak8963.h:46
Ak8963::i2c_p
struct i2c_periph * i2c_p
peripheral used for communcation
Definition: ak8963.h:54
int16_t
signed short int16_t
Definition: types.h:17
uint8_t
unsigned char uint8_t
Definition: types.h:14
Ak8963::initialized
bool initialized
config done flag
Definition: ak8963.h:56
Ak8963::status
enum Ak8963Status status
main status
Definition: ak8963.h:58
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
ak8963_periodic
static void ak8963_periodic(struct Ak8963 *ak)
convenience function: read or start configuration if not already initialized
Definition: ak8963.h:75
Ak8963ConfStatus
Ak8963ConfStatus
Config status states.
Definition: ak8963.h:39
AK_CONF_DONE
@ AK_CONF_DONE
Definition: ak8963.h:42
AK_STATUS_IDLE
@ AK_STATUS_IDLE
Definition: ak8963.h:47
Ak8963::i2c_trans
struct i2c_transaction i2c_trans
i2c transaction used for communication with the ak8936
Definition: ak8963.h:55
Ak8963::data_available
volatile bool data_available
data ready flag
Definition: ak8963.h:61
i2c_periph
Definition: i2c.h:144
i2c.h
ak8963_init
void ak8963_init(struct Ak8963 *ak, struct i2c_periph *i2c_p, uint8_t addr)
Initialize AK8963 struct.
Definition: ak8963.c:34