I'm using PMM240 power management board to control battery RRC-2054, and I have problem to use SMBus, please see the code I listed below, looks device is ready, but when you send something, it is always in busy(Master Data Transmission process is ongoing). Will this a matter of address problem, or a command problem, or others? anyway to get more info for this busy status?
if (HAL_SMBUS_IsDeviceReady(&hsmbus2, (uint16_t) PMM240_ADDRESS, 2, 2)
!= HAL_OK) {
Error_Handler();//passed
}
uint32_t test = HAL_SMBUS_GetState(&hsmbus2);
if (test != HAL_SMBUS_STATE_READY) {
Error_Handler();//passed.
}
ret = HAL_SMBUS_Master_Transmit_IT(&hsmbus2,
(uint16_t) PMM240_ADDRESS, &buffertx[0], 1,
SMBUS_OTHER_FRAME_NO_PEC);
if (ret != HAL_OK) {
Error_Handler();//passed
}
// after enough time delay, 100 or 1000 ms
HAL_Delay(100);//not useful for the following code.
// inserting HAL_SMBUS_Init(&hsmbus2) could reset the busy status, but info lost, right?
test = HAL_SMBUS_GetState(&hsmbus2);
if (test != HAL_SMBUS_STATE_READY) {
Error_Handler();//not passed
}