2021-12-30 06:30 AM
how to read write i2c eeprom using HAL_I2C_Mem_Read and HAL_I2C_Mem_Write function.
how to convert uint16_t to uint8_t and uint32_t to uint8_t
Solved! Go to Solution.
2021-12-30 05:47 PM
HAL_I2C_Mem_Read( &hi2c1,IIC_ReadAddr, 10, I2C_MEMADD_SIZE_8BIT, process_read_buf, 2, 1000 );//read uint16_t command
HAL_I2C_Mem_Read( &hi2c1,IIC_ReadAddr, 10, I2C_MEMADD_SIZE_8BIT, process_read_buf, 4, 1000 );//read uint32_t command
So simple
2021-12-30 08:41 AM
These functions take a pointer to the data, i.e.
if uint32_t x; is a variable, you supply
(uint8_t*)(&x) for the pData and
sizeof(uint32_t) for the Size parameter.
hth
KnarfB
2021-12-30 11:13 AM
The question is about basic C data types and pointers. It belongs to a school/university introductory course, not a manufacturer specific forum.
https://www.tutorialspoint.com/cprogramming/c_passing_pointers_to_functions.htm
https://www.tutorialspoint.com/cprogramming/c_type_casting.htm
2021-12-30 05:47 PM
HAL_I2C_Mem_Read( &hi2c1,IIC_ReadAddr, 10, I2C_MEMADD_SIZE_8BIT, process_read_buf, 2, 1000 );//read uint16_t command
HAL_I2C_Mem_Read( &hi2c1,IIC_ReadAddr, 10, I2C_MEMADD_SIZE_8BIT, process_read_buf, 4, 1000 );//read uint32_t command
So simple
2021-12-30 10:29 PM
Thanks works well gives exactly things I want :smiling_face_with_smiling_eyes:👍🏻