spi.h File Reference

SPI bus master implementation. More...


Defines

#define SPI_CPOL_LOW   0x00
 Hidle clock level is low.
#define SPI_CPOL_HI   0x01
 Hidle clock level is high.
#define SPI_FIRST_EDGE   0x00
 Data sampled of first clock edge.
#define SPI_SECOND_EDGE   0x02
 Data sampled on second clock edge.
#define SPI_LSB_FIRST   0x00
 Bit order is LSB.
#define SPI_MSB_FIRST   0x04
 Bit order is MSB.

Functions

int SPI_InitBus (unsigned int Mode, unsigned int BitPerWord)
 Set the initial state of SPI bus data lines.
uint32_t SPI_DataExchange (uint32_t Data)
 SPI bus data exchange.


Detailed Description

SPI bus master implementation.

Author:
Alessandro Accattini
Date:
28 Gen 2020 SPI bus is implemented on top of I/O module: first 3 data lines (D0, D1, and D2) are used to simulate respectively: MOSI, MISO and CLK lines. All other data lines are available through I/O module for other purposes; it is very important to not overwrite first 3 data lines settings while SPI bus is in use.

Define Documentation

#define SPI_CPOL_LOW   0x00

Hidle clock level is low.

/brief SPI operation mode


Function Documentation

uint32_t SPI_DataExchange ( uint32_t  Data  ) 

SPI bus data exchange.

Parameters:
Data data sent over the SPI bus.
Returns:
data received over the SPI bus.
This function is used to exchange data over the SPI bus. SPI bus is bidirectional: while a word is transmitted from master to slave, another word is transmitted back from slave to master.

int SPI_InitBus ( unsigned int  Mode,
unsigned int  BitPerWord 
)

Set the initial state of SPI bus data lines.

Parameters:
Mode bus mode.
BitPerWord SPI bus word size.
Returns:
0 on success.
Sets the direction and initial state of data lines used to implement the SPI bus; after this call first 3 I/O data lines are under control of this module and its status should not be over written calling I/O module functions.


Generated on Tue Apr 14 22:08:57 2020 for libdrivers by  doxygen 1.5.6