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
spi.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2012 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 
29 #include "std.h"
30 #include "mcu_periph/spi.h"
31 
32 #if SPI_MASTER
33 
34 #if USE_SPI0
36 
37 void spi0_init(void)
38 {
39  spi_init(&spi0);
41 }
42 #endif // USE_SPI0
43 
44 
45 #if USE_SPI1
47 
48 void spi1_init(void)
49 {
50  spi_init(&spi1);
52 }
53 #endif // USE_SPI1
54 
55 
56 #if USE_SPI2
58 
59 void spi2_init(void)
60 {
61  spi_init(&spi2);
63 }
64 #endif // USE_SPI2
65 
66 
67 #if USE_SPI3
68 struct spi_periph spi3;
69 
70 void spi3_init(void)
71 {
72  spi_init(&spi3);
73  spi3_arch_init();
74 }
75 #endif // USE_SPI3
76 
77 
78 void spi_init(struct spi_periph *p)
79 {
80  p->trans_insert_idx = 0;
81  p->trans_extract_idx = 0;
82  p->status = SPIIdle;
83  p->mode = SPIMaster;
84  p->suspend = false;
85 }
86 
87 #endif /* SPI_MASTER */
88 
89 
90 #if SPI_SLAVE
91 
92 #if USE_SPI0_SLAVE
93 struct spi_periph spi0;
94 
95 void spi0_slave_init(void)
96 {
98  spi0_slave_arch_init();
99 }
100 #endif // USE_SPI0_SLAVE
101 
102 
103 #if USE_SPI1_SLAVE
104 struct spi_periph spi1;
105 
106 void spi1_slave_init(void)
107 {
109  spi1_slave_arch_init();
110 }
111 #endif // USE_SPI1_SLAVE
112 
113 
114 #if USE_SPI2_SLAVE
115 struct spi_periph spi2;
116 
117 void spi2_slave_init(void)
118 {
120  spi2_slave_arch_init();
121 }
122 #endif // USE_SPI2_SLAVE
123 
124 
125 #if USE_SPI3_SLAVE
126 struct spi_periph spi3;
127 
128 void spi3_slave_init(void)
129 {
130  spi_slave_init(&spi3);
131  spi3_slave_arch_init();
132 }
133 #endif // USE_SPI3_SLAVE
134 
135 
136 extern void spi_slave_init(struct spi_periph *p)
137 {
138  p->trans_insert_idx = 0;
139  p->trans_extract_idx = 0;
140  p->status = SPIIdle;
141  p->mode = SPISlave;
142  p->suspend = false;
143 }
144 
145 #endif /* SPI_SLAVE */
146 
struct spi_periph spi2
receive transferred over DMA
Definition: spi.c:57
void spi1_arch_init(void)
Architecture dependent SPI1 initialization.
Definition: spi_arch.c:352
volatile uint8_t suspend
control for stop/resume of the fifo
Definition: spi.h:181
void spi_init(struct spi_periph *p)
Initialize a spi peripheral.
Definition: spi.c:78
Architecture independent SPI (Serial Peripheral Interface) API.
SPI peripheral structure.
Definition: spi.h:168
void spi_slave_init(struct spi_periph *p)
Initialize a spi peripheral in slave mode.
Definition: spi.c:136
struct spi_periph spi0
Definition: spi.c:35
void spi2_arch_init(void)
Architecture dependent SPI2 initialization.
Definition: spi_arch.c:391
enum SPIStatus status
internal state of the peripheral
Definition: spi.h:174
void spi1_init(void)
Definition: spi.c:48
Definition: spi.h:101
void spi2_init(void)
Definition: spi.c:59
Definition: spi.h:48
enum SPIMode mode
Definition: spi.h:179
uint8_t trans_extract_idx
Definition: spi.h:172
static float p[2][2]
Definition: spi.h:47
void spi0_arch_init(void)
Architecture dependent SPI0 initialization.
Definition: spi_arch.c:136
struct spi_periph spi1
receive transferred over DMA
Definition: spi.c:46
void spi0_init(void)
Definition: spi.c:37
uint8_t trans_insert_idx
Definition: spi.h:171