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

📄 writespi1.c

📁 Mplab C30编译器
💻 C
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -