Name

spi_init — initializes SPI controller

Synopsis

#include <spi.h>   
unsigned int spi_init (freq,  
 cpol,  
 cphase,  
 endian); 
unsigned int freq;
bool cpol;
bool cphase;
bool endian;
 

Arguments

freq

frequency in kHz

cpol

clock polarity - idle high or idle low

cphase

clock phase - shift on negative edge or positive edge

endian

MSB first or LSB first

Description

Initializes the SPI controller, with the specified parameters. Should be invoked before an other function in the SPI module is invoked.

Returns the actual frequency set. Clock polarity cpol is specified by one of SPI_CPOL_IDLE_HIGH and SPI_CPOL_IDLE_LOW. Clock phase cphase is specified by one of SPI_CPHASE_TRAIL_EDGE and SPI_CPHASE_LEAD_EDGE. Endianess endian specified one of SPI_ENDIAN_LSB_FIRST and SPI_ENDIAN_MSB_FIRST.