5. Add the following I²C error handling code below stm32f7xx_it.c when using STM32 FW_F7 V1.7.0 or lower.
This handles the I²C NACK after performing a system reset.
/**
* @brief this function handles I2C1 error interrupt.
*/
voidI2C1_ER_IRQHandler(void)
{
/* USER CODE BEGIN I2C1_ER_IRQn 0 */
i2c_temp.Mode = hi2c1.Mode;
i2c_temp.State = hi2c1.State;
/* USER CODE END I2C1_ER_IRQn 0 */
HAL_I2C_ER_IRQHandler(&hi2c1);
/* USER CODE BEGIN I2C1_ER_IRQn 1 */
hi2c1.Mode = i2c_temp.Mode;
hi2c1.State = i2c_temp.State;
/* USER CODE END I2C1_ER_IRQn 1 */
}
6.4.6 API
1. chip_info_show
Name int chip_info_show(char *buf)
Description Read chip information and return chip ID and version
Parameters char * buf Host allocated buffer to return chip information or error codes.
Return value int Length of the output buffer
2. nvm_program_show
Name
int nvm_program_show(char *buf)
Description Program NVM with provided Header file.
Parameters char * buf Host allocated buffer to return error codes.
Return value int Length of the output buffer
6.4.7 Error codes
Table 8. Error codes with descriptions
Error code
Value Description
OK 0x00000000 Success operation.
E_BUS_R 0x80000001 Error during I2C read operation.
E_BUS_W 0x80000002 Error during I2C write operation.
E_BUS_WR 0x80000003 Error during I2C write read operation.
E_UNEXPECTED_OP_MODE 0x80000004 Invalid operating mode. NVM programming must be done in DC mode.
E_NVM_WRITE 0x80000005 Failed to program NVM.
E_INVALID_INPUT 0x80000006 Invalid input parameters.
E_MEMORY_ALLOC 0x80000007 Failed to allocate memory buffer.
E_UNEXPECTED_HW_REV 0x80000008 Invalid chip revision. Should match the provided nvm_data.h.
E_TIMEOUT 0x80000009 Timeout error when performing firmware operation.
E_NVM_DATA_MISMATCH 0x8000000A Data mismatch with programmed data.
E_UNEXPECTED_CHIP_ID 0x8000000B Invalid chip ID. Should match the provided nvm_data.h.
UM3161
Reference code with STM32 development boards
UM3161 - Rev 1
page 54/78