Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
spi.h
Go to the documentation of this file.
1 /*
2  * Paparazzi $Id$
3  *
4  * Copyright (C) 2005-2006 Pascal Brisset, Antoine Drouin
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
29 #ifndef SPI_H
30 #define SPI_H
31 
32 #ifdef USE_SPI
33 
34 #include "std.h"
35 
36 enum SPITransactionStatus {
37  SPITransPending,
38  SPITransRunning,
39  SPITransSuccess,
40  SPITransFailed
41 };
42 
43 struct spi_transaction {
44  volatile uint8_t* mosi_buf;
45  volatile uint8_t* miso_buf;
46  volatile uint8_t* ready;
47  uint8_t length;
48  volatile enum SPITransactionStatus status;
49 };
50 
51 #include "mcu_periph/spi_arch.h"
52 
53 
57 
58 extern volatile bool_t spi_message_received;
59 
60 void spi_init(void);
61 
62 #ifdef SPI_MASTER
63 
64 #define SPI_NONE 0
65 #define SPI_SLAVE0 1
66 #define SPI_SLAVE1 2
67 #define SPI_SLAVE2 3
68 
69 extern volatile uint8_t spi_cur_slave;
70 extern uint8_t spi_nb_ovrn;
71 
72 #define SpiCheckAvailable() (spi_cur_slave == SPI_NONE)
73 #define SpiOverRun() {spi_nb_ovrn++;}
74 
75 #endif /* SPI_MASTER */
76 
77 #endif /* USE_SPI */
78 
79 #endif /* SPI_H */
status
Definition: anemotaxis.c:10
bool_t spi_message_received
Definition: sim_baro.c:8
uint8_t * spi_buffer_output
Definition: spi.c:29
uint8_t * spi_buffer_input
Definition: spi.c:28
void spi_init(void)
Definition: spi_arch.c:3
unsigned char uint8_t
Definition: types.h:14
uint8_t spi_buffer_length
Definition: spi.c:30