2021-04-07 06:31 AM
/* List of XferOptions in usage of :
* 1- Restart condition when direction change
* 2- No Restart condition in other use cases
*/
#define SMBUS_FIRST_FRAME SMBUS_SOFTEND_MODE
#define SMBUS_NEXT_FRAME ((uint32_t(SMBUS_RELOAD_MODE|SMBUS_SOFTEND_MODE))
#define SMBUS_FIRST_AND_LAST_FRAME_NO_PEC SMBUS_AUTOEND_MODE
#define SMBUS_LAST_FRAME_NO_PEC SMBUS_AUTOEND_MODE
#define SMBUS_FIRST_FRAME_WITH_PEC (SMBUS_SOFTEND_MODE|SMBUS_SENDPEC_MODE))
#define SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC ((uint32_t)(SMBUS_AUTOEND_MODE | SMBUS_SENDPEC_MODE))
#define SMBUS_LAST_FRAME_WITH_PEC ((uint32_t)(SMBUS_AUTOEND_MODE | SMBUS_SENDPEC_MODE))
/* List of XferOptions in usage of :
* 1- Restart condition in all use cases (direction change or not)
*/
#define SMBUS_OTHER_FRAME_NO_PEC (0x000000AAU)
#define SMBUS_OTHER_FRAME_WITH_PEC (0x0000AA00U)
#define SMBUS_OTHER_AND_LAST_FRAME_NO_PEC (0x00AA0000U)
#define SMBUS_OTHER_AND_LAST_FRAME_WITH_PEC (0xAA000000U)
/**
From the above options in master mode which Xferotion should be selected if I want to generate a restart condition?
What is the difference between SMBUS_OTHER_FRAME_NO_PEC and SMBUS_FIRST_FRAME ?
I want to write a byte of data to slave with a restart condition by using HAL_SMBUS_Master_Transmit_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
and then receive data from slave using
HAL_SMBUS_Master_Receive_IT(SMBUS_HandleTypeDef *hsmbus, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
After receiving there should be a stop condition generated. So Xferoption while transmitting should be SMBUS_SOFTEND_MODE and while receiving it should be SMBUS_AUTOEND_MODE. Please let me know if the procedure is correct?
But when should we call HAL_SMBUS_Master_Receive_IT()? Should I call it after the TC flag is set from the previous Transmission ie in (HAL_SMBUS_MasterTxCpltCallback()) or
While(1)
{
HAL_SMBUS_Master_Transmit_IT();
HAL_SMBUS_Master_Receive_IT();
}
should work?