i2c.h
Go to the documentation of this file.
00001 #ifndef __MSP430WARE_I2C_H__
00002 #define __MSP430WARE_I2C_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_Bx__
00011 
00012 //*****************************************************************************
00013 //
00014 //The following are values that can be passed to the I2C_masterInit() API
00015 //as the selectClockSource parameter.
00016 //
00017 //*****************************************************************************
00018 #define I2C_CLOCKSOURCE_ACLK    UCSSEL__ACLK
00019 #define I2C_CLOCKSOURCE_SMCLK   UCSSEL__SMCLK
00020 
00021 //*****************************************************************************
00022 //
00023 //The following are values that can be passed to the I2C_enableInterrupt(),
00024 //I2C_disableInterrupt(), I2C_clearInterrupt(), I2C_getInterruptStatus(), API
00025 //as the mask parameter.
00026 //
00027 //*****************************************************************************
00028 #define I2C_NAK_INTERRUPT                UCNACKIE
00029 #define I2C_ARBITRATIONLOST_INTERRUPT    UCALIE
00030 #define I2C_STOP_INTERRUPT               UCSTPIE
00031 #define I2C_START_INTERRUPT              UCSTTIE
00032 #define I2C_TRANSMIT_INTERRUPT           UCTXIE
00033 #define I2C_RECEIVE_INTERRUPT            UCRXIE
00034 
00035 //*****************************************************************************
00036 //
00037 //The following are values that can be passed to the I2C_masterInit() API
00038 //as the dataRate parameter.
00039 //
00040 //*****************************************************************************
00041 #define I2C_SET_DATA_RATE_400KBPS             400000
00042 #define I2C_SET_DATA_RATE_100KBPS             100000
00043 
00044 //*****************************************************************************
00045 //
00046 //The following are values that is returned by the I2C_isBusy()  and
00047 //I2C_isBusBusy() API
00048 //
00049 //*****************************************************************************
00050 #define I2C_BUS_BUSY     UCBBUSY
00051 #define I2C_BUS_NOT_BUSY 0x00
00052 
00053 //*****************************************************************************
00054 //
00055 //The following are values that can be returned by the I2C_masterIsSTOPSent()
00056 //API
00057 //
00058 //*****************************************************************************
00059 
00060 #define I2C_SENDING_STOP                UCTXSTP
00061 #define I2C_STOP_SEND_COMPLETE  0x00
00062 
00063 //*****************************************************************************
00064 //
00065 //The following are values that can be passed to the I2C_setMode() API
00066 //as the mode parameter.
00067 //
00068 //*****************************************************************************
00069 #define I2C_TRANSMIT_MODE       UCTR
00070 #define I2C_RECEIVE_MODE        0x00
00071 
00072 //*****************************************************************************
00073 //
00074 //Prototypes for the APIs.
00075 //
00076 //*****************************************************************************
00077 extern void I2C_masterInit (unsigned int baseAddress,
00078     unsigned char selectClockSource,
00079     unsigned long i2cClk,
00080     unsigned long dataRate);
00081 extern void I2C_slaveInit (unsigned int baseAddress,
00082     unsigned char slaveAddress
00083     );
00084 extern void I2C_enable (unsigned int baseAddress);
00085 extern void I2C_disable (unsigned int baseAddress);
00086 extern void I2C_setSlaveAddress (unsigned int baseAddress,
00087     unsigned char slaveAddress
00088     );
00089 extern void I2C_setMode (unsigned int baseAddress,
00090     unsigned char mode
00091     );
00092 extern void I2C_slaveDataPut (unsigned int baseAddress,
00093     unsigned char transmitData
00094     );
00095 extern unsigned char I2C_slaveDataGet (unsigned int baseAddress);
00096 extern unsigned char I2C_isBusBusy (unsigned int baseAddress);
00097 extern unsigned char I2C_isBusy (unsigned int baseAddress);
00098 extern void I2C_enableInterrupt (unsigned int baseAddress,
00099     unsigned char mask
00100     );
00101 extern void I2C_disableInterrupt (unsigned int baseAddress,
00102     unsigned char mask
00103     );
00104 extern void I2C_clearInterruptFlag (unsigned int baseAddress,
00105     unsigned char mask
00106     );
00107 extern unsigned char I2C_getInterruptStatus (unsigned int baseAddress,
00108     unsigned char mask
00109     );
00110 extern void I2C_masterSendSingleByte (unsigned int baseAddress,
00111     unsigned char txData
00112     );
00113 extern void I2C_masterMultiByteSendStart (unsigned int baseAddress,
00114     unsigned char txData
00115     );
00116 extern void I2C_masterMultiByteSendNext (unsigned int baseAddress,
00117     unsigned char txData
00118     );
00119 extern void I2C_masterMultiByteSendFinish (unsigned int baseAddress,
00120     unsigned char txData
00121     );
00122 extern void I2C_masterMultiByteSendStop (unsigned int baseAddress);
00123 extern void I2C_masterMultiByteReceiveStart (unsigned int baseAddress);
00124 extern unsigned char I2C_masterMultiByteReceiveNext (unsigned int baseAddress);
00125 extern unsigned char I2C_masterMultiByteReceiveFinish (
00126     unsigned int baseAddress
00127     );
00128 extern void I2C_masterMultiByteReceiveStop (unsigned int baseAddress);
00129 extern void I2C_masterSingleReceiveStart (unsigned int baseAddress);
00130 extern unsigned char I2C_masterSingleReceive (unsigned int baseAddress);
00131 extern unsigned long I2C_getReceiveBufferAddressForDMA (
00132     unsigned int baseAddress
00133     );
00134 extern unsigned long I2C_getTransmitBufferAddressForDMA (
00135     unsigned int baseAddress
00136     );
00137 extern unsigned char I2C_masterIsSTOPSent (unsigned int baseAddress);
00138 extern void I2C_masterSendStart (unsigned int baseAddress);
00139 #endif

Copyright 2012, Texas Instruments Incorporated