added getMasterAddress() and isSlaveMaster()
This commit is contained in:
@@ -198,6 +198,21 @@ bool isMaster(unsigned char addr) {
|
||||
&& ((addrLo == 0x0) || (addrLo == 0x1) || (addrLo == 0x3) || (addrLo == 0x7) || (addrLo == 0xF));
|
||||
}
|
||||
|
||||
bool isSlaveMaster(unsigned char addr) {
|
||||
return isMaster((unsigned char)(addr+256-5));
|
||||
}
|
||||
|
||||
unsigned char getMasterAddress(unsigned char addr) {
|
||||
if (isMaster(addr))
|
||||
return addr;
|
||||
|
||||
addr = (unsigned char)(addr+256-5);
|
||||
if (isMaster(addr))
|
||||
return addr;
|
||||
|
||||
return SYN;
|
||||
}
|
||||
|
||||
unsigned char getMasterNumber(unsigned char addr) {
|
||||
unsigned char addrHi = (addr & 0xF0) >> 4;
|
||||
unsigned char addrLo = (addr & 0x0F);
|
||||
|
||||
@@ -156,6 +156,20 @@ private:
|
||||
*/
|
||||
bool isMaster(unsigned char addr);
|
||||
|
||||
/**
|
||||
* Returns whether the address is a slave address of one of the 25 masters.
|
||||
* @param addr the address to check.
|
||||
* @return <code>true</code> if the specified address is a slave address of a master.
|
||||
*/
|
||||
bool isSlaveMaster(unsigned char addr);
|
||||
|
||||
/**
|
||||
* Returns the master address associated with the specified address (master or slave).
|
||||
* @param addr the address to check.
|
||||
* @return the master address, or SYN if the specified address is neither a master address nor a slave address of a master.
|
||||
*/
|
||||
unsigned char getMasterAddress(unsigned char addr);
|
||||
|
||||
/**
|
||||
* Returns the number of the master if the address is a valid bus address.
|
||||
* @param addr the bus address.
|
||||
|
||||
Reference in New Issue
Block a user