cancel
Showing results for 
Search instead for 
Did you mean: 

confusion in stm8s_eval_i2c_ee.c of STM8S_StdPeriph_Lib

Weihong Guan
Associate
Posted on April 09, 2018 at 17:29

As a detailed look into 

STSW-STM8069 / STM8S_StdPeriph_Lib v2.2.0 :

 

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm8-embedded-software/stsw-stm8069.html

, 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.

#i2c #stm8s #standard-peripheral-library
2 REPLIES 2
henry.dick
Senior II
Posted on April 10, 2018 at 12:22

the comment in the code associated with your first question should have given enough clue: that's typical for i2c read/write functions from/to a block;

the 2nd one is legit. unless they changed the use for that variable.

Posted on April 10, 2018 at 18:51

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6sF&d=%2Fa%2F0X0000000bx4%2FJjKH.loSDqp0CEUemcqj1os4GhPhRN3gLKYgmDrzALU&asPdf=false