Paparazzi UAS  v6.0_unstable-22-ge44277d-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ist8310.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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 IST8310_H
29 #define IST8310_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 
45 };
46 
52 };
53 
55 struct IST8310 {
56  struct i2c_periph *i2c_p;
58  bool initialized;
59 
62 
63  volatile bool data_available;
64  union {
65  struct Int16Vect3 vect;
66  int16_t value[3];
67  } data;
68 };
69 
70 // Functions
71 extern void ist8310_init(struct IST8310 *ist, struct i2c_periph *i2c_p, uint8_t addr);
72 extern void ist8310_configure(struct IST8310 *ist);
73 extern void ist8310_event(struct IST8310 *ist);
74 extern void ist8310_read(struct IST8310 *ist);
75 
77 static inline void ist8310_periodic(struct IST8310 *ist)
78 {
79  if (ist->initialized) {
80  ist8310_read(ist);
81  } else {
82  ist8310_configure(ist);
83  }
84 }
85 
86 #endif /* IST8310_H */
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
IST8310Status
Normal status states.
Definition: ist8310.h:48
Default IST8310 structure.
Definition: ist8310.h:55
bool initialized
config done flag
Definition: ist8310.h:58
enum IST8310ConfStatus init_status
init status
Definition: ist8310.h:61
Register and address definitions for the IST8310 magnetometer.
void ist8310_read(struct IST8310 *ist)
Definition: ist8310.c:98
struct i2c_transaction i2c_trans
i2c transaction used for communication with the ist8310
Definition: ist8310.h:57
I2C transaction structure.
Definition: i2c.h:93
static void ist8310_periodic(struct IST8310 *ist)
convenience function: read or start configuration if not already initialized
Definition: ist8310.h:77
void ist8310_init(struct IST8310 *ist, struct i2c_periph *i2c_p, uint8_t addr)
Initialize IST8310 struct.
Definition: ist8310.c:34
void ist8310_event(struct IST8310 *ist)
Definition: ist8310.c:111
IST8310ConfStatus
Config status states.
Definition: ist8310.h:39
volatile bool data_available
data ready flag
Definition: ist8310.h:63
struct i2c_periph * i2c_p
peripheral used for communcation
Definition: ist8310.h:56
enum IST8310Status status
main status
Definition: ist8310.h:60
Paparazzi fixed point algebra.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
union IST8310::@308 data
void ist8310_configure(struct IST8310 *ist)
Definition: ist8310.c:46
Architecture independent I2C (Inter-Integrated Circuit Bus) API.