Skip to content

Commit c773137

Browse files
committed
Accept 8bit I2C address from user and shift it to 7bit
Before, user has to enter 7bit address of I2C, but based on EAPI specification, the I2C device address <adr> is expected in 8-bit hex format with the 7-bit address in the upper seven bits and the lowest bit set as read (1) / write (0) bit accordingly. In other words, user must enter encoded 7bit address. EAPIlib should decode that In addition, unsupported 10bit comparison is removed, becasue it is already checked in EApiAPI.cpp file Signed-off-by: reyhanehy <reyhane.y84@gmail.com>
1 parent b36cd61 commit c773137

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

lib/EApiEmulI2C.c

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,9 @@ EApiI2CWriteReadEmul(
120120

121121
i2cbus = Id;
122122

123-
if((Addr & 0x80) == 0x80){ //10bit addr
124-
EAPI_LIB_RETURN_ERROR(
125-
EApiI2CWriteReadEmul,
126-
EAPI_STATUS_UNSUPPORTED ,
127-
"10Bit Address is not supported"
128-
);
129-
/* LclAddr=Addr<<8;
130-
LclAddr|=*((uint8_t *)pWBuffer);
131-
pWBuffer=((uint8_t *)pWBuffer)+1;
132-
WriteBCnt--;*/
133-
}
134-
else
135-
LclAddr=Addr;
123+
/* EAPI specification expects 8bit address from user, which should be
124+
* shifted one bit to have 7bit address */
125+
LclAddr=EAPI_I2C_DEC_7BIT_ADDR(Addr);
136126

137127
#if (STRICT_VALIDATION>1)
138128
siFormattedMessage_M2(
@@ -436,19 +426,9 @@ EApiI2CWriteReadEmulUniversal(
436426

437427
i2cbus = Id;
438428

439-
if((Addr & 0x80) == 0x80){ //10bit addr
440-
EAPI_LIB_RETURN_ERROR(
441-
EApiI2CWriteReadEmulUniversal,
442-
EAPI_STATUS_UNSUPPORTED ,
443-
"10Bit Address is not supported"
444-
);
445-
/* LclAddr=Addr<<8;
446-
LclAddr|=*((uint8_t *)pWBuffer);
447-
pWBuffer=((uint8_t *)pWBuffer)+1;
448-
WriteBCnt--; */
449-
}
450-
else
451-
LclAddr=Addr;
429+
/* EAPI specification expects 8bit address from user, which should be
430+
* shifted one bit to have 7bit address */
431+
LclAddr=EAPI_I2C_DEC_7BIT_ADDR(Addr);
452432

453433
#if (STRICT_VALIDATION>1)
454434
siFormattedMessage_M2(

0 commit comments

Comments
 (0)