Other Parts Discussed in Thread: MSPM0G3507, BQ25798, BQ4050
Hi Ti SDK enginners,
I have several questions regarding on your latest SDK.
1.undocumented issue resolution
Recently we upgraded our SDK to 1.30.00.03 and found regression issue. If an I2C device isn't connected, the MCU will struck.
I think that I found the root of cause that in 1.30.00.03, smbus_phy.c:
case DL_I2C_IIDX_CONTROLLER_NACK: ret_state = SMBus_NWK_controllerProcessNACK(smbus); __BKPT(0); /* Placeholder for debugging purposes */ break;
Probably the __BKPT(0) locks the MCU if debugger isn't attached. And this can explain why if a debugger attaches to it, I see a breakpoint stop on where I didn't put (actually in disassembly only, since we were using library, no source code symbol link to that)
I am happy to see this problem was solved in the latest 2.00.00.03. But Isn't disclosed in the SDK release page. Can you please attach brief description of this (regression) issue in SDK release in the future?
2. Unsure the intention of this piece of code, is it a bug?
smbus_phy.c:
SMBus_PHY_controllerStartRx(){ ... while (timeout && ( (DL_I2C_getControllerStatus(smbus->phy.SMBus_Phy_i2cBase) | DL_I2C_CONTROLLER_STATUS_BUSY) == DL_I2C_CONTROLLER_STATUS_BUSY ) ) { timeout--; } ... }
In my instinct, should bitfield be check like (get_flags() & bitfield_mask == bitfield_mask) to determine if bitfield_mask is set?
But why this code seems to work? Do you actually want to make sure all other bitfields must be 0? The code makes me confusion.
Can you explain the intention of this piece?
3.suggestion for makefile
Also, I am glad to see that in the 2.00.00.03 SDK, Some of the build option are provided as below.
#ifndef SMB_TARGET_SUPPORTS_HOST_NOTIFY #define SMB_TARGET_SUPPORTS_HOST_NOTIFY (true) #endif ... #ifndef SMB_CONTROLLER_SUPPORTS_HOST_NOTIFY #define SMB_CONTROLLER_SUPPORTS_HOST_NOTIFY (true) #endif
CFLAGS = $USER_CFLAGS -I$(TICLANG_ARMCOMPILER)/include ....... AFLAGS = $USER_AFLAGS rc ASMFLAGS = $USER_ASMFLAGS -I$(TICLANG_ARMCOMPILER)/include .....
SDK_INSTALL_DIR ?= $(MSPM0_SDK_DIR) TICLANG_ARMCOMPILER ?= $(TI_TOOL_DIR) GCC_ARMCOMPILER ?= $(GCC_TOOL_DIR) override NAME=$(SDK_LOCAL_BUILD_SMBUS_DIR)/smbus override OBJ_DIR=$(SDK_LOCAL_BUILD_SMBUS_DIR)/obj override SRC_DIR=$(SDK_INSTALL_DIR)/source/ti/smbus USER_CFLAGS = -DSMB_TARGET_SUPPORTS_HOST_NOTIFY=false -DSMB_CONTROLLER_SUPPORTS_HOST_NOTIFY=false include $(SRC_DIR)/lib/ticlang/m0p/Makefile
4.target and controller shares the same init
I saw that the smbus module references external function SYSCFG_DL_SMB_I2C_init() to initialize the underlying I2C peripheral. However, due to the namespace, if we use both smbus host and target in the same project (yes, we have two legs of I2C, we are designing a special I2C smbus gateway), it cannot achieve our goal.
I recommend to change your SMBus_controllerInit() and SMBus_targetInit() function prototype, to allow passing a function pointer void *p(void) to it. Then, in your internal implementation, you may call it through this way
SMBus_PHY_targetEnable(){ ... if(smbus->phy.init_fun){ smbus->phy.init_fun(); } ....