-
Notifications
You must be signed in to change notification settings - Fork 3k
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
STM32: driver/Added I2C timing calculation algorithm #14557
STM32: driver/Added I2C timing calculation algorithm #14557
Conversation
@affrinpinhero-2356, thank you for your changes. |
51c964f
to
daa52c5
Compare
@ARMmbed/team-st-mcd please review |
daa52c5
to
cdba4b6
Compare
@@ -34,31 +42,14 @@ extern "C" { | |||
#define I2CAPI_I2C3_CLKSRC RCC_I2C3CLKSOURCE_SYSCLK | |||
|
|||
/* Provide the suitable timing depending on requested frequency */ |
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.
is the comment still correct if the function was removed?
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.
@0xc0170 This can be removed. I have somehow missed.
uint32_t I2C_ComputeTiming(uint32_t clock_src_freq, uint32_t i2c_freq); | ||
uint32_t get_i2c_timing(I2CName i2c, int hz); | ||
void I2C_Compute_PRESC_SCLDEL_SDADEL(uint32_t clock_src_freq, uint32_t I2C_speed); | ||
uint32_t I2C_Compute_SCLL_SCLH(uint32_t clock_src_freq, uint32_t I2C_speed); |
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.
The function declarations using camelcase or just as the rest of HAL only lower case, can we unify them?
I assume i2c_get_pclk() or if you want to keep this different from Mbed OS HAL, you can add a prefix for instance.
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.
@0xc0170 I think its better to change all to **camelCase**
format.
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.
@0xc0170 This will be applicable for all files rite.
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.
@0xc0170 I have modified function name to below mentioned. Hope this will make it unique. Update me if this is okay.
uint32_t get_i2c_pclk(I2CName i2c);
uint32_t i2c_compute_timing(uint32_t clock_src_freq, uint32_t i2c_freq);
uint32_t get_i2c_timing(I2CName i2c, int hz);
void i2c_compute_Presc_Scldel_Sdadel(uint32_t clock_src_freq, uint32_t I2C_speed);
uint32_t i2c_compute_Scll_Sclh(uint32_t clock_src_freq, uint32_t I2C_speed);
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.
i2c_device.h
belongs to HAL implementation? similar to i2c_api.c so it should be consistent with the naming. Mbed OS style guide specifies to use lower case with _
as a separator for function/methods names
If this is the case (this is HAL implementation), ti would be:
uint32_t i2c_compute_timing(uint32_t clock_src_freq, uint32_t i2c_freq);
uint32_t i2c_get_timing(I2CName i2c, int hz);
void i2c_compute_presc_scldel_sdadel(uint32_t clock_src_freq, uint32_t i2c_speed);
uint32_t i2c_compute_scll_sclh(uint32_t clock_src_freq, uint32_t i2c_speed);
cdba4b6
to
ac6b7d5
Compare
CI started |
Jenkins CI Test : ❌ FAILEDBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Let's restart CI ? |
CI started |
Jenkins CI Test : ❌ FAILEDBuild Number: 4 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Yes, new files have not been added in the CMakeLists.txt |
I found there are n number of cmaks. And I was confused which one should I need to update. |
For ex targets/TARGET_STM/TARGET_STM32F0/i2c_device.c has to be added in etc |
Oh okay thanks. ☺ |
This commit adds I2C timing value automatic calculation algorithm for all supported families added. This patch improves I2C timing calculation according to I2C input clock and I2C bus speed. This commit also allows user to change the system clock and I2C input clock. Related issue: ARMmbed#12907 Pull request type: [x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor) [] Feature update (New feature / Functionality change / New API) [] Major update (Breaking change E.g. Return code change / API behaviour change) Test results: [] No Tests required for this change (E.g docs only update) [x] Covered by existing mbed-os tests (Greentea or Unittest) [] Tests / results supplied as part of this PR Signed-off-by: Affrin Pinhero <affrin.pinhero@hcl.com>
57a390d
to
d974b47
Compare
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.
Let's restart CI ?
CI restarted |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 5 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
This PR does not contain release version label after merging. |
Summary of changes
This patch improves I2C timing calculation by adding features of calculating timing value according to I2C input clock and I2C bus speed.
Current modification helps user to change the system clock and I2C input clock.
Pull request type
[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)
Test results