added getMasterAddress() and isSlaveMaster()

This commit is contained in:
john30
2015-03-07 12:04:24 +01:00
parent ed3ef3f5e4
commit 9bf17b86c6
2 changed files with 29 additions and 0 deletions
+15
View File
@@ -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);
+14
View File
@@ -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.