SAMV71 Xplained Ultra Software Package 1.5

spi.c File Reference

#include "chip.h"
#include <stdint.h>

Go to the source code of this file.

Functions

void SPI_Enable (Spi *spi)
 Enables a SPI peripheral.
void SPI_Disable (Spi *spi)
 Disables a SPI peripheral.
void SPI_EnableIt (Spi *spi, uint32_t dwSources)
 Enables one or more interrupt sources of a SPI peripheral.
void SPI_DisableIt (Spi *spi, uint32_t dwSources)
 Disables one or more interrupt sources of a SPI peripheral.
void SPI_Configure (Spi *spi, uint32_t dwId, uint32_t dwConfiguration)
 Configures a SPI peripheral as specified. The configuration can be computed using several macros (see SPI Configuration Macros).
void SPI_ChipSelect (Spi *spi, uint8_t cS)
 Configures SPI chip select.
void SPI_SetMode (Spi *spi, uint32_t dwConfiguration)
 Configures SPI Mode Register.
void SPI_ReleaseCS (Spi *spi)
 Configures SPI to release last used CS line.
void SPI_ConfigureNPCS (Spi *spi, uint32_t dwNpcs, uint32_t dwConfiguration)
 Configures a chip select of a SPI peripheral. The chip select configuration is computed using several macros (see SPI Configuration Macros).
void SPI_ConfigureCSMode (Spi *spi, uint32_t dwNpcs, uint32_t bReleaseOnLast)
 Configures a chip select active mode of a SPI peripheral.
uint32_t SPI_GetStatus (Spi *spi)
 Get the current status register of the given SPI peripheral.
uint32_t SPI_Read (Spi *spi)
 Reads and returns the last word of data received by a SPI peripheral. This method must be called after a successful SPI_Write call.
void SPI_Write (Spi *spi, uint32_t dwNpcs, uint16_t wData)
 Sends data through a SPI peripheral. If the SPI is configured to use a fixed peripheral select, the npcs value is meaningless. Otherwise, it identifies the component which shall be addressed.
void SPI_WriteLast (Spi *spi, uint32_t dwNpcs, uint16_t wData)
 Sends last data through a SPI peripheral. If the SPI is configured to use a fixed peripheral select, the npcs value is meaningless. Otherwise, it identifies the component which shall be addressed.
uint32_t SPI_IsFinished (Spi *spi)
 Check if SPI transfer finish.

Detailed Description

Implementation of Serial Peripheral Interface (SPI) controller.

Definition in file spi.c.


Function Documentation

void SPI_ChipSelect ( Spi spi,
uint8_t  cS 
)

Configures SPI chip select.

Parameters:
spi Pointer to an SPI instance.
cS Chip select of NPSCx.

Definition at line 146 of file spi.c.

void SPI_Configure ( Spi spi,
uint32_t  dwId,
uint32_t  dwConfiguration 
)

Configures a SPI peripheral as specified. The configuration can be computed using several macros (see SPI Configuration Macros).

Parameters:
spi Pointer to an SPI instance.
id Peripheral ID of the SPI.
configuration Value of the SPI configuration register.

Definition at line 128 of file spi.c.

Here is the call graph for this function:

void SPI_ConfigureCSMode ( Spi spi,
uint32_t  dwNpcs,
uint32_t  bReleaseOnLast 
)

Configures a chip select active mode of a SPI peripheral.

Parameters:
spi Pointer to an SPI instance.
dwNpcs Chip select to configure (0, 1, 2 or 3).
bReleaseOnLast CS controlled by last transfer. SPI_ReleaseCS() is used to release CS.

Definition at line 197 of file spi.c.

void SPI_ConfigureNPCS ( Spi spi,
uint32_t  dwNpcs,
uint32_t  dwConfiguration 
)

Configures a chip select of a SPI peripheral. The chip select configuration is computed using several macros (see SPI Configuration Macros).

Parameters:
spi Pointer to an SPI instance.
npcs Chip select to configure (0, 1, 2 or 3).
configuration Desired chip select configuration.

Definition at line 184 of file spi.c.

void SPI_Disable ( Spi spi  ) 

Disables a SPI peripheral.

Parameters:
spi Pointer to an SPI instance.

Definition at line 93 of file spi.c.

void SPI_DisableIt ( Spi spi,
uint32_t  dwSources 
)

Disables one or more interrupt sources of a SPI peripheral.

Parameters:
spi Pointer to an SPI instance.
sources Bitwise OR of selected interrupt sources.

Definition at line 115 of file spi.c.

void SPI_Enable ( Spi spi  ) 

Enables a SPI peripheral.

Parameters:
spi Pointer to an SPI instance.

Definition at line 83 of file spi.c.

void SPI_EnableIt ( Spi spi,
uint32_t  dwSources 
)

Enables one or more interrupt sources of a SPI peripheral.

Parameters:
spi Pointer to an SPI instance.
sources Bitwise OR of selected interrupt sources.

Definition at line 104 of file spi.c.

uint32_t SPI_GetStatus ( Spi spi  ) 

Get the current status register of the given SPI peripheral.

Note:
This resets the internal value of the status register, so further read may yield different values.
Parameters:
spi Pointer to a Spi instance.
Returns:
SPI status register.

Definition at line 212 of file spi.c.

uint32_t SPI_IsFinished ( Spi spi  ) 

Check if SPI transfer finish.

Parameters:
spi Pointer to an SPI instance.
Returns:
Returns 1 if there is no pending write operation on the SPI; otherwise returns 0.

Definition at line 278 of file spi.c.

uint32_t SPI_Read ( Spi spi  ) 

Reads and returns the last word of data received by a SPI peripheral. This method must be called after a successful SPI_Write call.

Parameters:
spi Pointer to an Spi instance.
Returns:
read data.

Definition at line 225 of file spi.c.

void SPI_ReleaseCS ( Spi spi  ) 

Configures SPI to release last used CS line.

Parameters:
spi Pointer to an SPI instance.

Definition at line 169 of file spi.c.

void SPI_SetMode ( Spi spi,
uint32_t  dwConfiguration 
)

Configures SPI Mode Register.

Parameters:
spi Pointer to an SPI instance.
configuration Value of the SPI mode register.

Definition at line 158 of file spi.c.

void SPI_Write ( Spi spi,
uint32_t  dwNpcs,
uint16_t  wData 
)

Sends data through a SPI peripheral. If the SPI is configured to use a fixed peripheral select, the npcs value is meaningless. Otherwise, it identifies the component which shall be addressed.

Parameters:
spi Pointer to an SPI instance.
npcs Chip select of the component to address (0, 1, 2 or 3).
data Word of data to send.

Definition at line 241 of file spi.c.

void SPI_WriteLast ( Spi spi,
uint32_t  dwNpcs,
uint16_t  wData 
)

Sends last data through a SPI peripheral. If the SPI is configured to use a fixed peripheral select, the npcs value is meaningless. Otherwise, it identifies the component which shall be addressed.

Parameters:
spi Pointer to an SPI instance.
npcs Chip select of the component to address (0, 1, 2 or 3).
data Word of data to send.

Definition at line 260 of file spi.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines