Paparazzi UAS  v5.15_devel-230-gc96ce27
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 #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 
89 void spi_init(struct spi_periph *p)
90 {
91  p->trans_insert_idx = 0;
92  p->trans_extract_idx = 0;
93  p->status = SPIIdle;
94  p->mode = SPIMaster;
95  p->suspend = false;
96 }
97 
98 #endif /* SPI_MASTER */
99 
100 
101 #if SPI_SLAVE
102 
103 #if USE_SPI0_SLAVE
104 struct spi_periph spi0;
105 
106 void spi0_slave_init(void)
107 {
109  spi0_slave_arch_init();
110 }
111 #endif // USE_SPI0_SLAVE
112 
113 
114 #if USE_SPI1_SLAVE
115 struct spi_periph spi1;
116 
117 void spi1_slave_init(void)
118 {
120  spi1_slave_arch_init();
121 }
122 #endif // USE_SPI1_SLAVE
123 
124 
125 #if USE_SPI2_SLAVE
126 struct spi_periph spi2;
127 
128 void spi2_slave_init(void)
129 {
131  spi2_slave_arch_init();
132 }
133 #endif // USE_SPI2_SLAVE
134 
135 
136 #if USE_SPI3_SLAVE
137 struct spi_periph spi3;
138 
139 void spi3_slave_init(void)
140 {
141  spi_slave_init(&spi3);
142  spi3_slave_arch_init();
143 }
144 #endif // USE_SPI3_SLAVE
145 
146 
147 extern void spi_slave_init(struct spi_periph *p)
148 {
149  p->trans_insert_idx = 0;
150  p->trans_extract_idx = 0;
151  p->status = SPIIdle;
152  p->mode = SPISlave;
153  p->suspend = false;
154 }
155 
156 #endif /* SPI_SLAVE */
157 
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:366
volatile uint8_t suspend
control for stop/resume of the fifo
Definition: spi.h:187
void spi_init(struct spi_periph *p)
Initialize a spi peripheral.
Definition: spi.c:89
Architecture independent SPI (Serial Peripheral Interface) API.
SPI peripheral structure.
Definition: spi.h:174
void spi_slave_init(struct spi_periph *p)
Initialize a spi peripheral in slave mode.
Definition: spi.c:147
struct spi_periph spi0
Definition: spi.c:35
void spi2_arch_init(void)
Architecture dependent SPI2 initialization.
Definition: spi_arch.c:405
enum SPIStatus status
internal state of the peripheral
Definition: spi.h:180
void spi1_init(void)
Definition: spi.c:48
Definition: spi.h:107
void spi2_init(void)
Definition: spi.c:59
Definition: spi.h:54
enum SPIMode mode
Definition: spi.h:185
uint8_t trans_extract_idx
Definition: spi.h:178
static float p[2][2]
Definition: spi.h:53
void spi0_arch_init(void)
Architecture dependent SPI0 initialization.
Definition: spi_arch.c:137
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:177