Paparazzi UAS v7.0_unstable
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
37void spi0_init(void)
38{
39 spi_init(&spi0);
41}
42#endif // USE_SPI0
43
44
45#if USE_SPI1
47
48void spi1_init(void)
49{
50 spi_init(&spi1);
52}
53#endif // USE_SPI1
54
55
56#if USE_SPI2
58
59void spi2_init(void)
60{
61 spi_init(&spi2);
63}
64#endif // USE_SPI2
65
66
67#if USE_SPI3
68struct spi_periph spi3;
69
70void spi3_init(void)
71{
72 spi_init(&spi3);
74}
75#endif // USE_SPI3
76
77
78#if USE_SPI4
79struct spi_periph spi4;
80
81void spi4_init(void)
82{
83 spi_init(&spi4);
85}
86#endif // USE_SPI4
87
88#if USE_SPI6
89struct spi_periph spi6;
90
91void spi6_init(void)
92{
93 spi_init(&spi6);
95}
96#endif // USE_SPI6
97
98void 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
113struct spi_periph spi0;
114
115void spi0_slave_init(void)
116{
119}
120#endif // USE_SPI0_SLAVE
121
122
123#if USE_SPI1_SLAVE
124struct spi_periph spi1;
125
126void spi1_slave_init(void)
127{
130}
131#endif // USE_SPI1_SLAVE
132
133
134#if USE_SPI2_SLAVE
135struct spi_periph spi2;
136
137void spi2_slave_init(void)
138{
141}
142#endif // USE_SPI2_SLAVE
143
144
145#if USE_SPI3_SLAVE
146struct spi_periph spi3;
147
148void spi3_slave_init(void)
149{
152}
153#endif // USE_SPI3_SLAVE
154
155
156extern 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_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]
uint16_t foo
Definition main_demo5.c:58
Architecture independent SPI (Serial Peripheral Interface) API.