spi.h
Go to the documentation of this file.
00001 #ifndef __MSP430WARE_SPI_H__
00002 #define __MSP430WARE_SPI_H__
00003 
00004 //*****************************************************************************
00005 //
00006 //The following are the defines to include the required modules for this
00007 //peripheral in msp430xgeneric.h file
00008 //
00009 //*****************************************************************************
00010 #define __MSP430_HAS_USCI_Ax__
00011 
00012 //*****************************************************************************
00013 //
00014 //The following are values that can be passed to the SPI_masterInit() API
00015 //as the selectClockSource parameter.
00016 //
00017 //*****************************************************************************
00018 #define SPI_CLOCKSOURCE_ACLK    UCSSEL__ACLK
00019 #define SPI_CLOCKSOURCE_SMCLK   UCSSEL__SMCLK
00020 
00021 //*****************************************************************************
00022 //
00023 //The following are values that can be passed to the SPI_masterInit() ,
00024 //SPI_slaveInit() API as the msbFirst parameter.
00025 //
00026 //*****************************************************************************
00027 #define SPI_MSB_FIRST    UCMSB
00028 #define SPI_LSB_FIRST    0x00
00029 
00030 //*****************************************************************************
00031 //
00032 //The following are values that can be returned by the SPI_isBusy() API
00033 //
00034 //*****************************************************************************
00035 #define SPI_BUSY        UCBUSY
00036 #define SPI_NOT_BUSY    0x00
00037 
00038 //*****************************************************************************
00039 //
00040 //The following are values that can be passed to the SPI_masterInit() ,
00041 //SPI_slaveInit() API as the clockPhase parameter.
00042 //
00043 //*****************************************************************************
00044 #define SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT    0x00
00045 #define SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT    UCCKPH
00046 
00047 //*****************************************************************************
00048 //
00049 //The following are values that can be passed to the SPI_masterInit() ,
00050 //SPI_slaveInit() API as the clockPolarity parameter.
00051 //
00052 //*****************************************************************************
00053 #define SPI_CLOCKPOLARITY_INACTIVITY_HIGH    UCCKPL
00054 #define SPI_CLOCKPOLARITY_INACTIVITY_LOW     0x00
00055 
00056 //*****************************************************************************
00057 //
00058 //The following are values that can be passed to the SPI_enableInterrupt() ,
00059 //SPI_disableInterrupt(), SPI_getInterruptStatus(),  API as the mask parameter.
00060 //
00061 //*****************************************************************************
00062 #define SPI_TRANSMIT_INTERRUPT    UCTXIE
00063 #define SPI_RECEIVE_INTERRUPT     UCRXIE
00064 
00065 //*****************************************************************************
00066 //
00067 //Prototypes for the APIs.
00068 //
00069 //*****************************************************************************
00070 extern unsigned short SPI_masterInit (unsigned int baseAddress,
00071     unsigned char selectClockSource,
00072     unsigned long clockSourceFrequency,
00073     unsigned long desiredSpiClock,
00074     unsigned char msbFirst,
00075     unsigned char clockPhase,
00076     unsigned char clockPolarity
00077     );
00078 extern void SPI_masterChangeClock (unsigned int baseAddress,
00079     unsigned long clockSourceFrequency,
00080     unsigned long desiredSpiClock
00081     );
00082 
00083 extern unsigned short SPI_slaveInit (unsigned int baseAddress,
00084     unsigned char msbFirst,
00085     unsigned char clockPhase,
00086     unsigned char clockPolarity
00087     );
00088 extern void SPI_changeClockPhasePolarity (unsigned int baseAddress,
00089     unsigned char clockPhase,
00090     unsigned char clockPolarity
00091     );
00092 extern void SPI_transmitData ( unsigned int baseAddress,
00093     unsigned char transmitData
00094     );
00095 
00096 extern unsigned char SPI_receiveData (unsigned int baseAddress);
00097 extern void SPI_enableInterrupt (unsigned int baseAddress,
00098     unsigned char mask
00099     );
00100 extern void SPI_disableInterrupt (unsigned int baseAddress,
00101     unsigned char mask
00102     );
00103 extern unsigned char SPI_getInterruptStatus (unsigned int baseAddress,
00104     unsigned char mask
00105     );
00106 extern void SPI_enable (unsigned int baseAddress);
00107 extern void SPI_disable (unsigned int baseAddress);
00108 extern unsigned long SPI_getReceiveBufferAddressForDMA
00109     (unsigned int baseAddress);
00110 extern unsigned long SPI_getTransmitBufferAddressForDMA
00111     (unsigned int baseAddress);
00112 extern unsigned char SPI_isBusy (unsigned int baseAddress);
00113 extern void SPI_clearInterruptFlag (unsigned int baseAddress,
00114     unsigned char mask
00115     );
00116 #endif
00117 

Copyright 2012, Texas Instruments Incorporated