本文整理汇总了C++中IdleI2C函数的典型用法代码示例。如果您正苦于以下问题:C++ IdleI2C函数的具体用法?C++ IdleI2C怎么用?C++ IdleI2C使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IdleI2C函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XEEBeginRead
/*********************************************************************
* Function: XEE_RESULT XEEBeginRead(unsigned char control,
* XEE_ADDR address)
*
* PreCondition: XEEInit() is already called.
*
* Input: control - EEPROM control and address code.
* address - Address at which read is to be performed.
*
* Output: XEE_SUCCESS if successful
* other value if failed.
*
* Side Effects: None
*
* Overview: Sets internal address counter to given address.
* Puts EEPROM in sequential read mode.
*
* Note: This function does not release I2C bus.
* User must call XEEEndRead() when read is not longer
* needed; I2C bus will released after XEEEndRead()
* is called.
********************************************************************/
XEE_RESULT XEEBeginRead(unsigned char control, XEE_ADDR address )
{
unsigned char r;
r = XEESetAddr(control, address);
if ( r != XEE_SUCCESS )
return r;
r = XEEClose();
if ( r != XEE_SUCCESS )
return r;
IdleI2C();
StartI2C();
while( EEPROM_SPICON2bits.SEN );
if ( PIR2bits.BCLIF )
return XEE_BUS_COLLISION;
if ( WriteI2C(control+1) )
return XEE_BUS_COLLISION;
IdleI2C();
if ( !EEPROM_SPICON2bits.ACKSTAT )
return XEE_SUCCESS;
return XEE_NAK;
}
示例2: LDByteWriteI2C
/*********************************************************************
* Function: LDByteWriteI2C()
* Input: Control Byte, 8 - bit address, data.
* Overview: Write a byte to low density device at address LowAdd
********************************************************************/
unsigned int LDByteWriteI2C(unsigned char ControlByte, unsigned char LowAdd, unsigned char data)
{
unsigned int ErrorCode1;
unsigned int ErrorCode2;
IdleI2C(); //Ensure Module is Idle
StartI2C(); //Generate Start COndition
WriteI2C(ControlByte); //Write Control byte
IdleI2C();
ErrorCode1 = ACKStatus(); //Return ACK Status
WriteI2C(LowAdd); //Write Low Address
IdleI2C();
ErrorCode2 = ACKStatus(); //Return ACK Status
WriteI2C(data); //Write Data
IdleI2C();
StopI2C(); //Initiate Stop Condition
//EEAckPolling(ControlByte); //Perform ACK polling
if(ErrorCode1 == 0) { printf("ACK 1 not recieved"); }
if(ErrorCode2 == 0) { printf("ACK 2 not recieved"); }
//return(ErrorCode);
}
示例3: i2c_write
static int
i2c_write(struct i2c_platform_data *adap, unsigned char *buf,
unsigned int len)
{
int i;
u32 data;
pr_debug("i2c_write\n");
i = 0;
while (i < len) {
data = buf[i];
if (MasterWriteI2C(adap, data))
return -EIO;
IdleI2C(adap);
if (pic32_bus_readl(adap->base + PIC32_I2CxSTAT) &
I2CSTAT_ACKSTAT)
return -EIO;
i++;
}
StopI2C(adap);
IdleI2C(adap);
return 0;
}
示例4: internalChangeAddressLine
void internalChangeAddressLine(unsigned char oldAddress, unsigned char value) {
IdleI2C();
StartI2C();
MasterWriteI2C(oldAddress);
IdleI2C();
MasterWriteI2C(0);
IdleI2C();
MasterWriteI2C(value);
IdleI2C();
StopI2C();
IdleI2C();
}
示例5: XEEWrite
XEE_RESULT XEEWrite(unsigned char val)
{
IdleI2C(); // ensure module is idle
if ( WriteI2C( val ) ) // data byte for EEPROM
return XEE_BUS_COLLISION; // set error for write collision
IdleI2C();
if ( !EEPROM_SPICON2bits.ACKSTAT )
return XEE_SUCCESS;
return XEE_NAK;
}
示例6: LDPageWriteI2C
/*********************************************************************
* Function: LDPageWriteI2C()
* Input: ControlByte, LowAdd, *wrptr.
* Overview: Write a page of data from array pointed to be wrptr
* starting at LowAdd
* Note: LowAdd must start on a page boundary
********************************************************************/
unsigned int LDPageWriteI2C(unsigned char ControlByte, unsigned char LowAdd, unsigned char *wrptr)
{
IdleI2C(); //wait for bus Idle
StartI2C(); //Generate Start condition
WriteI2C(ControlByte); //send controlbyte for a write
IdleI2C(); //wait for bus Idle
WriteI2C(LowAdd); //send low address
IdleI2C(); //wait for bus Idle
putstringI2C(wrptr); //send data
IdleI2C(); //wait for bus Idle
StopI2C(); //Generate Stop
return(0);
}
示例7: writeSRF02Command
void writeSRF02Command(char addr, char reg, char cmd) {
StartI2C();
// Wait till Start sequence is completed
IdleI2C();
MasterWriteI2C(addr);
IdleI2C();
MasterWriteI2C(reg);
IdleI2C();
// command
MasterWriteI2C(cmd);
IdleI2C();
StopI2C();
}
示例8: XEEIsBusy
/*********************************************************************
* Function: XEE_RESULT XEEIsBusy(unsigned char control)
*
* PreCondition: XEEInit() is already called.
*
* Input: control - EEPROM control and address code.
*
* Output: XEE_READY if EEPROM is not busy
* XEE_BUSY if EEPROM is busy
* other value if failed.
*
* Side Effects: None
*
* Overview: Requests ack from EEPROM.
*
* Note: None
********************************************************************/
XEE_RESULT XEEIsBusy(unsigned char control)
{
XEE_RESULT r;
IdleI2C(); // ensure module is idle
StartI2C(); // initiate START condition
while ( EEPROM_SPICON2bits.SEN ); // wait until start condition is over
if ( PIR2bits.BCLIF ) // test for bus collision
{
return XEE_BUS_COLLISION; // return with Bus Collision error
}
else
{
if ( WriteI2C( control ) ) // write byte - R/W bit should be 0
return XEE_BUS_COLLISION; // set error for write collision
IdleI2C(); // ensure module is idle
if ( PIR2bits.BCLIF ) // test for bus collision
return XEE_BUS_COLLISION; // return with Bus Collision error
if ( !EEPROM_SPICON2bits.ACKSTAT )
r = XEE_READY;
else
r = XEE_BUSY;
#if 0
while ( EEPROM_SPICON2bits.ACKSTAT ) // test for ACK condition received
{
RestartI2C(); // initiate Restart condition
while ( EEPROM_SPICON2bits.RSEN ); // wait until re-start condition is over
if ( PIR2bits.BCLIF ) // test for bus collision
return XEE_BUS_COLLISION; // return with Bus Collision error
if ( WriteI2C( control ) ) // write byte - R/W bit should be 0
return XEE_BUS_COLLISION; // set error for write collision
IdleI2C(); // ensure module is idle
}
#endif
}
StopI2C(); // send STOP condition
while ( EEPROM_SPICON2bits.PEN ); // wait until stop condition is over
if ( PIR2bits.BCLIF ) // test for bus collision
return XEE_BUS_COLLISION; // return with Bus Collision error
return r;
//return XEE_READY; // return with no error
}
示例9: setRelayStates
void setRelayStates(int relayStates) {
StartI2C();
IdleI2C();
while(I2CCONbits.SEN);
MasterWriteI2C(writeAddr);
IdleI2C();
// send the register
MasterWriteI2C(RLY08_REGISTER_RELAY_STATES);
IdleI2C();
// send the value
MasterWriteI2C(relayStates);
IdleI2C();
StopI2C();
}
示例10: sendRLY08Command
void sendRLY08Command(int command) {
StartI2C();
IdleI2C();
while(I2CCONbits.SEN);
MasterWriteI2C(writeAddr);
IdleI2C();
// send the register
MasterWriteI2C(RLY08_REGISTER_COMMAND);
IdleI2C();
// send the value
MasterWriteI2C(command);
IdleI2C();
StopI2C();
}
示例11: ReadI2C
int16_t ReadI2C (void)
{
int i;
static int16_t retval = 0;
if (IdleI2C () != 1)
{
return ERREUR_I2C_IDLE;
}
I2C1CONbits.RCEN = 1;
for (i=TIMEOUT_I2C; i>0; i--)
{
if(I2C1STATbits.RBF)
break;
if ((i-1) <= 0)
return ERREUR_I2C_READ;
}
retval = (int16_t)I2C1RCV;
return retval;
}
示例12: WriteI2C
int16_t WriteI2C (uint8_t byte)
{
int i;
if (IdleI2C () != 1)
{
return ERREUR_I2C_IDLE;
}
I2C1TRN = byte;
for (i=TIMEOUT_I2C; i>0; i--)
{
if (!I2C1STATbits.TBF)
{
break;
}
else
{
if (i == 0)
return ERREUR_I2C_WRITE;
}
}
return 1;
}
示例13: RestartI2C
int16_t RestartI2C (void)
{
int i;
if (IdleI2C () != 1)
{
return ERREUR_I2C_IDLE;
}
I2C1CONbits.RSEN = 1;
for (i=TIMEOUT_I2C; i>0; i--)
{
if (!I2C1CONbits.RSEN)
{
break;
}
else
{
if (i == 0)
return ERREUR_I2C_RESTART;
}
}
return 1;
}
示例14: StopI2C
int16_t StopI2C (void)
{
int i;
if (IdleI2C () != 1)
{
return ERREUR_I2C_IDLE;
}
I2C1CONbits.PEN = 1;
for (i=TIMEOUT_I2C; i>0; i--)
{
if (!I2C1CONbits.PEN)
{
break;
}
else
{
if (i == 0)
return ERREUR_I2C_STOP;
}
}
return 1;
}
示例15: SendChar
void SendChar(unsigned char data) {
IdleI2C();
StartI2C();
IdleI2C();
putcI2C(OLED_address); //send address
IdleI2C();
putcI2C(0x40); //send data incomming
IdleI2C();
putcI2C(data);
IdleI2C();
// WriteI2C(0x40);
//WriteI2C(data);
StopI2C();
}