Paparazzi UAS v7.0_unstable
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"
34
35/* Address and register definitions */
37
44
51
53struct Ak8963 {
54 struct i2c_periph *i2c_p;
57
60
61 volatile bool data_available;
62 union {
63 struct Int16Vect3 vect;
64 int16_t value[3];
66};
67
68// Functions
69extern void ak8963_init(struct Ak8963 *ak, struct i2c_periph *i2c_p, uint8_t addr);
70extern void ak8963_configure(struct Ak8963 *ak);
71extern void ak8963_event(struct Ak8963 *ak);
72extern void ak8963_read(struct Ak8963 *ak);
73
75static inline void ak8963_periodic(struct Ak8963 *ak)
76{
77 if (ak->initialized) {
78 ak8963_read(ak);
79 } else {
81 }
82}
83
84#endif /* AK8963_H */
void ak8963_event(struct Ak8963 *ak)
Definition ak8963.c:95
enum Ak8963Status status
main status
Definition ak8963.h:58
void ak8963_configure(struct Ak8963 *ak)
Definition ak8963.c:46
Ak8963Status
Normal status states.
Definition ak8963.h:46
@ AK_STATUS_IDLE
Definition ak8963.h:47
@ AK_STATUS_DONE
Definition ak8963.h:49
@ AK_STATUS_READ
Definition ak8963.h:48
struct i2c_transaction i2c_trans
i2c transaction used for communication with the ak8936
Definition ak8963.h:55
enum Ak8963ConfStatus init_status
init status
Definition ak8963.h:59
bool initialized
config done flag
Definition ak8963.h:56
volatile bool data_available
data ready flag
Definition ak8963.h:61
union Ak8963::@310 data
struct i2c_periph * i2c_p
peripheral used for communcation
Definition ak8963.h:54
void ak8963_init(struct Ak8963 *ak, struct i2c_periph *i2c_p, uint8_t addr)
Initialize AK8963 struct.
Definition ak8963.c:34
static void ak8963_periodic(struct Ak8963 *ak)
convenience function: read or start configuration if not already initialized
Definition ak8963.h:75
Ak8963ConfStatus
Config status states.
Definition ak8963.h:39
@ AK_CONF_MODE
Definition ak8963.h:41
@ AK_CONF_UNINIT
Definition ak8963.h:40
@ AK_CONF_DONE
Definition ak8963.h:42
void ak8963_read(struct Ak8963 *ak)
Definition ak8963.c:83
Default Ak8963 structure.
Definition ak8963.h:53
I2C transaction structure.
Definition i2c.h:93
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
Paparazzi fixed point algebra.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.