Defines | Functions
espi.h File Reference

Go to the source code of this file.

Defines

#define __MSP430_HAS_EUSCI_Ax__
#define eSPI_CLOCKSOURCE_ACLK   UCSSEL__ACLK
#define eSPI_CLOCKSOURCE_SMCLK   UCSSEL__SMCLK
#define eSPI_MSB_FIRST   UCMSB
#define eSPI_LSB_FIRST   0x00
#define eSPI_BUSY   UCBUSY
#define eSPI_NOT_BUSY   0x00
#define eSPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT   0x00
#define eSPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT   UCCKPH
#define eSPI_3PIN   UCMODE_0
#define eSPI_4PIN_UCxSTE_ACTIVE_HIGH   UCMODE_1
#define eSPI_4PIN_UCxSTE_ACTIVE_LOW   UCMODE_2
#define eSPI_CLOCKPOLARITY_INACTIVITY_HIGH   UCCKPL
#define eSPI_CLOCKPOLARITY_INACTIVITY_LOW   0x00
#define eSPI_TRANSMIT_INTERRUPT   UCTXIE
#define eSPI_RECEIVE_INTERRUPT   UCRXIE
#define eSPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE   UCSTEM
#define eSPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS   0x00

Functions

unsigned short eSPI_masterInit (unsigned int baseAddress, unsigned char selectClockSource, unsigned long clockSourceFrequency, unsigned long desiredSpiClock, unsigned int msbFirst, unsigned int clockPhase, unsigned int clockPolarity, unsigned char spiMode)
void eSPI_select4PinFunctionality (unsigned int baseAddress, unsigned char select4PinFunctionality)
void eSPI_masterChangeClock (unsigned int baseAddress, unsigned long clockSourceFrequency, unsigned long desiredSpiClock)
unsigned short eSPI_slaveInit (unsigned int baseAddress, unsigned int msbFirst, unsigned int clockPhase, unsigned int clockPolarity)
void eSPI_changeClockPhasePolarity (unsigned int baseAddress, unsigned char clockPhase, unsigned char clockPolarity)
void eSPI_transmitData (unsigned int baseAddress, unsigned char transmitData)
unsigned char eSPI_receiveData (unsigned int baseAddress)
void eSPI_enableInterrupt (unsigned int baseAddress, unsigned char mask)
void eSPI_disableInterrupt (unsigned int baseAddress, unsigned char mask)
unsigned char eSPI_getInterruptStatus (unsigned int baseAddress, unsigned char mask)
void eSPI_enable (unsigned int baseAddress)
void eSPI_disable (unsigned int baseAddress)
unsigned long eSPI_getReceiveBufferAddressForDMA (unsigned int baseAddress)
unsigned long eSPI_getTransmitBufferAddressForDMA (unsigned int baseAddress)
unsigned char eSPI_isBusy (unsigned int baseAddress)
void eSPI_clearInterruptFlag (unsigned int baseAddress, unsigned char mask)

Define Documentation

#define __MSP430_HAS_EUSCI_Ax__
#define eSPI_CLOCKSOURCE_ACLK   UCSSEL__ACLK

Referenced by eSPI_masterInit().

#define eSPI_CLOCKSOURCE_SMCLK   UCSSEL__SMCLK

Referenced by eSPI_masterInit().

#define eSPI_MSB_FIRST   UCMSB

Referenced by eSPI_masterInit(), and eSPI_slaveInit().

#define eSPI_LSB_FIRST   0x00

Referenced by eSPI_masterInit(), and eSPI_slaveInit().

#define eSPI_BUSY   UCBUSY
#define eSPI_NOT_BUSY   0x00
#define eSPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT   0x00

Referenced by eSPI_masterInit(), and eSPI_slaveInit().

#define eSPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT   UCCKPH

Referenced by eSPI_masterInit(), and eSPI_slaveInit().

#define eSPI_3PIN   UCMODE_0

Referenced by eSPI_masterInit().

#define eSPI_4PIN_UCxSTE_ACTIVE_HIGH   UCMODE_1

Referenced by eSPI_masterInit().

#define eSPI_4PIN_UCxSTE_ACTIVE_LOW   UCMODE_2

Referenced by eSPI_masterInit().

#define eSPI_CLOCKPOLARITY_INACTIVITY_HIGH   UCCKPL
#define eSPI_CLOCKPOLARITY_INACTIVITY_LOW   0x00
#define eSPI_TRANSMIT_INTERRUPT   UCTXIE
#define eSPI_RECEIVE_INTERRUPT   UCRXIE
#define eSPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE   UCSTEM
#define eSPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS   0x00

Function Documentation

unsigned short eSPI_masterInit ( unsigned int  baseAddress,
unsigned char  selectClockSource,
unsigned long  clockSourceFrequency,
unsigned long  desiredSpiClock,
unsigned int  msbFirst,
unsigned int  clockPhase,
unsigned int  clockPolarity,
unsigned char  spiMode 
)

Initializes the SPI Master block.

Parameters:
baseAddressis the base address of the I2C Master module.
selectClockSourceselects Clock source. Valid values are eSPI_CLOCKSOURCE_ACLK eSPI_CLOCKSOURCE_SMCLK
clockSourceFrequencyis the frequency of the slected clock source
desiredSpiClockis the desired clock rate for SPI communication
msbFirstcontrols the direction of the receive and transmit shift register. Valid values are eSPI_MSB_FIRST eSPI_LSB_FIRST [Default Value]
clockPhaseis clock phase select. Valid values are eSPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default Value] eSPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
clockPolarity_InactivityHIGHis clock polarity select. Valid values are eSPI_CLOCKPOLARITY_INACTIVITY_HIGH eSPI_CLOCKPOLARITY_INACTIVITY_LOW [Default Value]
spiModeis SPI mode select. Valid values are eSPI_3PIN [Default Value] eSPI_4PIN_UCxSTE_ACTIVE_HIGH eSPI_4PIN_UCxSTE_ACTIVE_LOW Upon successful initialization of the SPI master block, this function will have set the bus speed for the master, but the SPI Master block still remains disabled and must be enabled with eSPI_enable()

Modified bits are UCCKPH, UCCKPL, UC7BIT, UCMSB,UCSSELx, UCSWRST bits of UCAxCTLW0 register

Returns:
STATUS_SUCCESS

References ASSERT, eSPI_3PIN, eSPI_4PIN_UCxSTE_ACTIVE_HIGH, eSPI_4PIN_UCxSTE_ACTIVE_LOW, eSPI_CLOCKPOLARITY_INACTIVITY_HIGH, eSPI_CLOCKPOLARITY_INACTIVITY_LOW, eSPI_CLOCKSOURCE_ACLK, eSPI_CLOCKSOURCE_SMCLK, eSPI_LSB_FIRST, eSPI_MSB_FIRST, eSPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT, eSPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT, HWREG, and STATUS_SUCCESS.

void eSPI_select4PinFunctionality ( unsigned int  baseAddress,
unsigned char  select4PinFunctionality 
)

Selects 4Pin Functionality

Parameters:
baseAddressis the base address of the I2C Master module.
select4PinFunctionalityselects Clock source. Valid values are eSPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS eSPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE This function should be invoked only in 4-wire mode. Invoking this function has no effect in 3-wire mode.

Modified bits are UCSTEM bit of UCAxCTLW0 register

Returns:
STATUS_SUCCESS

References ASSERT, eSPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE, eSPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS, and HWREG.

void eSPI_masterChangeClock ( unsigned int  baseAddress,
unsigned long  clockSourceFrequency,
unsigned long  desiredSpiClock 
)

Initializes the SPI Master clock.At the end of this function call, SPI module is left enabled.

Parameters:
baseAddressis the base address of the I2C Master module.
clockSourceFrequencyis the frequency of the slected clock source
desiredSpiClockis the desired clock rate for SPI communication

Modified bits are UCSWRST bit of UCAxCTLW0 register and UCAxBRW register

Returns:
None

References HWREG.

unsigned short eSPI_slaveInit ( unsigned int  baseAddress,
unsigned int  msbFirst,
unsigned int  clockPhase,
unsigned int  clockPolarity 
)

Initializes the SPI Slave block.

Parameters:
baseAddressis the base address of the SPI Slave module.
msbFirstcontrols the direction of the receive and transmit shift register. Valid values are eSPI_MSB_FIRST eSPI_LSB_FIRST [Default Value]
clockPhaseis clock phase select. Valid values are eSPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default Value] eSPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
clockPolarity_InactivityHIGHis clock polarity select. Valid values are eSPI_CLOCKPOLARITY_INACTIVITY_HIGH eSPI_CLOCKPOLARITY_INACTIVITY_LOW [Default Value] Upon successful initialization of the SPI slave block, this function will have initailized the slave block, but the SPI Slave block still remains disabled and must be enabled with eSPI_enable()

Modified bits are UCMSB, UC7BIT, UCMST, UCCKPL, UCCKPH, UCMODE_3, UCSWRST bits of UCAxCTLW0

Returns:
STATUS_SUCCESS

References ASSERT, eSPI_CLOCKPOLARITY_INACTIVITY_HIGH, eSPI_CLOCKPOLARITY_INACTIVITY_LOW, eSPI_LSB_FIRST, eSPI_MSB_FIRST, eSPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT, eSPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT, HWREG, and STATUS_SUCCESS.

void eSPI_changeClockPhasePolarity ( unsigned int  baseAddress,
unsigned char  clockPhase,
unsigned char  clockPolarity 
)

Changes the SPI colock phase and polarity.At the end of this function call, SPI module is left enabled.

Parameters:
baseAddressis the base address of the I2C Master module.
clockPhaseis clock phase select. Valid values are eSPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default Value] eSPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
clockPolarity_InactivityHIGHis clock polarity select. Valid values are eSPI_CLOCKPOLARITY_INACTIVITY_HIGH eSPI_CLOCKPOLARITY_INACTIVITY_LOW [Default Value]

Modified bits are UCSWRST, UCCKPH, UCCKPL, UCSWRST bits of UCAxCTLW0

Returns:
None

References ASSERT, eSPI_CLOCKPOLARITY_INACTIVITY_HIGH, eSPI_CLOCKPOLARITY_INACTIVITY_LOW, and HWREG.

void eSPI_transmitData ( unsigned int  baseAddress,
unsigned char  transmitData 
)

Transmits a byte from the SPI Module.

Parameters:
baseAddressis the base address of the SPI module.
transmitDatadata to be transmitted from the SPI module

This function will place the supplied data into SPI trasmit data register to start transmission

Modified register is UCAxTXBUF

Returns:
None.

References HWREG.

unsigned char eSPI_receiveData ( unsigned int  baseAddress)

Receives a byte that has been sent to the SPI Module.

Parameters:
baseAddressis the base address of the SPI module.

This function reads a byte of data from the SPI receive data Register.

Returns:
Returns the byte received from by the SPI module, cast as an unsigned char.

References HWREG.

void eSPI_enableInterrupt ( unsigned int  baseAddress,
unsigned char  mask 
)

Enables individual SPI interrupt sources.

Parameters:
baseAddressis the base address of the SPI module.
maskis the bit mask of the interrupt sources to be enabled.

Enables the indicated SPI interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The mask parameter is the logical OR of any of the following:

  • eSPI_RECEIVE_INTERRUPT -Receive interrupt
  • eSPI_TRANSMIT_INTERRUPT - Transmit interrupt

Modified registers are UCAxIFG and UCAxIE

Returns:
None.

References ASSERT, eSPI_RECEIVE_INTERRUPT, eSPI_TRANSMIT_INTERRUPT, and HWREG.

void eSPI_disableInterrupt ( unsigned int  baseAddress,
unsigned char  mask 
)

Disables individual SPI interrupt sources.

Parameters:
baseAddressis the base address of the SPI module.
maskis the bit mask of the interrupt sources to be disabled.

Disables the indicated SPI interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The mask parameter is the logical OR of any of the following:

  • eSPI_RECEIVE_INTERRUPT -Receive interrupt
  • eSPI_TRANSMIT_INTERRUPT - Transmit interrupt

Modified register is UCAxIE

Returns:
None.

References ASSERT, eSPI_RECEIVE_INTERRUPT, eSPI_TRANSMIT_INTERRUPT, and HWREG.

unsigned char eSPI_getInterruptStatus ( unsigned int  baseAddress,
unsigned char  mask 
)

Gets the current SPI interrupt status.

Parameters:
baseAddressis the base address of the SPI module.
maskis the masked interrupt flag status to be returned.

This returns the interrupt status for the SPI module based on which flag is passed. mask parameter can be either any of the following selection.

  • eSPI_RECEIVE_INTERRUPT -Receive interrupt
  • eSPI_TRANSMIT_INTERRUPT - Transmit interrupt

Modified registers are UCAxIFG.

Returns:
The current interrupt status as the mask of the set flags

References ASSERT, eSPI_RECEIVE_INTERRUPT, eSPI_TRANSMIT_INTERRUPT, and HWREG.

void eSPI_enable ( unsigned int  baseAddress)

Enables the SPI block.

Parameters:
baseAddressis the base address of the USCI SPI module.

This will enable operation of the SPI block. Modified bits are UCSWRST bit of UCAxCTLW0 register.

Returns:
None.

References HWREG.

void eSPI_disable ( unsigned int  baseAddress)

Disables the SPI block.

Parameters:
baseAddressis the base address of the USCI SPI module.

This will disable operation of the SPI block.

Modified bits are UCSWRST bit of UCAxCTLW0 register.

Returns:
None.

References HWREG.

unsigned long eSPI_getReceiveBufferAddressForDMA ( unsigned int  baseAddress)

Returns the address of the RX Buffer of the SPI for the DMA module.

Parameters:
baseAddressis the base address of the SPI module.

Returns the address of the SPI RX Buffer. This can be used in conjunction with the DMA to store the received data directly to memory.

Returns:
NONE
unsigned long eSPI_getTransmitBufferAddressForDMA ( unsigned int  baseAddress)

Returns the address of the TX Buffer of the SPI for the DMA module.

Parameters:
baseAddressis the base address of the SPI module.

Returns the address of the SPI TX Buffer. This can be used in conjunction with the DMA to obtain transmitted data directly from memory.

Returns:
NONE
unsigned char eSPI_isBusy ( unsigned int  baseAddress)

Indicates whether or not the SPI bus is busy.

Parameters:
baseAddressis the base address of the SPI module.

This function returns an indication of whether or not the SPI bus is busy.This function checks the status of the bus via UCBBUSY bit

Returns:
eSPI_BUSY if the SPI module trasmitting or receiving is busy; otherwise, returns eSPI_NOT_BUSY.

References HWREG.

void eSPI_clearInterruptFlag ( unsigned int  baseAddress,
unsigned char  mask 
)

Clears the selected SPI interrupt status flag.

Parameters:
baseAddressis the base address of the SPI module.
maskis the masked interrupt flag to be cleared.

The mask parameter is the logical OR of any of the following:

  • eSPI_RECEIVE_INTERRUPT -Receive interrupt
  • eSPI_TRANSMIT_INTERRUPT - Transmit interrupt Modified registers are UCAxIFG.
Returns:
None

References ASSERT, eSPI_RECEIVE_INTERRUPT, eSPI_TRANSMIT_INTERRUPT, and HWREG.


Copyright 2012, Texas Instruments Incorporated