Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
high_speed_logger_spi_link.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2013 The Paparazzi Team
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  */
22 
24 
25 #include "modules/core/abi.h"
26 #include "modules/imu/imu.h"
27 #include "mcu_periph/spi.h"
28 
29 
32 
33 static volatile bool high_speed_logger_spi_link_ready = true;
34 static struct imu_gyro_t *hsl_gyro;
35 static struct imu_accel_t *hsl_accel;
36 static struct imu_mag_t *hsl_mag;
37 
38 static void high_speed_logger_spi_link_trans_cb(struct spi_transaction *trans);
39 
41 {
43 
50  high_speed_logger_spi_link_transaction.slave_idx = HIGH_SPEED_LOGGER_SPI_LINK_SLAVE_NUMBER;
56 }
57 
58 
60 {
61  // Static counter to identify missing samples
62  static int32_t counter = 0;
63 
64  // count all periodic steps
65  counter ++;
66 
67  // only send a new message if the previous was completely sent
69  // copy the counter into the SPI datablock
71 
72  if(hsl_gyro == NULL)
74  if(hsl_accel == NULL)
76  if(hsl_mag == NULL)
78 
79  if(hsl_gyro == NULL || hsl_accel == NULL || hsl_mag == NULL)
80  return;
81 
92 
93  spi_submit(&(HIGH_SPEED_LOGGER_SPI_LINK_DEVICE), &high_speed_logger_spi_link_transaction);
94  }
95 }
96 
97 static void high_speed_logger_spi_link_trans_cb(struct spi_transaction *trans __attribute__((unused)))
98 {
100 }
101 
102 
spi_transaction::cdiv
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
Definition: spi.h:159
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
spi_transaction::cpol
enum SPIClockPolarity cpol
clock polarity control
Definition: spi.h:155
imu_mag_t::unscaled
struct Int32Vect3 unscaled
Last unscaled values in sensor frame.
Definition: imu.h:75
abi.h
spi_transaction::output_length
uint16_t output_length
number of data words to write
Definition: spi.h:152
Int32Rates::q
int32_t q
in rad/s with INT32_RATE_FRAC
Definition: pprz_algebra_int.h:181
spi.h
imu_get_gyro
struct imu_gyro_t * imu_get_gyro(uint8_t sender_id, bool create)
Find or create the gyro in the imu structure.
Definition: imu.c:658
spi_transaction
SPI transaction structure.
Definition: spi.h:148
Int32Vect3::z
int32_t z
Definition: pprz_algebra_int.h:91
imu_get_mag
struct imu_mag_t * imu_get_mag(uint8_t sender_id, bool create)
Find or create the mag in the imu structure.
Definition: imu.c:705
imu_get_accel
struct imu_accel_t * imu_get_accel(uint8_t sender_id, bool create)
Find or create the accel in the imu structure.
Definition: imu.c:681
counter
int32_t counter
Definition: avoid_navigation.c:55
SPISelectUnselect
@ SPISelectUnselect
slave is selected before transaction and unselected after
Definition: spi.h:63
spi_transaction::bitorder
enum SPIBitOrder bitorder
MSB/LSB order.
Definition: spi.h:158
spi_transaction::output_buf
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
Definition: spi.h:150
spi_transaction::select
enum SPISlaveSelect select
slave selection behavior
Definition: spi.h:154
Int32Rates::p
int32_t p
in rad/s with INT32_RATE_FRAC
Definition: pprz_algebra_int.h:180
imu.h
SPIMSBFirst
@ SPIMSBFirst
Definition: spi.h:112
spi_transaction::cpha
enum SPIClockPhase cpha
clock phase control
Definition: spi.h:156
spi_transaction::after_cb
SPICallback after_cb
NULL or function called after the transaction.
Definition: spi.h:161
spi_submit
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
Definition: spi_arch.c:508
imu_mag_t
Definition: imu.h:71
SPICpolIdleHigh
@ SPICpolIdleHigh
CPOL = 1.
Definition: spi.h:84
Int32Vect3::y
int32_t y
Definition: pprz_algebra_int.h:90
SPIDss8bit
@ SPIDss8bit
Definition: spi.h:90
SPIDiv64
@ SPIDiv64
Definition: spi.h:125
int32_t
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
spi_transaction::input_length
uint16_t input_length
number of data words to read
Definition: spi.h:151
imu_accel_t
Definition: imu.h:59
spi_transaction::dss
enum SPIDataSizeSelect dss
data transfer word size
Definition: spi.h:157
spi_transaction::slave_idx
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
Definition: spi.h:153
imu_gyro_t::unscaled
struct Int32Rates unscaled
Last unscaled values in sensor frame.
Definition: imu.h:52
spi_transaction::input_buf
volatile uint8_t * input_buf
pointer to receive buffer for DMA
Definition: spi.h:149
SPICphaEdge2
@ SPICphaEdge2
CPHA = 1.
Definition: spi.h:75
Int32Vect3::x
int32_t x
Definition: pprz_algebra_int.h:89
imu_gyro_t
Definition: imu.h:47
imu_accel_t::unscaled
struct Int32Vect3 unscaled
Last unscaled values in sensor frame.
Definition: imu.h:64
ABI_BROADCAST
#define ABI_BROADCAST
Broadcast address.
Definition: abi_common.h:57
Int32Rates::r
int32_t r
in rad/s with INT32_RATE_FRAC
Definition: pprz_algebra_int.h:182