2023-10-16 11:47 PM
Hello everyone,
I'm new in STM32CubeIDE, and I work on I2C issues. I've wrote the below code in Arduino, but I can't set the some codes for STM32CubeIDE.
How I can adjust the below codes for STM32CubeIDE?
Thanks in advance.
Codes:
#define REGMAP_ORG 0x00
#define SLAVE_ADDRESS 0x32
#define CTRL_CMD 0x86
#define SAVE_CHECK_CRC 0x02
Wire.beginTransmission(SLAVE_ADDRESS); // transmit to device #0x32
Wire.write(REGMAP_ORG); // sends offset byte
Wire.write(00);
Wire.endTransmission(); // stop transmitting
Wire.beginTransmission(SLAVE_ADDRESS); // transmit to device #0x32
Wire.write(CTRL_CMD);
Wire.write(SAVE_CHECK_CRC);
Wire.endTransmission(); // stop transmitting
Wire.requestFrom(SLAVE_ADDRESS, 2); //2 bytes
2023-10-16 11:57 PM
Use HAL
Use perhaps functions HAL_I2C_Mem_Read() and HAL_I2C_Mem_Write() for internal address / byte(s) type communication.Or look at related HAL I2C functions, and examples.
https://github.com/cturvey/RandomNinjaChef/blob/main/STM32_uBlox_I2C.c
https://github.com/cturvey/RandomNinjaChef/blob/main/MKRWAN1300_SAM_M8Q_I2C.ino
2023-10-17 07:02 AM
2023-10-20 12:16 AM
Thanks for replying @Rim LANDOLSI @Tesla DeLorean