putsspi1.c
来自「Microchip的官方PIC24H系列16位单片机的外设源程序库。」· C语言 代码 · 共 27 行
C
27 行
#include <p30fxxxx.h>
#include <spi.h>
/*****************************************************************************
* Function Name : putsSPI1 *
* Description : This function writes the specified length of data *
word/byte to be transmitted into the transmit buffer *
* Parameters : unsigned int: length of bytes/words to be written *
unsigned int*: Address ofthe location where the data *
to be transmitted is stored *
* Return Value : None *
******************************************************************************/
void putsSPI1(unsigned int length, unsigned int *wrptr)
{
char *temp_ptr = (char *) wrptr;
while (length) /* write byte/word until length is 0 */
{
if(SPI1CONbits.MODE16)
SPI1BUF = *wrptr++; /* initiate SPI bus cycle by word write */
else
SPI1BUF = *temp_ptr++; /* initiate SPI bus cycle by byte write */
while(SPI1STATbits.SPITBF); /* wait until 'SPITBF' bit is cleared */
length--; /* decrement length */
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?