Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ms2100.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
3  * Copyright (C) 2012 Gautier Hattenberger
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 
28 #ifndef MS2100_H
29 #define MS2100_H
30 
31 #include "std.h"
32 #include "mcu_periph/spi.h"
33 #include "math/pprz_algebra_int.h"
34 
35 
42 };
43 
44 struct Ms2100 {
45  struct spi_periph *spi_p;
48  volatile uint8_t req_buf[1];
49  volatile uint8_t read_buf[2];
50  volatile enum Ms2100Status status;
51  volatile uint8_t cur_axe;
52  union {
53  struct Int16Vect3 vect;
54  int16_t value[3];
55  } data;
56 };
57 
58 // keep gobal var for now...
59 extern struct Ms2100 ms2100;
60 
61 extern void ms2100_init(struct Ms2100 *ms, struct spi_periph *spi_p, uint8_t slave_idx);
62 extern void ms2100_read(struct Ms2100 *ms);
63 extern void ms2100_event(struct Ms2100 *ms);
64 
65 static inline void ms2100_periodic(struct Ms2100 *ms)
66 {
67  if (ms->status == MS2100_IDLE) {
68  ms2100_read(ms);
69  }
70 }
71 
72 /* underlying architecture */
73 #include "peripherals/ms2100_arch.h"
74 /* must be implemented by underlying architecture */
75 extern void ms2100_arch_init(void);
76 
77 #endif /* MS2100_H */
struct spi_transaction req_trans
Definition: ms2100.h:46
void ms2100_event(struct Ms2100 *ms)
Definition: ms2100.c:105
Ms2100Status
Definition: ms2100.h:36
void ms2100_read(struct Ms2100 *ms)
send request to read next axis
Definition: ms2100.c:96
volatile uint8_t req_buf[1]
SPI buffer for the command byte.
Definition: ms2100.h:48
SPI transaction structure.
Definition: spi.h:148
volatile uint8_t read_buf[2]
SPI buffer for reading a single axis.
Definition: ms2100.h:49
Architecture independent SPI (Serial Peripheral Interface) API.
void ms2100_arch_init(void)
Definition: ms2100_arch.c:38
Definition: ms2100.h:44
SPI peripheral structure.
Definition: spi.h:174
struct spi_transaction read_trans
Definition: ms2100.h:47
volatile uint8_t cur_axe
Definition: ms2100.h:51
signed short int16_t
Definition: types.h:17
unsigned char uint8_t
Definition: types.h:14
void ms2100_init(struct Ms2100 *ms, struct spi_periph *spi_p, uint8_t slave_idx)
Definition: ms2100.c:47
struct spi_periph * spi_p
Definition: ms2100.h:45
struct Ms2100 ms2100
Definition: ms2100.c:44
union Ms2100::@337 data
static void ms2100_periodic(struct Ms2100 *ms)
Definition: ms2100.h:65
enum Ms2100Status status
Definition: ms2100.h:50
Paparazzi fixed point algebra.