Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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
35 struct spi_periph spi0;
36 
37 void spi0_init(void)
38 {
39  spi_init(&spi0);
41 }
42 #endif // USE_SPI0
43 
44 
45 #if USE_SPI1
46 struct spi_periph spi1;
47 
48 void spi1_init(void)
49 {
50  spi_init(&spi1);
52 }
53 #endif // USE_SPI1
54 
55 
56 #if USE_SPI2
57 struct spi_periph 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 #if USE_SPI4
79 struct spi_periph spi4;
80 
81 void spi4_init(void)
82 {
83  spi_init(&spi4);
84  spi4_arch_init();
85 }
86 #endif // USE_SPI4
87 
88 #if USE_SPI6
89 struct spi_periph spi6;
90 
91 void spi6_init(void)
92 {
93  spi_init(&spi6);
94  spi6_arch_init();
95 }
96 #endif // USE_SPI6
97 
98 void spi_init(struct spi_periph *p)
99 {
100  p->trans_insert_idx = 0;
101  p->trans_extract_idx = 0;
102  p->status = SPIIdle;
103  p->mode = SPIMaster;
104  p->suspend = false;
105 }
106 
107 #endif /* SPI_MASTER */
108 
109 
110 #if SPI_SLAVE
111 
112 #if USE_SPI0_SLAVE
113 struct spi_periph spi0;
114 
115 void spi0_slave_init(void)
116 {
118  spi0_slave_arch_init();
119 }
120 #endif // USE_SPI0_SLAVE
121 
122 
123 #if USE_SPI1_SLAVE
124 struct spi_periph spi1;
125 
126 void spi1_slave_init(void)
127 {
129  spi1_slave_arch_init();
130 }
131 #endif // USE_SPI1_SLAVE
132 
133 
134 #if USE_SPI2_SLAVE
135 struct spi_periph spi2;
136 
137 void spi2_slave_init(void)
138 {
140  spi2_slave_arch_init();
141 }
142 #endif // USE_SPI2_SLAVE
143 
144 
145 #if USE_SPI3_SLAVE
146 struct spi_periph spi3;
147 
148 void spi3_slave_init(void)
149 {
150  spi_slave_init(&spi3);
151  spi3_slave_arch_init();
152 }
153 #endif // USE_SPI3_SLAVE
154 
155 
156 extern void spi_slave_init(struct spi_periph *p)
157 {
158  p->trans_insert_idx = 0;
159  p->trans_extract_idx = 0;
160  p->status = SPIIdle;
161  p->mode = SPISlave;
162  p->suspend = false;
163 }
164 
165 #endif /* SPI_SLAVE */
166 
void spi2_init(void)
Definition: spi.c:59
void spi0_init(void)
Definition: spi.c:37
void spi_init(struct spi_periph *p)
Initialize a spi peripheral.
Definition: spi.c:98
void spi_slave_init(struct spi_periph *p)
Initialize a spi peripheral in slave mode.
Definition: spi.c:156
void spi1_init(void)
Definition: spi.c:48
void spi1_arch_init(void)
Architecture dependent SPI1 initialization.
Definition: spi_arch.c:423
void spi0_arch_init(void)
Architecture dependent SPI0 initialization.
Definition: spi_arch.c:137
struct spi_periph spi2
receive transferred over DMA
Definition: spi.c:57
void spi2_arch_init(void)
Architecture dependent SPI2 initialization.
Definition: spi_arch.c:442
struct spi_periph spi0
Definition: spi.c:35
struct spi_periph spi1
receive transferred over DMA
Definition: spi.c:46
@ SPIIdle
Definition: spi.h:107
@ SPIMaster
Definition: spi.h:53
@ SPISlave
Definition: spi.h:54
SPI peripheral structure.
Definition: spi.h:174
static float p[2][2]
Architecture independent SPI (Serial Peripheral Interface) API.