masterputsi2c1.c

来自「基於 c51/8051 的 nand Flash Memory HY27US08」· C语言 代码 · 共 38 行

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

/***********************************************************************
*    Function Name:  MasterputsI2C1
*    Description:    This routine is used to write out a string to the 
*                    I2C bus.If write collision occurs,-3 is sent.If 
*                    Nack is received, -2 is sent.If string is written 
*                    and null char reached, 0 is returned.               
*    Parameters:     unsigned char * : wrptr                                    
*    Return Value:   char  
************************************************************************/

#ifdef _I2C_V2_1

char MasterputsI2C1(unsigned char * wrptr)
{
    while(*wrptr)                           //transmit data until null char
    {
        if(MasterputcI2C1(*wrptr) == -1)        // write a byte
        return -3;                          //return with write collison error

        while(I2C1STATbits.TBF);             //Wait till data is transmitted.

        IdleI2C1();
        wrptr++;
    }
    return 0;           
}



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

⌨️ 快捷键说明

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