-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
arch/arm/stm32/: Fix I2C to support STM32G4 devices. #15420
base: master
Are you sure you want to change the base?
Conversation
[Experimental Bot, please feedback here] Fill In The Commit Message: This PR contains a Commit with an Empty Commit Message. Please fill in the Commit Message with the PR Summary. This PR description does not fully meet the NuttX requirements. Here's a breakdown of why and how to improve it: Missing/Insufficient Information:
Recommendations for Improvement:
By addressing these points, you will significantly improve the quality of your PR and increase its chances of being accepted. A clear, well-documented PR makes the reviewer's job much easier and demonstrates your understanding of the codebase and the impact of your changes. |
@@ -2144,6 +2144,25 @@ static int stm32_i2c_init(struct stm32_i2c_priv_s *priv) | |||
modifyreg32(STM32_RCC_APB1RSTR, 0, priv->config->reset_bit); | |||
modifyreg32(STM32_RCC_APB1RSTR, priv->config->reset_bit, 0); | |||
|
|||
/* Configure clock source to HSI */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should go to stm32g4xxxx_rcc.c file where other CCIPR related config is done
@@ -2706,9 +2725,19 @@ struct i2c_master_s *stm32_i2cbus_initialize(int port) | |||
struct stm32_i2c_priv_s *priv = NULL; /* private data of device with multiple instances */ | |||
struct stm32_i2c_inst_s *inst = NULL; /* device, single instance */ | |||
|
|||
#if STM32_HSI_FREQUENCY != 8000000 || defined(INVALID_CLOCK_SOURCE) | |||
# warning STM32_I2C_INIT: Peripheral clock is HSI and it must be 16mHz or the speed/timing calculations need to be redone. | |||
#if defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you move all these warnings to Pre-processor Definitions
section (somewhere under line 250) ?
Note: Please adhere to Contributing Guidelines.
Summary
According to the documentation of the file arch/arm/src/stm32/stm32_i2c_v2.c, the driver supports, as a clock source, only STM32_HSI_FREQUENCY = 16 MHz. In fact, the function stm32_i2c_setclock adjusts the STM32_I2C1_TIMINGR register considering fI2CCLK at 16 MHz. However, the function stm32_i2cbus_initialize returns NULL if STM32_HSI_FREQUENCY != 8000000. Thus, in my understanding, the function stm32_i2c_setclock is not adjusting the bus frequency correctly. Furthermore, no clock source verification is performed.
This patch modifies the I2C driver to allow devices in the STM32G4 family to function correctly. The driver's behavior has not been modified for devices in the STM32_STM32F30XX, STM32_STM32F33XX, and STM32_STM32F37XX families, although I believe the driver is not functioning properly.
Impact
No impact is expected
Testing
This changes was tested on STM32G474.