?? main.c
字號:
/*** USCI master library with DMA **********************************************
In this file the usage of the USCI I2C master library with DMA support is shown.
This library uses pointers to specify what data is to be sent. The usage of the
DMA is transparent to the user.
When calling the TI_USCI_I2C_DMA_receive or TI_USCI_I2C_DMA_transmit routines
the number of bytes, which are to be transmitted or received have to be passed
as well as a pointer to a data field, that contains(or stores) the data.
This code checks if there is a slave with address 0x50 is connected to the I2C
bus and if the slave device is present, bytes are received and transmitted.
Uli Kretzschmar
MSP430 Systems
Freising
*******************************************************************************/
#include "msp430x26x.h"
#include "TI_USCI_I2C_master_dma.h"
unsigned char array[40] = { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb };
unsigned char store[40] = { 13, 13, 13, 13, 13, 13, 13, 0, 0, 0};
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_8MHZ;
DCOCTL = CALDCO_8MHZ;
_EINT();
TI_USCI_I2C_DMA_transmitinit(0x50,0x12);// init transmitting with USCI and DMA
while ( TI_USCI_I2C_notready() ); // wait for bus to be free
if ( TI_USCI_I2C_slave_present(0x50) ) // slave address may differ from
{ // initialization
TI_USCI_I2C_DMA_receiveinit(0x50,0x12); // init receiving with USCI and DMA
while ( TI_USCI_I2C_notready() ); // wait for bus to be free
TI_USCI_I2C_DMA_receive(4,store);
while ( TI_USCI_I2C_notready() ); // wait for bus to be free
TI_USCI_I2C_DMA_transmitinit(0x50,0x12);// init transmitting with USCI and DMA
while ( TI_USCI_I2C_notready() ); // wait for bus to be free
TI_USCI_I2C_DMA_transmit(4,array); // start transmitting with DMA
}
LPM3;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -