Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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;
57  struct i2c_transaction i2c_trans;
58  bool initialized;
59 
60  enum IST8310Status status;
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 */
I2C transaction structure.
Definition: i2c.h:93
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
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
bool initialized
config done flag
Definition: ist8310.h:58
void ist8310_event(struct IST8310 *ist)
Definition: ist8310.c:111
union IST8310::@321 data
void ist8310_init(struct IST8310 *ist, struct i2c_periph *i2c_p, uint8_t addr)
Initialize IST8310 struct.
Definition: ist8310.c:34
enum IST8310ConfStatus init_status
init status
Definition: ist8310.h:61
enum IST8310Status status
main status
Definition: ist8310.h:60
void ist8310_configure(struct IST8310 *ist)
Definition: ist8310.c:46
IST8310Status
Normal status states.
Definition: ist8310.h:48
@ IST_STATUS_READ
Definition: ist8310.h:50
@ IST_STATUS_DONE
Definition: ist8310.h:51
@ IST_STATUS_IDLE
Definition: ist8310.h:49
struct i2c_periph * i2c_p
peripheral used for communcation
Definition: ist8310.h:56
static void ist8310_periodic(struct IST8310 *ist)
convenience function: read or start configuration if not already initialized
Definition: ist8310.h:77
volatile bool data_available
data ready flag
Definition: ist8310.h:63
IST8310ConfStatus
Config status states.
Definition: ist8310.h:39
@ IST_CONF_DONE
Definition: ist8310.h:44
@ IST_CONF_CNTL3
Definition: ist8310.h:42
@ IST_CONF_CNTL1
Definition: ist8310.h:41
@ IST_CONF_UNINIT
Definition: ist8310.h:40
@ IST_CONF_CNTL4
Definition: ist8310.h:43
Default IST8310 structure.
Definition: ist8310.h:55
Register and address definitions for the IST8310 magnetometer.
Paparazzi fixed point algebra.
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98