AnsweredAssumed Answered

confusion in stm8s_eval_i2c_ee.c of STM8S_StdPeriph_Lib

Question asked by Weihong Guan on Apr 9, 2018
Latest reply on Apr 10, 2018 by Weihong Guan

As a detailed look into STSW-STM8069 / STM8S_StdPeriph_Lib v2.2.0 :, the Utilities/STM8S_EVAL/Common/stm8s_eval_i2c_ee.c file is quite confusing.


I can see there is a SAFE procedure implemented. in line 230


* Read data from first byte until byte N-3 */

if ((uint16_t)(*NumByteToRead)> 3) 

I believe it should be a "while" instead of "if". "if" case only got one byte read. and there is no outer "while" to repeat this case.


in line 295

/* Reset the number of bytes to be read from the EEPROM */
NumByteToRead = 0;

In this function, NumByteToRead is a uint16_t pointer. setting the pointer to 0 / null, is it what the lib mean? Maybe doing it will also make (uint16_t)(*NumByteToRead) == 0. 


Somehow I just do not know why a safe procedure is recommended.