STM32F10x library
Data Structures | Functions | Variables
spi.c File Reference

SPI routines. More...

#include <inttypes.h>
#include "stm32f10x.h"

Functions

void spi_init (uint8_t devnum, uint16_t brps)
 Initialize SPI interface. More...
 
void spi_putc (uint8_t devnum, uint8_t *d)
 Send and receive byte. More...
 
void spi_puts (uint8_t devnum, char *s)
 Send and receive string. More...
 
void spi_putsn (uint8_t devnum, char *s, uint16_t n)
 Send and receive string of length n. More...
 

Variables

struct SPI_DevDef SPI1_PinDef = {2, SPI1, RCC_APB2Periph_SPI1, GPIOA, RCC_APB2Periph_GPIOA, GPIO_Pin_4, GPIO_Pin_5, GPIO_Pin_6, GPIO_Pin_7}
 
struct SPI_DevDef SPI2_PinDef = {1, SPI2, RCC_APB1Periph_SPI2, GPIOB, RCC_APB2Periph_GPIOB, GPIO_Pin_12, GPIO_Pin_13, GPIO_Pin_14, GPIO_Pin_15}
 

Detailed Description

SPI routines.

Author
Matej Kogovsek (matej.nosp@m.@ham.nosp@m.radio.nosp@m..si)
Note
This file is part of mat-stm32f1-lib

Function Documentation

void spi_init ( uint8_t  devnum,
uint16_t  brps 
)

Initialize SPI interface.

Although SPI can have different clock phase and polarity, I have never ran across anything that uses other than low polarity and 1st edge phase. Therefore these parameters are implied and not variable. As are 8 bit words and MSB first.

Parameters
[in]devnumSPI peripheral number (1..2)
[in]brpsBaudrate prescaler, F_CPU dependent
void spi_putc ( uint8_t  devnum,
uint8_t *  d 
)

Send and receive byte.

Parameters
[in]devnumSPI peripheral number (1..2)
[in,out]dByte to send/receive
void spi_puts ( uint8_t  devnum,
char *  s 
)

Send and receive string.

Parameters
[in]devnumSPI peripheral number (1..2)
[in,out]sZero terminated string to send/receive
void spi_putsn ( uint8_t  devnum,
char *  s,
uint16_t  n 
)

Send and receive string of length n.

Parameters
[in]devnumSPI peripheral number (1..2)
[in,out]sString to send/receive
[in]nNumber of bytes to send/receive

Variable Documentation

struct SPI_DevDef SPI1_PinDef = {2, SPI1, RCC_APB2Periph_SPI1, GPIOA, RCC_APB2Periph_GPIOA, GPIO_Pin_4, GPIO_Pin_5, GPIO_Pin_6, GPIO_Pin_7}

Register and pin defs for SPI1

struct SPI_DevDef SPI2_PinDef = {1, SPI2, RCC_APB1Periph_SPI2, GPIOB, RCC_APB2Periph_GPIOB, GPIO_Pin_12, GPIO_Pin_13, GPIO_Pin_14, GPIO_Pin_15}

Register and pin defs for SPI2