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

📄 getsspi2.c

📁 PIC driver for ILI9325 display
💻 C
字号:
#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include "spi.h"

/****************************************************************************
*     Function Name :  getsSPI2                                             *
*     Description   :  This routine reads a string from the SPI             *
*                      receive buffer.The number of byte/word to be read    *
*                      is determined by parameter 'length'                  *
*     Parameters    :  unsigned int length: The length of data expected     *
*                      unsigned int *rdptr   the received data to be        *
*                      recorded to this array                               *
*                      unsigned int uart_data_wait timeout value            *
*     Return Value  :  unsigned int number of data bytes yet to be received *                     
****************************************************************************/

/* The following devices support SPI2 */
#ifdef _SPI_V2_2

unsigned int getsSPI2(unsigned int length, unsigned int *rdptr, unsigned int spi_data_wait)
{
    int wait = 0;
    char *temp_ptr = (char *)rdptr;
    while (length)                         /* stay in loop until length = 0  */
    {
        while(!DataRdySPI2())
        {

           if(wait < spi_data_wait)
              wait++ ;                     /* wait for time out operation */
           else
              return(length);              /* Time out, return number of byte/word read 
                                              for a given length */
        }
        wait = 0;
        if(SPI2CON1bits.MODE16)
//           *rdptr++ = getcSPI2();         /* read a single word */
			*rdptr++ = ReadSPI2();
        else
 //           *temp_ptr++ = getcSPI2();      /* read a single byte */
			*temp_ptr++ = ReadSPI2();
        length--;                          /* reduce string length count by 1*/
    }

    return (length);                       /* return number of byte/word to be read i.e, 0 */
}

#else
#warning "Does not build on this target"
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -