⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spitransferblock.c

📁 ti-Chipcon CC1010 1G以下Soc源码库。包括rf,powermodes,clockmodes,flashRW,interrupts,timer,pwm,uart...所有底层驱动源码
💻 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 + -