How to check for Rx/TX Errors using DS3231?
This is my first STM32 project, I have little experience with the CubeIDE or STM32. I am trying to move over from doing all of my previous projects on Arduino.
I have got the DS3231 working using the STM32CubeIDE. Board = Nucleo 144 - F413ZH.
I am reading the time, that I set, and I am printing it to the serial monitor using UART.
I am using the following to read and when required, write to the DS3231:
#define DS3231_ADDRESS 0xD0
HAL_I2C_Mem_Write(&hi2c1, DS3231_ADDRESS, 0x00, 1, setArray, 7, 1000);
HAL_I2C_Mem_Read(&hi2c1, DS3231_ADDRESS, 0x00, 1, getArray, 7, 1000);
As you might see, I have just got two functions called set and get time that include these lines.
However, I would like to understand how to use the HAL_StatusTypeDef to check if there are any errors on the I2C lines. Similar to what is implemented in DigiKeys video on youtube titled "Getting Started With STM32 and Nucleo Part 2". But I cannot understand how to implement it with the DS3231.
I have tried similar implementations of the following but cannot get it working:
ret = HAL_I2C_Master_Transmit(hi2c, DevAddress, pData, Size, Timeout)
ret = HAL_I2C_Master_Receive(hi2c, DevAddress, pData, Size, Timeout)
The goal is to print out "Rx Error" or "Tx Error" if the corresponding SDA or SDL line is disconnected.
