masterputsi2c2.c

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

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

/***********************************************************************
*    Function Name:  MasterputsI2C2
*    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_2

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

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

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




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

⌨️ 快捷键说明

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