libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
spi_common_v1.h
Go to the documentation of this file.
1/** @addtogroup spi_defines
2
3@author @htmlonly &copy; @endhtmlonly 2011 Fergus Noble <fergusnoble@gmail.com>
4
5*/
6/*
7 * This file is part of the libopencm3 project.
8 *
9 * Copyright (C) 2011 Fergus Noble <fergusnoble@gmail.com>
10 *
11 * This library is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this library. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA SPI.H
26The order of header inclusion is important. spi.h includes the device
27specific memorymap.h header before including this header file.*/
28
29/** @cond */
30#ifdef LIBOPENCM3_SPI_H
31/** @endcond */
32#pragma once
33
34/**@{*/
35
37
38/* DFF: Data frame format */
39/****************************************************************************/
40/** @defgroup spi_dff SPI data frame format
41@ingroup spi_defines
42
43@{*/
44
45#define SPI_CR1_DFF_8BIT (0 << 11)
46#define SPI_CR1_DFF_16BIT (1 << 11)
47
48/**@}*/
49
50#define SPI_CR1_DFF (1 << 11)
51
52/* --- Function prototypes ------------------------------------------------- */
53
55
56int spi_init_master(uint32_t spi, uint32_t br, uint32_t cpol, uint32_t cpha,
57 uint32_t dff, uint32_t lsbfirst);
58void spi_set_dff_8bit(uint32_t spi);
59void spi_set_dff_16bit(uint32_t spi);
60
62
63/** @cond */
64#else
65#warning "spi_common_v1.h should not be included explicitly, only via spi.h"
66#endif
67/** @endcond */
68/**@}*/
69
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void spi_set_dff_16bit(uint32_t spi)
SPI Set Data Frame Format to 16 bits.
void spi_set_dff_8bit(uint32_t spi)
SPI Set Data Frame Format to 8 bits.
int spi_init_master(uint32_t spi, uint32_t br, uint32_t cpol, uint32_t cpha, uint32_t dff, uint32_t lsbfirst)
Configure the SPI as Master.
Definition: spi_common_v1.c:83