Go to the source code of this file.
Defines | |
#define | __MSP430_HAS_USCI_Ax__ |
#define | SPI_CLOCKSOURCE_ACLK UCSSEL__ACLK |
#define | SPI_CLOCKSOURCE_SMCLK UCSSEL__SMCLK |
#define | SPI_MSB_FIRST UCMSB |
#define | SPI_LSB_FIRST 0x00 |
#define | SPI_BUSY UCBUSY |
#define | SPI_NOT_BUSY 0x00 |
#define | SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT 0x00 |
#define | SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT UCCKPH |
#define | SPI_CLOCKPOLARITY_INACTIVITY_HIGH UCCKPL |
#define | SPI_CLOCKPOLARITY_INACTIVITY_LOW 0x00 |
#define | SPI_TRANSMIT_INTERRUPT UCTXIE |
#define | SPI_RECEIVE_INTERRUPT UCRXIE |
Functions | |
unsigned short | SPI_masterInit (unsigned int baseAddress, unsigned char selectClockSource, unsigned long clockSourceFrequency, unsigned long desiredSpiClock, unsigned char msbFirst, unsigned char clockPhase, unsigned char clockPolarity) |
void | SPI_masterChangeClock (unsigned int baseAddress, unsigned long clockSourceFrequency, unsigned long desiredSpiClock) |
unsigned short | SPI_slaveInit (unsigned int baseAddress, unsigned char msbFirst, unsigned char clockPhase, unsigned char clockPolarity) |
void | SPI_changeClockPhasePolarity (unsigned int baseAddress, unsigned char clockPhase, unsigned char clockPolarity) |
void | SPI_transmitData (unsigned int baseAddress, unsigned char transmitData) |
unsigned char | SPI_receiveData (unsigned int baseAddress) |
void | SPI_enableInterrupt (unsigned int baseAddress, unsigned char mask) |
void | SPI_disableInterrupt (unsigned int baseAddress, unsigned char mask) |
unsigned char | SPI_getInterruptStatus (unsigned int baseAddress, unsigned char mask) |
void | SPI_enable (unsigned int baseAddress) |
void | SPI_disable (unsigned int baseAddress) |
unsigned long | SPI_getReceiveBufferAddressForDMA (unsigned int baseAddress) |
unsigned long | SPI_getTransmitBufferAddressForDMA (unsigned int baseAddress) |
unsigned char | SPI_isBusy (unsigned int baseAddress) |
void | SPI_clearInterruptFlag (unsigned int baseAddress, unsigned char mask) |
#define __MSP430_HAS_USCI_Ax__ |
#define SPI_CLOCKSOURCE_ACLK UCSSEL__ACLK |
Referenced by SPI_masterInit().
#define SPI_CLOCKSOURCE_SMCLK UCSSEL__SMCLK |
Referenced by SPI_masterInit().
#define SPI_MSB_FIRST UCMSB |
Referenced by SPI_masterInit(), and SPI_slaveInit().
#define SPI_LSB_FIRST 0x00 |
Referenced by SPI_masterInit(), and SPI_slaveInit().
#define SPI_BUSY UCBUSY |
#define SPI_NOT_BUSY 0x00 |
#define SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT 0x00 |
Referenced by SPI_masterInit(), and SPI_slaveInit().
#define SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT UCCKPH |
Referenced by SPI_masterInit(), and SPI_slaveInit().
#define SPI_CLOCKPOLARITY_INACTIVITY_HIGH UCCKPL |
Referenced by SPI_changeClockPhasePolarity(), SPI_masterInit(), and SPI_slaveInit().
#define SPI_CLOCKPOLARITY_INACTIVITY_LOW 0x00 |
Referenced by SPI_changeClockPhasePolarity(), SPI_masterInit(), and SPI_slaveInit().
#define SPI_TRANSMIT_INTERRUPT UCTXIE |
Referenced by SPI_clearInterruptFlag(), SPI_disableInterrupt(), SPI_enableInterrupt(), and SPI_getInterruptStatus().
#define SPI_RECEIVE_INTERRUPT UCRXIE |
Referenced by SPI_clearInterruptFlag(), SPI_disableInterrupt(), SPI_enableInterrupt(), and SPI_getInterruptStatus().
unsigned short SPI_masterInit | ( | unsigned int | baseAddress, |
unsigned char | selectClockSource, | ||
unsigned long | clockSourceFrequency, | ||
unsigned long | desiredSpiClock, | ||
unsigned char | msbFirst, | ||
unsigned char | clockPhase, | ||
unsigned char | clockPolarity | ||
) |
Initializes the SPI Master block.
baseAddress | is the base address of the I2C Master module. |
selectClockSource | selects Clock source. Valid values are SPI_CLOCKSOURCE_ACLK SPI_CLOCKSOURCE_SMCLK |
clockSourceFrequency | is the frequency of the slected clock source |
desiredSpiClock | is the desired clock rate for SPI communication |
msbFirst | controls the direction of the receive and transmit shift register. Valid values are SPI_MSB_FIRST SPI_LSB_FIRST [Default Value] |
clockPhase | is clock phase select. Valid values are SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default Value] SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT |
clockPolarity_InactivityHIGH | is clock polarity select. Valid values are SPI_CLOCKPOLARITY_INACTIVITY_HIGH SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default Value] 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 SPI_enable() |
Modified bits are UCCKPH, UCCKPL, UC7BIT, UCMSB bits of UCBxCTL0 register and UCSSELx, UCSWRST bits of UCBxCTL1 register
References ASSERT, HWREGB, SPI_CLOCKPOLARITY_INACTIVITY_HIGH, SPI_CLOCKPOLARITY_INACTIVITY_LOW, SPI_CLOCKSOURCE_ACLK, SPI_CLOCKSOURCE_SMCLK, SPI_LSB_FIRST, SPI_MSB_FIRST, SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT, SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT, and STATUS_SUCCESS.
void SPI_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.
baseAddress | is the base address of the I2C Master module. |
clockSourceFrequency | is the frequency of the slected clock source |
desiredSpiClock | is the desired clock rate for SPI communication |
References HWREGB.
unsigned short SPI_slaveInit | ( | unsigned int | baseAddress, |
unsigned char | msbFirst, | ||
unsigned char | clockPhase, | ||
unsigned char | clockPolarity | ||
) |
Initializes the SPI Slave block.
baseAddress | is the base address of the SPI Slave module. |
msbFirst | controls the direction of the receive and transmit shift register. Valid values are SPI_MSB_FIRST SPI_LSB_FIRST [Default Value] |
clockPhase | is clock phase select. Valid values are SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default Value] SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT |
clockPolarity_InactivityHIGH | is clock polarity select. Valid values are SPI_CLOCKPOLARITY_INACTIVITY_HIGH SPI_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 SPI_enable() |
Modified bits are UCMSB, UC7BIT, UCMST, UCCKPL, UCCKPH, UCMODE_3 bits of UCAxCTL0 and UCSWRST bits of UCAxCTL1
References ASSERT, HWREGB, SPI_CLOCKPOLARITY_INACTIVITY_HIGH, SPI_CLOCKPOLARITY_INACTIVITY_LOW, SPI_LSB_FIRST, SPI_MSB_FIRST, SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT, SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT, and STATUS_SUCCESS.
void SPI_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.
baseAddress | is the base address of the I2C Master module. |
clockPhase | is clock phase select. Valid values are SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default Value] SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT |
clockPolarity_InactivityHIGH | is clock polarity select. Valid values are SPI_CLOCKPOLARITY_INACTIVITY_HIGH SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default Value] |
References ASSERT, HWREGB, SPI_CLOCKPOLARITY_INACTIVITY_HIGH, and SPI_CLOCKPOLARITY_INACTIVITY_LOW.
void SPI_transmitData | ( | unsigned int | baseAddress, |
unsigned char | transmitData | ||
) |
Transmits a byte from the SPI Module.
baseAddress | is the base address of the SPI module. |
transmitData | data to be transmitted from the SPI module |
This function will place the supplied data into SPI trasmit data register to start transmission
References HWREGB.
unsigned char SPI_receiveData | ( | unsigned int | baseAddress | ) |
Receives a byte that has been sent to the SPI Module.
baseAddress | is the base address of the SPI module. |
This function reads a byte of data from the SPI receive data Register.
References HWREGB.
void SPI_enableInterrupt | ( | unsigned int | baseAddress, |
unsigned char | mask | ||
) |
Enables individual SPI interrupt sources.
baseAddress | is the base address of the SPI module. |
mask | is 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:
Modified registers are UCAxIFG and UCAxIE
References ASSERT, HWREGB, SPI_RECEIVE_INTERRUPT, and SPI_TRANSMIT_INTERRUPT.
void SPI_disableInterrupt | ( | unsigned int | baseAddress, |
unsigned char | mask | ||
) |
Disables individual SPI interrupt sources.
baseAddress | is the base address of the SPI module. |
mask | is 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:
Modified register is UCAxIE
References ASSERT, HWREGB, SPI_RECEIVE_INTERRUPT, and SPI_TRANSMIT_INTERRUPT.
unsigned char SPI_getInterruptStatus | ( | unsigned int | baseAddress, |
unsigned char | mask | ||
) |
Gets the current SPI interrupt status.
baseAddress | is the base address of the SPI module. |
mask | is 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.
Modified registers are UCAxIFG.
References ASSERT, HWREGB, SPI_RECEIVE_INTERRUPT, and SPI_TRANSMIT_INTERRUPT.
void SPI_enable | ( | unsigned int | baseAddress | ) |
Enables the SPI block.
baseAddress | is the base address of the USCI SPI module. |
This will enable operation of the SPI block. Modified bits are UCSWRST bit of UCAxCTL1 register.
References HWREGB.
void SPI_disable | ( | unsigned int | baseAddress | ) |
Disables the SPI block.
baseAddress | is the base address of the USCI SPI module. |
This will disable operation of the SPI block.
Modified bits are UCSWRST bit of UCAxCTL1 register.
References HWREGB.
unsigned long SPI_getReceiveBufferAddressForDMA | ( | unsigned int | baseAddress | ) |
Returns the address of the RX Buffer of the SPI for the DMA module.
baseAddress | is 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.
unsigned long SPI_getTransmitBufferAddressForDMA | ( | unsigned int | baseAddress | ) |
Returns the address of the TX Buffer of the SPI for the DMA module.
baseAddress | is 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.
unsigned char SPI_isBusy | ( | unsigned int | baseAddress | ) |
Indicates whether or not the SPI bus is busy.
baseAddress | is 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
References HWREGB.
void SPI_clearInterruptFlag | ( | unsigned int | baseAddress, |
unsigned char | mask | ||
) |
Clears the selected SPI interrupt status flag.
baseAddress | is the base address of the SPI module. |
mask | is the masked interrupt flag to be cleared. |
The mask parameter is the logical OR of any of the following:
Modified registers are UCAxIFG.
References ASSERT, HWREGB, SPI_RECEIVE_INTERRUPT, and SPI_TRANSMIT_INTERRUPT.