RTEMS  5.0.0
Functions
spi.c File Reference
#include "chip.h"
#include <stdint.h>

Functions

void SPI_Enable (Spi *spi)
 Enables a SPI peripheral. More...
 
void SPI_Disable (Spi *spi)
 Disables a SPI peripheral. More...
 
void SPI_EnableIt (Spi *spi, uint32_t dwSources)
 Enables one or more interrupt sources of a SPI peripheral. More...
 
void SPI_DisableIt (Spi *spi, uint32_t dwSources)
 Disables one or more interrupt sources of a SPI peripheral. More...
 
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). More...
 
void SPI_ChipSelect (Spi *spi, uint8_t cS)
 Configures SPI chip select. More...
 
void SPI_SetMode (Spi *spi, uint32_t dwConfiguration)
 Configures SPI Mode Register. More...
 
void SPI_ReleaseCS (Spi *spi)
 Configures SPI to release last used CS line. More...
 
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). More...
 
void SPI_ConfigureCSMode (Spi *spi, uint32_t dwNpcs, uint32_t bReleaseOnLast)
 Configures a chip select active mode of a SPI peripheral. More...
 
uint32_t SPI_GetStatus (Spi *spi)
 Get the current status register of the given SPI peripheral. More...
 
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. More...
 
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. More...
 
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. More...
 
uint32_t SPI_IsFinished (Spi *spi)
 Check if SPI transfer finish. More...
 

Detailed Description

Implementation of Serial Peripheral Interface (SPI) controller.

Function Documentation

◆ SPI_ChipSelect()

void SPI_ChipSelect ( Spi spi,
uint8_t  cS 
)

Configures SPI chip select.

Parameters
spiPointer to an SPI instance.
cSChip select of NPSCx.

◆ SPI_Configure()

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
spiPointer to an SPI instance.
idPeripheral ID of the SPI.
configurationValue of the SPI configuration register.

◆ SPI_ConfigureCSMode()

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

Configures a chip select active mode of a SPI peripheral.

Parameters
spiPointer to an SPI instance.
dwNpcsChip select to configure (0, 1, 2 or 3).
bReleaseOnLastCS controlled by last transfer. SPI_ReleaseCS() is used to release CS.

◆ SPI_ConfigureNPCS()

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
spiPointer to an SPI instance.
npcsChip select to configure (0, 1, 2 or 3).
configurationDesired chip select configuration.

◆ SPI_Disable()

void SPI_Disable ( Spi spi)

Disables a SPI peripheral.

Parameters
spiPointer to an SPI instance.

◆ SPI_DisableIt()

void SPI_DisableIt ( Spi spi,
uint32_t  dwSources 
)

Disables one or more interrupt sources of a SPI peripheral.

Parameters
spiPointer to an SPI instance.
sourcesBitwise OR of selected interrupt sources.

◆ SPI_Enable()

void SPI_Enable ( Spi spi)

Enables a SPI peripheral.

Parameters
spiPointer to an SPI instance.

◆ SPI_EnableIt()

void SPI_EnableIt ( Spi spi,
uint32_t  dwSources 
)

Enables one or more interrupt sources of a SPI peripheral.

Parameters
spiPointer to an SPI instance.
sourcesBitwise OR of selected interrupt sources.

◆ SPI_GetStatus()

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
spiPointer to a Spi instance.
Returns
SPI status register.

◆ SPI_IsFinished()

uint32_t SPI_IsFinished ( Spi spi)

Check if SPI transfer finish.

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

◆ SPI_Read()

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
spiPointer to an Spi instance.
Returns
read data.

◆ SPI_ReleaseCS()

void SPI_ReleaseCS ( Spi spi)

Configures SPI to release last used CS line.

Parameters
spiPointer to an SPI instance.

◆ SPI_SetMode()

void SPI_SetMode ( Spi spi,
uint32_t  dwConfiguration 
)

Configures SPI Mode Register.

Parameters
spiPointer to an SPI instance.
configurationValue of the SPI mode register.

◆ SPI_Write()

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
spiPointer to an SPI instance.
npcsChip select of the component to address (0, 1, 2 or 3).
dataWord of data to send.

◆ SPI_WriteLast()

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
spiPointer to an SPI instance.
npcsChip select of the component to address (0, 1, 2 or 3).
dataWord of data to send.