RTEMS
5.0.0
|
#include "chip.h"
Go to the source code of this file.
Macros | |
#define | SPI_PCS(npcs) SPI_MR_PCS((~(1 << npcs) & 0xF)) |
#define | SPI_SCBR(baudrate, masterClock) SPI_CSR_SCBR((uint32_t)(masterClock / baudrate)) |
#define | SPI_DLYBS(delay, masterClock) SPI_CSR_DLYBS((uint32_t) (((masterClock / 1000000) * delay) / 1000)+1) |
#define | SPI_DLYBCT(delay, masterClock) SPI_CSR_DLYBCT ((uint32_t) (((masterClock / 1000000) * delay) / 32000)+1) |
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_SetMode (Spi *spi, uint32_t dwConfiguration) |
Configures SPI Mode Register. More... | |
void | SPI_ChipSelect (Spi *spi, uint8_t cS) |
Configures SPI chip select. 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_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_GetStatus (Spi *spi) |
Get the current status register of the given SPI peripheral. More... | |
uint32_t | SPI_IsFinished (Spi *pSpi) |
Check if SPI transfer finish. More... | |
Interface for Serial Peripheral Interface (SPI) controller.
#define SPI_DLYBCT | ( | delay, | |
masterClock | |||
) | SPI_CSR_DLYBCT ((uint32_t) (((masterClock / 1000000) * delay) / 32000)+1) |
Calculates the value of the CSR DLYBCT field given the desired delay (in ns)
#define SPI_DLYBS | ( | delay, | |
masterClock | |||
) | SPI_CSR_DLYBS((uint32_t) (((masterClock / 1000000) * delay) / 1000)+1) |
Calculates the value of the CSR DLYBS field given the desired delay (in ns)
#define SPI_PCS | ( | npcs | ) | SPI_MR_PCS((~(1 << npcs) & 0xF)) |
#define SPI_SCBR | ( | baudrate, | |
masterClock | |||
) | SPI_CSR_SCBR((uint32_t)(masterClock / baudrate)) |
Calculates the value of the CSR SCBR field given the baudrate and MCK.
void SPI_ChipSelect | ( | Spi * | spi, |
uint8_t | cS | ||
) |
Configures SPI chip select.
spi | Pointer to an SPI instance. |
cS | Chip select of NPSCx. |
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).
spi | Pointer to an SPI instance. |
id | Peripheral ID of the SPI. |
configuration | Value of the SPI configuration register. |
void SPI_ConfigureCSMode | ( | Spi * | spi, |
uint32_t | dwNpcs, | ||
uint32_t | bReleaseOnLast | ||
) |
Configures a chip select active mode of a SPI peripheral.
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. |
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).
spi | Pointer to an SPI instance. |
npcs | Chip select to configure (0, 1, 2 or 3). |
configuration | Desired chip select configuration. |
void SPI_Disable | ( | Spi * | spi | ) |
Disables a SPI peripheral.
spi | Pointer to an SPI instance. |
void SPI_DisableIt | ( | Spi * | spi, |
uint32_t | dwSources | ||
) |
Disables one or more interrupt sources of a SPI peripheral.
spi | Pointer to an SPI instance. |
sources | Bitwise OR of selected interrupt sources. |
void SPI_Enable | ( | Spi * | spi | ) |
Enables a SPI peripheral.
spi | Pointer to an SPI instance. |
void SPI_EnableIt | ( | Spi * | spi, |
uint32_t | dwSources | ||
) |
Enables one or more interrupt sources of a SPI peripheral.
spi | Pointer to an SPI instance. |
sources | Bitwise OR of selected interrupt sources. |
uint32_t SPI_GetStatus | ( | Spi * | spi | ) |
Get the current status register of the given SPI peripheral.
spi | Pointer to a Spi instance. |
uint32_t SPI_IsFinished | ( | Spi * | spi | ) |
Check if SPI transfer finish.
spi | Pointer to an SPI instance. |
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.
spi | Pointer to an Spi instance. |
void SPI_ReleaseCS | ( | Spi * | spi | ) |
Configures SPI to release last used CS line.
spi | Pointer to an SPI instance. |
void SPI_SetMode | ( | Spi * | spi, |
uint32_t | dwConfiguration | ||
) |
Configures SPI Mode Register.
spi | Pointer to an SPI instance. |
configuration | Value of the SPI mode register. |
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.
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. |
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.
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. |