Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces 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 initialized;
65  volatile bool data_available;
66  union {
67  struct Int16Vect3 vect;
68  int16_t value[3];
69  } data;
73 };
74 
75 
76 // TODO IRQ handling
77 
78 // Functions
79 extern void hmc58xx_init(struct Hmc58xx *hmc, struct i2c_periph *i2c_p, uint8_t addr);
80 extern void hmc58xx_start_configure(struct Hmc58xx *hmc);
81 extern void hmc58xx_read(struct Hmc58xx *hmc);
82 extern void hmc58xx_event(struct Hmc58xx *hmc);
83 
85 static inline void hmc58xx_periodic(struct Hmc58xx *hmc)
86 {
87  if (hmc->initialized) {
88  hmc58xx_read(hmc);
89  } else {
91  }
92 }
93 
94 #endif /* HMC58XX_H */
unsigned short uint16_t
Definition: types.h:16
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:75
bool initialized
config done flag
Definition: hmc58xx.h:63
volatile bool data_available
data ready flag
Definition: hmc58xx.h:65
struct i2c_periph * i2c_p
Definition: hmc58xx.h:61
enum Hmc58xxType type
Definition: hmc58xx.h:71
enum Hmc58xxConfStatus init_status
init status
Definition: hmc58xx.h:64
uint8_t mode
Measurement mode.
Definition: hmc58xx.h:43
void hmc58xx_read(struct Hmc58xx *hmc)
Definition: hmc58xx.c:139
struct i2c_transaction i2c_trans
Definition: hmc58xx.h:62
uint8_t gain
Gain configuration (1 -> +- 1 Gauss)
Definition: hmc58xx.h:42
union Hmc58xx::@303 data
uint8_t meas
Measurement configuration.
Definition: hmc58xx.h:41
void hmc58xx_start_configure(struct Hmc58xx *hmc)
Definition: hmc58xx.c:126
signed short int16_t
Definition: types.h:17
uint8_t rate
Data Output Rate Bits(6 -> 50Hz with HMC5843, 75Hz with HMC5883)
Definition: hmc58xx.h:40
I2C transaction structure.
Definition: i2c.h:93
Hmc58xxConfStatus
config status states
Definition: hmc58xx.h:47
Register defs for Honeywell HMC5843 and HMC5883 magnetometers.
I2C peripheral structure.
Definition: i2c.h:138
void hmc58xx_event(struct Hmc58xx *hmc)
Definition: hmc58xx.c:152
uint16_t adc_overflow_cnt
counts number of ADC measurement under/overflows
Definition: hmc58xx.h:72
unsigned char uint8_t
Definition: types.h:14
struct Hmc58xxConfig config
Definition: hmc58xx.h:70
static void hmc58xx_periodic(struct Hmc58xx *hmc)
convenience function: read or start configuration if not already initialized
Definition: hmc58xx.h:85
Hmc58xxType
Definition: hmc58xx.h:55
Paparazzi fixed point algebra.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.