-
Notifications
You must be signed in to change notification settings - Fork 1k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
wrong error management in i2C functions - part 2 #1805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Discussion related to my comment:
=> Based on my understanding (may be wrong), my opinion (may be wrong too): twi.c is a bad word in this situation. Twi is a protocol very close to I2C protocol. word was defined for copyright reasons. But here the architecture of this file is not related to a dedicated protocol. To me, a better name should be hal_wire_bridge or something like that. For simplicity reasons Twi should work in the same mode (non blocking) for both slave and master:
To me, the current situation (a mix between non blocking mode for slave, blocking mode for master in file twi) is driving complexity to maintain the code. delay management in twi may be moved to wire for easy maintenance, and clear separation of tasks. |
@camelator,
1/ Aim of Stm32duino is not to fix HAL bad error management: Then, about function `HAL_I2C_Master_Seq_Receive_IT()
It looks normal to me, 2a/ 2b/
Hardware clock stretching is there for that purpose: Slave keeps clock low until data is ready to be send. No need for extra software. If Slave doesn't use stretch capability, the master will not wait.
I disagree: aim is not only simplicity, but also efficiency, and respect of Arduino API. Please note that I convert this thread to discussion, as I see no clear failing use case. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Well...
I don't know how the tests are done as master, but to me, it may work with fast MCU but not with CPU as I2S slave:
1/ To me, the HAL functions are not correct and for that STM32Duino must deliver / correct the bad error management from HAL.
Example in function HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_IT
This function has a bad mix of error management and state and return value.
Then, it is possible (and because of other errors in STM32duino) to have this function returning HAL_OK but reading nothing (for example, if the line is busy)
=> STM32Duino should not only manage the return value of the HAL functions but as well error codes and state values, for each call o HAL function, mainly in master mode.
2/ In master mode, The philosophy of the requestFrom is we have to send a request, wait the slave to be ready, and read the data and check errors during the process.
2a/ There is no error check after the TX in function requestFrom
2b/
There is no waiting code in STM32Duino resulting errors returned, or random results, or 0 data, or n random data.
There is something that look like waiting code in function i2c_master_read but it is not well managed as the errors, states and return values from HAL functions are too bad.
For example it is clearly possible that the RX become ready after a while but before the timeout. In this condition, the reading is not repeated resulting wrong results and random behaviors like this one:
https://community.st.com/s/question/0D53W00000EnOPYSA3/stm32l4-hali2cstatebusyrx-issue
but it is not for a short time, when it happens it is stay.
I am not sure part 1/ is related to master as the code on my slave can't see the errors on the line.
I am sure there are other mistakes as I can see sometime strange state values with strange logic state on SCL and SDA with a logic analyzer.
The text was updated successfully, but these errors were encountered: