slaveputsi2c1.c
来自「基於 c51/8051 的 nand Flash Memory HY27US08」· C语言 代码 · 共 36 行
C
36 行
#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include <i2c.h>
/**************************************************************************
* Function Name: SlaveputsI2C1
* Description: This routine is used to write out a string to the
* I2C bus.If write collision occurs,-3 is sent.If
* string is written and null char reached, 0 is returned.
* Parameters: unsigned char * : wrptr
* Return Value: unsigned int
****************************************************************************/
#ifdef _I2C_V2_1
unsigned int SlaveputsI2C1(unsigned char * wrptr)
{
I2C1CONbits.STREN = 1; /* SCL clock stretch enable bit */
while(*wrptr) /* transmit data until null char */
{
SlaveputcI2C1(*wrptr++); /* Send a byte */
while(I2C1STATbits.TBF); /* wait till the transmit buffer is clear */
while(!IFS1bits.SI2C1IF); /* Wait till the ACK from master is received */
IFS1bits.SI2C1IF = 0; /* Clear Flag */
}
return 0; /* null char was reached */
}
#else
#warning "Does not build on this target"
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?