Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
hmc58xx.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 
29 #ifndef HMC58XX_H
30 #define HMC58XX_H
31 
32 #include "std.h"
33 #include "mcu_periph/i2c.h"
34 #include "math/pprz_algebra_int.h"
35 
36 /* Address and register definitions */
38 
39 struct Hmc58xxConfig {
44 };
45 
53 };
54 
58 };
59 
60 struct Hmc58xx {
61  struct i2c_periph *i2c_p;
63  bool_t initialized;
65  volatile bool_t data_available;
66  union {
67  struct Int16Vect3 vect;
69  } data;
72 };
73 
74 
75 // TODO IRQ handling
76 
77 // Functions
78 extern void hmc58xx_init(struct Hmc58xx *hmc, struct i2c_periph *i2c_p, uint8_t addr);
79 extern void hmc58xx_start_configure(struct Hmc58xx *hmc);
80 extern void hmc58xx_read(struct Hmc58xx *hmc);
81 extern void hmc58xx_event(struct Hmc58xx *hmc);
82 
84 static inline void hmc58xx_periodic(struct Hmc58xx *hmc) {
85  if (hmc->initialized)
86  hmc58xx_read(hmc);
87  else
89 }
90 
91 #endif /* HMC58XX_H */
void hmc58xx_init(struct Hmc58xx *hmc, struct i2c_periph *i2c_p, uint8_t addr)
Initialize Hmc58xx struct and set default config options.
Definition: hmc58xx.c:62
uint8_t mode
Measurement mode.
Definition: hmc58xx.h:43
union Hmc58xx::@20 data
enum Hmc58xxConfStatus init_status
init status
Definition: hmc58xx.h:64
void hmc58xx_read(struct Hmc58xx *hmc)
Definition: hmc58xx.c:123
struct i2c_transaction i2c_trans
Definition: hmc58xx.h:62
int16_t value[3]
data values accessible by channel index
Definition: hmc58xx.h:68
void hmc58xx_start_configure(struct Hmc58xx *hmc)
Definition: hmc58xx.c:112
signed short int16_t
Definition: types.h:17
enum Hmc58xxType type
Definition: hmc58xx.h:71
Hmc58xxConfStatus
config status states
Definition: hmc58xx.h:47
struct Int16Vect3 vect
data vector in mag coordinate system
Definition: hmc58xx.h:67
Register defs for Honeywell HMC5843 and HMC5883 magnetometers.
void hmc58xx_event(struct Hmc58xx *hmc)
Definition: hmc58xx.c:136
uint8_t rate
Data Output Rate Bits(6 -> 50Hz with HMC5843, 75Hz with HMC5883)
Definition: hmc58xx.h:40
unsigned char uint8_t
Definition: types.h:14
uint8_t meas
Measurement configuration.
Definition: hmc58xx.h:41
static void hmc58xx_periodic(struct Hmc58xx *hmc)
convenience function: read or start configuration if not already initialized
Definition: hmc58xx.h:84
Definition: i2c.h:90
struct Hmc58xxConfig config
Definition: hmc58xx.h:70
Hmc58xxType
Definition: hmc58xx.h:55
struct i2c_periph * i2c_p
Definition: hmc58xx.h:61
bool_t initialized
config done flag
Definition: hmc58xx.h:63
uint8_t gain
Gain configuration (1 -> +- 1 Gauss)
Definition: hmc58xx.h:42
volatile bool_t data_available
data ready flag
Definition: hmc58xx.h:65
Paparazzi fixed point algebra.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.