Exemple #1
0
/**
 * Begin a transmission as a master
 */
void DWire::beginTransmission(uint_fast8_t slaveAddress) {
	// Starting a transmission as a master to the slave at slaveAddress
	if (busRole != BUS_ROLE_MASTER)
		return;

	// Wait in case a previous message is still being sent
	while ( MAP_I2C_masterIsStopSent(module) == EUSCI_B_I2C_SENDING_STOP)
		;

	if (slaveAddress != this->slaveAddress)
		_setSlaveAddress(slaveAddress);
}
Exemple #2
0
/**
 * Begin a transmission as a master
 */
void DWire::beginTransmission( uint_fast8_t slaveAddress ) 
{
    // Starting a transmission as a master to the slave at slaveAddress
    if (busRole != BUS_ROLE_MASTER)
        return;

    // Wait in case a previous message is still being sent
    timeout = 0xFFFF;
    while ((*pTxBufferIndex > 0) & timeout)
        timeout--;
        
    if (!timeout) 
    {
        /* If we can't start the transmission, then reset everything */
        _resetBus( );
    }

    if (slaveAddress != this->slaveAddress)
        _setSlaveAddress( slaveAddress );
}