Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 "subsystems/imu.h"
26 #include "mcu_periph/spi.h"
27 
28 
31 
32 static volatile bool high_speed_logger_spi_link_ready = true;
33 
34 static void high_speed_logger_spi_link_trans_cb(struct spi_transaction *trans);
35 
37 {
39 
46  high_speed_logger_spi_link_transaction.slave_idx = HIGH_SPEED_LOGGER_SPI_LINK_SLAVE_NUMBER;
52 }
53 
54 
56 {
57  // Static counter to identify missing samples
58  static int32_t counter = 0;
59 
60  // count all periodic steps
61  counter ++;
62 
63  // only send a new message if the previous was completely sent
65  // copy the counter into the SPI datablock
67 
78 
79  spi_submit(&(HIGH_SPEED_LOGGER_SPI_LINK_DEVICE), &high_speed_logger_spi_link_transaction);
80  }
81 }
82 
83 static void high_speed_logger_spi_link_trans_cb(struct spi_transaction *trans __attribute__((unused)))
84 {
86 }
87 
88 
enum SPIClockPolarity cpol
clock polarity control
Definition: spi.h:149
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
Definition: spi.h:153
uint16_t output_length
number of data words to write
Definition: spi.h:146
CPHA = 1.
Definition: spi.h:69
SPI transaction structure.
Definition: spi.h:142
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
Definition: spi_arch.c:458
CPOL = 1.
Definition: spi.h:78
enum SPIBitOrder bitorder
MSB/LSB order.
Definition: spi.h:152
struct Imu imu
global IMU state
Definition: imu.c:108
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
Definition: spi.h:144
enum SPISlaveSelect select
slave selection behavior
Definition: spi.h:148
Architecture independent SPI (Serial Peripheral Interface) API.
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
Definition: imu.h:48
enum SPIClockPhase cpha
clock phase control
Definition: spi.h:150
int32_t r
in rad/s with INT32_RATE_FRAC
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:46
Definition: spi.h:84
SPICallback after_cb
NULL or function called after the transaction.
Definition: spi.h:155
int32_t counter
Inertial Measurement Unit interface.
uint16_t input_length
number of data words to read
Definition: spi.h:145
signed long int32_t
Definition: types.h:19
unsigned char uint8_t
Definition: types.h:14
slave is selected before transaction and unselected after
Definition: spi.h:57
enum SPIDataSizeSelect dss
data transfer word size
Definition: spi.h:151
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
Definition: spi.h:147
int32_t p
in rad/s with INT32_RATE_FRAC
Definition: spi.h:119
volatile uint8_t * input_buf
pointer to receive buffer for DMA
Definition: spi.h:143
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:47
int32_t q
in rad/s with INT32_RATE_FRAC