Skip to content
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

Wire: Max TX buffer length #1562

Merged
merged 4 commits into from
Nov 26, 2021
Merged

Conversation

ABOSTM
Copy link
Contributor

@ABOSTM ABOSTM commented Nov 26, 2021

Summary
Wire: limit TX buffer size to avoid consuming too much stack

If data size to be sent is greater than the max defined,
application can split the transfert
Note: no limit implemented in RX buffer, because when receiving,
data are received on I2C, it is not possible to split.

Fixes #1539

txBufferIndex and txBufferLength always have the same value.
Thus only 1 variable is necessary.
Rename it txDataSize for better understanding.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
Prepare introduction of max TX buffer length

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
@ABOSTM ABOSTM added the Fix label Nov 26, 2021
@fpistm fpistm added this to In progress in STM32 core based on ST HAL via automation Nov 26, 2021
@fpistm fpistm added this to the 2.2.0 🎄 🎅 milestone Nov 26, 2021
@fpistm fpistm assigned ABOSTM and unassigned fpistm Nov 26, 2021
@fpistm fpistm self-requested a review November 26, 2021 09:09
libraries/Wire/src/Wire.h Show resolved Hide resolved
libraries/Wire/src/Wire.h Outdated Show resolved Hide resolved
libraries/Wire/src/Wire.cpp Outdated Show resolved Hide resolved
STM32 core based on ST HAL automation moved this from In progress to Needs review Nov 26, 2021
If data size to be sent is greater than the max defined,
application can split the transfert
Note: no limit implemented in RX buffer, because when receiving,
data are received on I2C, it is not possible to split.

Fixes stm32duino#1539

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
Check of null pointer is already done in both
* allocateTxBuffer()
* allocateRxBuffer()
and it leads to _Error_Handler()

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
STM32 core based on ST HAL automation moved this from Needs review to Reviewer approved Nov 26, 2021
@fpistm fpistm merged commit 7ae74e4 into stm32duino:main Nov 26, 2021
STM32 core based on ST HAL automation moved this from Reviewer approved to Done Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

Wire: limit buffer size allocation
2 participants