Selso LIBERADO

STM32F303 BSP Code for EEPROM API Error on EEPROM_I2C_ReadBuffer()

Discussion created by Selso LIBERADO on Mar 6, 2017

Hello !

I'am using STMCubeMX, the STMCUBe HAL and BSP code for accessing a M24M01 EEPROM.

 

For reading data that I use the the BSP  function  :

uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint32_t* NumByteToRead)

 

The Call Stack is :

BSP_EEPROM_ReadBuffer -> EEPROM_I2C_ReadBuffer -> EEPROM_I2C_IO_ReadData -> I2Cx_ReadBuffer -> HAL_I2C_Mem_Read

 

The documentation of the BSP function says that NumByteToRead is modified after the call :

The variable pointed by NumByteToRead is reset to 0 when all the
  *              data are read from the EEPROM. Application should monitor this
  *              variable in order know when the transfer is complete.

 

But that's not right, in the function EEPROM_I2C_ReadBuffer  we copy the argument value and passes it to EEPROM_I2C_IO_ReadData, and never touches the argument value of the caller.

 

I looped until all bytes sent as adviced but it leads to infinite loop. As the called function does not return the bytes actually sent the quickest fix would be to change BSP_EEPROM_ReadBuffer arg type to "uint32_t"

 

Best regards.

Outcomes