📄 spitransferblock.c
字号:
/*****************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON CC1010 *
* *** + + *** HAL - SpiTransferBlock *
* *** +++ *** *
* *** *** *
* *********** *
* ********* *
* *
*****************************************************************************
* *
*****************************************************************************
* Author: ROH *
*****************************************************************************
* Revision history: *
* *
* $Log: SpiTransferBlock.c,v $
* Revision 1.1 2002/10/14 13:04:36 tos
* Initial version in CVS.
*
* *
****************************************************************************/
#include <chipcon/hal.h>
//----------------------------------------------------------------------------
// void halSpiTransferBlock(...)
//
// Description:
// Transfers _length_ bytes of the data block pointed to by _inoutBuffer_
// over the SPI interface. It is assumed that the SPI interface has
// already been correctly configured. If _read_ is TRUE the incoming
// data on the SPI interface will be stored in place in _inoutBuffer_,
// (overwriting the data that is transmitted), otherwise the received
// data is ignored.
//
// Arguments:
// byte* inoutBuffer
// Pointer to a block of data that is to be transmitted. If _read_ is
// TRUE the received data will overwrite this data.
// word length
// The number of bytes to receive/transmit.
// bool enableRead
// Overwrite the data transmitted with the received data (TRUE) or
// ignore received data (FALSE).
//
// Return value:
// void
//----------------------------------------------------------------------------
void halSpiTransferBlock(byte* inoutBuffer, word length, bool enableRead) {
// while (SPI_IS_ACTIVE); Removed by arr 2002-04-18
while (length--) { // Changed from _--length_ by arr 2002-04-18
SPI_DATA=*inoutBuffer;
//Torgeir:
//Wait until transmit complete (8 clk cycles) before read
while (SPI_IS_ACTIVE);
if (enableRead)
*inoutBuffer=SPI_DATA;
inoutBuffer++;
//Torgeir
//while (SPI_IS_ACTIVE); // Added by arr 2002-04-18
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -