Paparazzi UAS  v6.2_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;
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 */
Int16Vect3
Definition: pprz_algebra_int.h:62
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
IST_CONF_CNTL4
@ IST_CONF_CNTL4
Definition: ist8310.h:43
IST_STATUS_IDLE
@ IST_STATUS_IDLE
Definition: ist8310.h:49
ist8310_regs.h
IST_CONF_CNTL3
@ IST_CONF_CNTL3
Definition: ist8310.h:42
IST8310::initialized
bool initialized
config done flag
Definition: ist8310.h:58
IST8310::init_status
enum IST8310ConfStatus init_status
init status
Definition: ist8310.h:61
IST_STATUS_READ
@ IST_STATUS_READ
Definition: ist8310.h:50
IST8310
Default IST8310 structure.
Definition: ist8310.h:55
IST_STATUS_DONE
@ IST_STATUS_DONE
Definition: ist8310.h:51
IST8310Status
IST8310Status
Normal status states.
Definition: ist8310.h:48
pprz_algebra_int.h
Paparazzi fixed point algebra.
IST_CONF_DONE
@ IST_CONF_DONE
Definition: ist8310.h:44
int16_t
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
std.h
IST8310::data
union IST8310::@309 data
ist8310_read
void ist8310_read(struct IST8310 *ist)
Definition: ist8310.c:98
ist8310_periodic
static void ist8310_periodic(struct IST8310 *ist)
convenience function: read or start configuration if not already initialized
Definition: ist8310.h:77
IST8310::data_available
volatile bool data_available
data ready flag
Definition: ist8310.h:63
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
IST_CONF_CNTL1
@ IST_CONF_CNTL1
Definition: ist8310.h:41
ist8310_init
void ist8310_init(struct IST8310 *ist, struct i2c_periph *i2c_p, uint8_t addr)
Initialize IST8310 struct.
Definition: ist8310.c:34
IST8310::i2c_trans
struct i2c_transaction i2c_trans
i2c transaction used for communication with the ist8310
Definition: ist8310.h:57
ist8310_event
void ist8310_event(struct IST8310 *ist)
Definition: ist8310.c:111
IST8310::i2c_p
struct i2c_periph * i2c_p
peripheral used for communcation
Definition: ist8310.h:56
IST_CONF_UNINIT
@ IST_CONF_UNINIT
Definition: ist8310.h:40
IST8310::status
enum IST8310Status status
main status
Definition: ist8310.h:60
IST8310ConfStatus
IST8310ConfStatus
Config status states.
Definition: ist8310.h:39
i2c_periph
Definition: i2c.h:144
i2c.h
ist8310_configure
void ist8310_configure(struct IST8310 *ist)
Definition: ist8310.c:46