Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 */
Int16Vect3
Definition: pprz_algebra_int.h:62
Ms2100::cur_axe
volatile uint8_t cur_axe
Definition: ms2100.h:51
ms2100_read
void ms2100_read(struct Ms2100 *ms)
send request to read next axis
Definition: ms2100.c:96
spi.h
spi_transaction
SPI transaction structure.
Definition: spi.h:148
MS2100_READING_RES
@ MS2100_READING_RES
Definition: ms2100.h:40
MS2100_SENDING_REQ
@ MS2100_SENDING_REQ
Definition: ms2100.h:38
MS2100_IDLE
@ MS2100_IDLE
Definition: ms2100.h:37
Ms2100::req_buf
volatile uint8_t req_buf[1]
SPI buffer for the command byte.
Definition: ms2100.h:48
pprz_algebra_int.h
Paparazzi fixed point algebra.
spi_periph
SPI peripheral structure.
Definition: spi.h:174
std.h
Ms2100::status
enum Ms2100Status status
Definition: ms2100.h:50
MS2100_DATA_AVAILABLE
@ MS2100_DATA_AVAILABLE
Definition: ms2100.h:41
ms2100_arch_init
void ms2100_arch_init(void)
Definition: ms2100_arch.c:38
int16_t
signed short int16_t
Definition: types.h:17
Ms2100::spi_p
struct spi_periph * spi_p
Definition: ms2100.h:45
uint8_t
unsigned char uint8_t
Definition: types.h:14
ms2100
struct Ms2100 ms2100
Definition: ms2100.c:44
Ms2100::data
union Ms2100::@339 data
Ms2100Status
Ms2100Status
Definition: ms2100.h:36
Ms2100::read_trans
struct spi_transaction read_trans
Definition: ms2100.h:47
ms2100_event
void ms2100_event(struct Ms2100 *ms)
Definition: ms2100.c:105
Ms2100::read_buf
volatile uint8_t read_buf[2]
SPI buffer for reading a single axis.
Definition: ms2100.h:49
ms2100_periodic
static void ms2100_periodic(struct Ms2100 *ms)
Definition: ms2100.h:65
ms2100_init
void ms2100_init(struct Ms2100 *ms, struct spi_periph *spi_p, uint8_t slave_idx)
Definition: ms2100.c:47
Ms2100
Definition: ms2100.h:44
MS2100_GOT_EOC
@ MS2100_GOT_EOC
Definition: ms2100.h:39
Ms2100::req_trans
struct spi_transaction req_trans
Definition: ms2100.h:46