at91_spi.c File Reference

Go to the source code of this file.

Functions

int At91Spi0Init (void)
 Initialize the first serial peripheral interface on the AT91 MCU.
int At91Spi0InitChipSelects (u_int mask)
 Initialize specified SPI0 chip selects on the AT91 MCU.
int At91Spi0Enable (void)
 Initialize the second serial peripheral interface on the AT91 MCU.
int At91SpiInit (u_int base)
 Initialize serial peripheral interface on the AT91 MCU.
int At91SpiEnable (u_int base)
int At91SpiDisable (u_int base)
int At91SpiReset (u_int base)
 Reset serial peripheral interface on the AT91 MCU.
int At91SpiInitChipSelects (u_int base, u_int mask)
 Initialize specified SPI chip selects on the AT91 MCU.
int At91SpiSetRate (u_int base, u_int cs, u_long rate)
 Configure the SPI rate.
u_long At91SpiGetModeFlags (u_int base, u_int cs)
int At91SpiSetModeFlags (u_int base, u_int cs, u_long mode)
 Configure the SPI operation mode.
u_int At91SpiGetBits (u_int base, u_int cs)
int At91SpiSetBits (u_int base, u_int cs, u_int bits)
u_int At91SpiGetSckDelay (u_int base, u_int cs)
int At91SpiSetSckDelay (u_int base, u_int cs, u_int dly)
u_int At91SpiGetTxDelay (u_int base, u_int cs)
int At91SpiSetTxDelay (u_int base, u_int cs, u_int dly)
u_int At91SpiGetCsDelay (u_int base)
int At91SpiSetCsDelay (u_int base, u_int dly)
int At91SpiTransfer2 (u_int base, u_int cs, CONST void *txbuf, void *rxbuf, int xlen, CONST void *txnbuf, void *rxnbuf, int xnlen)
 Transfer two SPI buffers.


Function Documentation

int At91Spi0Init ( void   ) 

Initialize the first serial peripheral interface on the AT91 MCU.

Definition at line 78 of file at91_spi.c.

References _BV, At91Spi0Enable(), At91SpiReset(), NutIrqEnable(), NutRegisterIrqHandler(), outr, PMC_PCER, sig_SPI0, SPI0_BASE, and SPI0_ID.

int At91Spi0InitChipSelects ( u_int  mask  ) 

Initialize specified SPI0 chip selects on the AT91 MCU.

Parameters:
mask Chip selects to use. Set bit 0 for NPCS0, bit 1 for NPCS1 and so on.
Returns:
0 on success or -1 if any of the specified chip selects is not available.

Definition at line 101 of file at91_spi.c.

References _BV, outr, PIO_PDR_OFF, SPI0_CS0_PIN, SPI0_CS0_PIO_BASE, SPI0_CS0_PSR_OFF, SPI0_CS1_PIN, SPI0_CS1_PIO_BASE, SPI0_CS1_PSR_OFF, SPI0_CS2_PIN, SPI0_CS2_PIO_BASE, SPI0_CS2_PSR_OFF, SPI0_CS3_PIN, SPI0_CS3_PIO_BASE, and SPI0_CS3_PSR_OFF.

int At91Spi0Enable ( void   ) 

Initialize the second serial peripheral interface on the AT91 MCU.

Definition at line 137 of file at91_spi.c.

References outr, PIO_PDR_OFF, SPI0_PINS, SPI0_PIO_BASE, and SPI0_PSR_OFF.

int At91SpiInit ( u_int  base  ) 

Initialize serial peripheral interface on the AT91 MCU.

Parameters:
base Interface base address, either SPI_BASE, SPI0_BASE or SPI1_BASE.
Returns:
0 on success or -1 if SPI is not available.

Definition at line 239 of file at91_spi.c.

References At91Spi0Init(), SPI0_BASE, and SPI1_BASE.

int At91SpiEnable ( u_int  base  ) 

Definition at line 257 of file at91_spi.c.

References outr, SPI_CR_OFF, and SPI_SPIEN.

Referenced by At91SpiReset().

int At91SpiDisable ( u_int  base  ) 

Definition at line 264 of file at91_spi.c.

References outr, SPI_CR_OFF, and SPI_SPIDIS.

Referenced by At91SpiReset().

int At91SpiReset ( u_int  base  ) 

Reset serial peripheral interface on the AT91 MCU.

Parameters:
base Interface base address, either SPI_BASE, SPI0_BASE or SPI1_BASE.
Returns:
0 on success or -1 if SPI is not available.

Definition at line 279 of file at91_spi.c.

References At91SpiDisable(), At91SpiEnable(), outr, SPI_CR_OFF, SPI_DLYBCS_LSB, SPI_MODFDIS, SPI_MR_OFF, SPI_MSTR, SPI_PCS, and SPI_SWRST.

int At91SpiInitChipSelects ( u_int  base,
u_int  mask 
)

Initialize specified SPI chip selects on the AT91 MCU.

Parameters:
base Interface base address, either SPI_BASE, SPI0_BASE or SPI1_BASE.
mask Chip selects to use. Set bit 0 for NPCS0, bit 1 for NPCS1 and so on.
Returns:
0 on success or -1 if any of the specified chip selects is not available.

Definition at line 309 of file at91_spi.c.

References At91Spi0InitChipSelects(), SPI0_BASE, and SPI1_BASE.

int At91SpiSetRate ( u_int  base,
u_int  cs,
u_long  rate 
)

Configure the SPI rate.

Parameters:
base SPI register base.
cs Chip select line.
rate Baudrate. The maximum is MCK/1 and the minimum is MCK/255. If the specified rate is above the maximum or below the minimum, the maximum or minimum value resp. will be set.

Definition at line 335 of file at91_spi.c.

References inr, outr, SPI_CSR0_OFF, SPI_CSR1_OFF, SPI_CSR2_OFF, SPI_CSR3_OFF, SPI_SCBR, and SPI_SCBR_LSB.

u_long At91SpiGetModeFlags ( u_int  base,
u_int  cs 
)

Definition at line 373 of file at91_spi.c.

References inr, SPI_CPOL, SPI_CSR0_OFF, SPI_LLB, SPI_MODFDIS, SPI_MR_OFF, SPI_MSTR, SPI_NCPHA, SPI_PCSDEC, SPIMF_CAPRISE, SPIMF_LOOPBACK, SPIMF_MASTER, SPIMF_MFDETECT, and SPIMF_SCKIAHI.

int At91SpiSetModeFlags ( u_int  base,
u_int  cs,
u_long  mode 
)

Configure the SPI operation mode.

Parameters:
base SPI register base.
cs Chip select line.
mode Any of the following
  • SPIMF_MASTER Master mode.
  • SPIMF_PCSDEC Decoded chip selects.
  • SPIMF_MFDETECT Mode fault detection.
  • SPIMF_LOOPBACK Loopback mode.
  • SPIMF_SCKIAHI Clock is high when inactive.
  • SPIMF_CAPRISE Data cpatured on rising edge.
  • SPIMF_KEEPCS Chip select remains active after transfer.

Definition at line 418 of file at91_spi.c.

References At91SpiGetModeFlags(), inr, outr, SPI_CPOL, SPI_CSAAT, SPI_CSR0_OFF, SPI_LLB, SPI_MODFDIS, SPI_MR_OFF, SPI_MSTR, SPI_NCPHA, SPI_PCSDEC, SPIMF_CAPRISE, SPIMF_KEEPCS, SPIMF_LOOPBACK, SPIMF_MASTER, SPIMF_MFDETECT, SPIMF_PCSDEC, and SPIMF_SCKIAHI.

u_int At91SpiGetBits ( u_int  base,
u_int  cs 
)

Definition at line 460 of file at91_spi.c.

References inr, SPI_BITS, SPI_BITS_10, SPI_BITS_11, SPI_BITS_12, SPI_BITS_13, SPI_BITS_14, SPI_BITS_15, SPI_BITS_16, SPI_BITS_9, and SPI_CSR0_OFF.

int At91SpiSetBits ( u_int  base,
u_int  cs,
u_int  bits 
)

Definition at line 496 of file at91_spi.c.

References At91SpiGetBits(), inr, outr, SPI_BITS, SPI_BITS_10, SPI_BITS_11, SPI_BITS_12, SPI_BITS_13, SPI_BITS_14, SPI_BITS_15, SPI_BITS_16, SPI_BITS_8, SPI_BITS_9, and SPI_CSR0_OFF.

u_int At91SpiGetSckDelay ( u_int  base,
u_int  cs 
)

Definition at line 538 of file at91_spi.c.

References inr, SPI_CSR0_OFF, SPI_DLYBS, and SPI_DLYBS_LSB.

int At91SpiSetSckDelay ( u_int  base,
u_int  cs,
u_int  dly 
)

Definition at line 543 of file at91_spi.c.

References At91SpiGetSckDelay(), inr, outr, SPI_CSR0_OFF, SPI_DLYBS, and SPI_DLYBS_LSB.

u_int At91SpiGetTxDelay ( u_int  base,
u_int  cs 
)

Definition at line 555 of file at91_spi.c.

References inr, SPI_CSR0_OFF, SPI_DLYBCT, and SPI_DLYBCT_LSB.

int At91SpiSetTxDelay ( u_int  base,
u_int  cs,
u_int  dly 
)

Definition at line 560 of file at91_spi.c.

References At91SpiGetTxDelay(), inr, outr, SPI_CSR0_OFF, SPI_DLYBCT, and SPI_DLYBCT_LSB.

u_int At91SpiGetCsDelay ( u_int  base  ) 

Definition at line 572 of file at91_spi.c.

References inr, SPI_DLYBCS, SPI_DLYBCS_LSB, and SPI_MR_OFF.

int At91SpiSetCsDelay ( u_int  base,
u_int  dly 
)

Definition at line 577 of file at91_spi.c.

References At91SpiGetCsDelay(), inr, outr, SPI_DLYBCS, SPI_DLYBCS_LSB, and SPI_MR_OFF.

int At91SpiTransfer2 ( u_int  base,
u_int  cs,
CONST void *  txbuf,
void *  rxbuf,
int  xlen,
CONST void *  txnbuf,
void *  rxnbuf,
int  xnlen 
)

Transfer two SPI buffers.

Parameters:
base SPI port base address.
cs SPI device chip select.
txbuf First transmit buffer.
rxbuf First receive buffer.
xlen Length of first transfer.
txnbuf Second transmit buffer.
rxnbuf Second receive buffer.
xnlen Length of second transfer.

Definition at line 599 of file at91_spi.c.

References inr, NutEventWait(), outr, PDC_RXTDIS, PDC_RXTEN, PDC_TXTDIS, PDC_TXTEN, PERIPH_PTCR_OFF, PERIPH_RCR_OFF, PERIPH_RNCR_OFF, PERIPH_RNPR_OFF, PERIPH_RPR_OFF, PERIPH_TCR_OFF, PERIPH_TNCR_OFF, PERIPH_TNPR_OFF, PERIPH_TPR_OFF, printf, SPI0_BASE, SPI1_BASE, SPI_IDR_OFF, SPI_IER_OFF, SPI_MR_OFF, SPI_PCS, SPI_PCS_0, SPI_PCS_1, SPI_PCS_2, SPI_PCS_3, SPI_RXBUFF, and SPI_SR_OFF.


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/