MSP430 DriverLib for MSP430F5xx_6xx Devices  2.91.13.01
usci_b_spi

Functions

bool USCI_B_SPI_initMaster (uint16_t baseAddress, USCI_B_SPI_initMasterParam *param)
 Initializes the SPI Master block. More...
 
void USCI_B_SPI_changeMasterClock (uint16_t baseAddress, USCI_B_SPI_changeMasterClockParam *param)
 Initializes the SPI Master clock.At the end of this function call, SPI module is left enabled. More...
 
bool USCI_B_SPI_initSlave (uint16_t baseAddress, uint8_t msbFirst, uint8_t clockPhase, uint8_t clockPolarity)
 Initializes the SPI Slave block. More...
 
void USCI_B_SPI_changeClockPhasePolarity (uint16_t baseAddress, uint8_t clockPhase, uint8_t clockPolarity)
 Changes the SPI clock phase and polarity.At the end of this function call, SPI module is left enabled. More...
 
void USCI_B_SPI_transmitData (uint16_t baseAddress, uint8_t transmitData)
 Transmits a byte from the SPI Module. More...
 
uint8_t USCI_B_SPI_receiveData (uint16_t baseAddress)
 Receives a byte that has been sent to the SPI Module. More...
 
void USCI_B_SPI_enableInterrupt (uint16_t baseAddress, uint8_t mask)
 Enables individual SPI interrupt sources. More...
 
void USCI_B_SPI_disableInterrupt (uint16_t baseAddress, uint8_t mask)
 Disables individual SPI interrupt sources. More...
 
uint8_t USCI_B_SPI_getInterruptStatus (uint16_t baseAddress, uint8_t mask)
 Gets the current SPI interrupt status. More...
 
void USCI_B_SPI_clearInterrupt (uint16_t baseAddress, uint8_t mask)
 Clears the selected SPI interrupt status flag. More...
 
void USCI_B_SPI_enable (uint16_t baseAddress)
 Enables the SPI block. More...
 
void USCI_B_SPI_disable (uint16_t baseAddress)
 Disables the SPI block. More...
 
uint32_t USCI_B_SPI_getReceiveBufferAddressForDMA (uint16_t baseAddress)
 Returns the address of the RX Buffer of the SPI for the DMA module. More...
 
uint32_t USCI_B_SPI_getTransmitBufferAddressForDMA (uint16_t baseAddress)
 Returns the address of the TX Buffer of the SPI for the DMA module. More...
 
uint8_t USCI_B_SPI_isBusy (uint16_t baseAddress)
 Indicates whether or not the SPI bus is busy. More...
 

Detailed Description

Function Documentation

§ USCI_B_SPI_changeClockPhasePolarity()

void USCI_B_SPI_changeClockPhasePolarity ( uint16_t  baseAddress,
uint8_t  clockPhase,
uint8_t  clockPolarity 
)

Changes the SPI clock 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:
  • USCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default]
  • USCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
clockPolarityValid values are:
  • USCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
  • USCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]

Modified bits are UCCKPL and UCCKPH of UCAxCTL0 register.

Returns
None

§ USCI_B_SPI_changeMasterClock()

void USCI_B_SPI_changeMasterClock ( uint16_t  baseAddress,
USCI_B_SPI_changeMasterClockParam param 
)

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.
paramis the pointer to struct for master clock setting.

Modified bits of UCAxBRW register.

Returns
None

References USCI_B_SPI_changeMasterClockParam::clockSourceFrequency, and USCI_B_SPI_changeMasterClockParam::desiredSpiClock.

§ USCI_B_SPI_clearInterrupt()

void USCI_B_SPI_clearInterrupt ( uint16_t  baseAddress,
uint8_t  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. Valid values are:
  • USCI_B_SPI_TRANSMIT_INTERRUPT
  • USCI_B_SPI_RECEIVE_INTERRUPT

Modified bits of UCBxIFG register.

Returns
None

§ USCI_B_SPI_disable()

void USCI_B_SPI_disable ( uint16_t  baseAddress)

Disables the SPI block.

This will disable operation of the SPI block.

Parameters
baseAddressis the base address of the USCI SPI module.

Modified bits are UCSWRST of UCBxCTL1 register.

Returns
None

§ USCI_B_SPI_disableInterrupt()

void USCI_B_SPI_disableInterrupt ( uint16_t  baseAddress,
uint8_t  mask 
)

Disables individual SPI interrupt sources.

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.

Parameters
baseAddressis the base address of the SPI module.
maskis the bit mask of the interrupt sources to be disabled. Valid values are:
  • USCI_B_SPI_TRANSMIT_INTERRUPT
  • USCI_B_SPI_RECEIVE_INTERRUPT

Modified bits of UCBxIE register.

Returns
None

§ USCI_B_SPI_enable()

void USCI_B_SPI_enable ( uint16_t  baseAddress)

Enables the SPI block.

This will enable operation of the SPI block.

Parameters
baseAddressis the base address of the USCI SPI module.

Modified bits are UCSWRST of UCBxCTL1 register.

Returns
None

§ USCI_B_SPI_enableInterrupt()

void USCI_B_SPI_enableInterrupt ( uint16_t  baseAddress,
uint8_t  mask 
)

Enables individual SPI interrupt sources.

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. Does not clear interrupt flags.

Parameters
baseAddressis the base address of the SPI module.
maskis the bit mask of the interrupt sources to be enabled. Valid values are:
  • USCI_B_SPI_TRANSMIT_INTERRUPT
  • USCI_B_SPI_RECEIVE_INTERRUPT

Modified bits of UCBxIE register.

Returns
None

§ USCI_B_SPI_getInterruptStatus()

uint8_t USCI_B_SPI_getInterruptStatus ( uint16_t  baseAddress,
uint8_t  mask 
)

Gets the current SPI interrupt status.

This returns the interrupt status for the SPI module based on which flag is passed.

Parameters
baseAddressis the base address of the SPI module.
maskis the masked interrupt flag status to be returned. Valid values are:
  • USCI_B_SPI_TRANSMIT_INTERRUPT
  • USCI_B_SPI_RECEIVE_INTERRUPT
Returns
The current interrupt status as the mask of the set flags Return Logical OR of any of the following:
  • USCI_B_SPI_TRANSMIT_INTERRUPT
  • USCI_B_SPI_RECEIVE_INTERRUPT
    indicating the status of the masked interrupts

§ USCI_B_SPI_getReceiveBufferAddressForDMA()

uint32_t USCI_B_SPI_getReceiveBufferAddressForDMA ( uint16_t  baseAddress)

Returns the address of the RX Buffer of the SPI for the DMA 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.

Parameters
baseAddressis the base address of the SPI module.
Returns
The address of the SPI RX buffer

§ USCI_B_SPI_getTransmitBufferAddressForDMA()

uint32_t USCI_B_SPI_getTransmitBufferAddressForDMA ( uint16_t  baseAddress)

Returns the address of the TX Buffer of the SPI for the DMA 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.

Parameters
baseAddressis the base address of the SPI module.
Returns
The address of the SPI TX buffer

§ USCI_B_SPI_initMaster()

bool USCI_B_SPI_initMaster ( uint16_t  baseAddress,
USCI_B_SPI_initMasterParam param 
)

Initializes the SPI Master block.

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 USCI_B_SPI_enable()

Parameters
baseAddressis the base address of the I2C Master module.
paramis the pointer to struct for master initialization.

Modified bits are UCSSELx and UCSWRST of UCBxCTL1 register; bits UCCKPH, UCCKPL, UC7BIT and UCMSB of UCBxCTL0 register.

Returns
STATUS_SUCCESS

References USCI_B_SPI_initMasterParam::clockPhase, USCI_B_SPI_initMasterParam::clockPolarity, USCI_B_SPI_initMasterParam::clockSourceFrequency, USCI_B_SPI_initMasterParam::desiredSpiClock, USCI_B_SPI_initMasterParam::msbFirst, and USCI_B_SPI_initMasterParam::selectClockSource.

§ USCI_B_SPI_initSlave()

bool USCI_B_SPI_initSlave ( uint16_t  baseAddress,
uint8_t  msbFirst,
uint8_t  clockPhase,
uint8_t  clockPolarity 
)

Initializes the SPI Slave block.

Upon successful initialization of the SPI slave block, this function will have initialized the slave block, but the SPI Slave block still remains disabled and must be enabled with USCI_B_SPI_enable()

Parameters
baseAddressis the base address of the SPI Slave module.
msbFirstcontrols the direction of the receive and transmit shift register. Valid values are:
  • USCI_B_SPI_MSB_FIRST
  • USCI_B_SPI_LSB_FIRST [Default]
clockPhaseis clock phase select. Valid values are:
  • USCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default]
  • USCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
clockPolarityValid values are:
  • USCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
  • USCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]

Modified bits are UCSWRST of UCBxCTL1 register; bits UCMSB, UCMST, UC7BIT, UCCKPL, UCCKPH and UCMODE of UCBxCTL0 register.

Returns
STATUS_SUCCESS

§ USCI_B_SPI_isBusy()

uint8_t USCI_B_SPI_isBusy ( uint16_t  baseAddress)

Indicates whether or not the SPI bus is busy.

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

Parameters
baseAddressis the base address of the SPI module.
Returns
USCI_B_SPI_BUSY if the SPI module transmitting or receiving is busy; otherwise, returns USCI_B_SPI_NOT_BUSY. Return one of the following:
  • USCI_B_SPI_BUSY
  • USCI_B_SPI_NOT_BUSY
    indicating if the USCI_B_SPI is busy

§ USCI_B_SPI_receiveData()

uint8_t USCI_B_SPI_receiveData ( uint16_t  baseAddress)

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

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

Parameters
baseAddressis the base address of the SPI module.
Returns
Returns the byte received from by the SPI module, cast as an uint8_t.

§ USCI_B_SPI_transmitData()

void USCI_B_SPI_transmitData ( uint16_t  baseAddress,
uint8_t  transmitData 
)

Transmits a byte from the SPI Module.

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

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

Copyright 2020, Texas Instruments Incorporated