writespi1.c

来自「Mplab C30编译器」· C语言 代码 · 共 38 行

C
38
字号
#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include "spi.h"

/********************************************************************************
Function Prototype : void WriteSPI1(unsigned int data_out)
 
Include            : spi.h
 
Description        : This function writes the data to be transmitted 
                     into the Transmit Buffer (SPIxBUF) register.
 
Arguments          : data_out - This is the data to be transmitted which 
                     will be stored in SPI buffer.
 
Return Value       : None
 
Remarks            : This function writes the data (byte/word) to be transmitted
                     into the transmit buffer.
                     If 16-bit communication is enabled, the 16-bit value is 
                     written to the transmit buffer.
                     If 8-bit communication is enabled, then upper byte is masked
                     and then written to the transmit buffer.
**********************************************************************************/
#ifdef _SPI_V2_1

void WriteSPI1(unsigned int data_out)
{   
    if (SPI1CON1bits.MODE16)          /* word write */
        SPI1BUF = data_out;
    else 
        SPI1BUF = data_out & 0xff;   /*  byte write  */
}
#else
#warning "Does not build on this target"
#endif

⌨️ 快捷键说明

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