Skip to content

Fix for i2c_t object not being initialized to 0 causing timeout #9895

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

Merged
merged 1 commit into from
Mar 14, 2019

Conversation

mrcoulter45
Copy link
Contributor

@mrcoulter45 mrcoulter45 commented Feb 28, 2019

Fix for issue #9890

Description

Fix problem where i2c_t not being initialized was causing i2c_init timeout.

Tested locally with two targets and with GCC_ARM and ARM toolchains.

Pull request type

[X] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@jeromecoutant
@LMESTM

@ciarmcom
Copy link
Member

@mrcoulter45, thank you for your changes.
@screamerbg @ARMmbed/mbed-os-maintainers please review.

@@ -261,6 +261,7 @@ void i2c_sw_reset(i2c_t *obj)
void i2c_init(i2c_t *obj, PinName sda, PinName scl)
{

memset(obj, 0, sizeof(*obj));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry but i2c_init is also used internally in several places in this file in order to reset the IP in case of communication issues. When resetting the IP, we don't want to lose the current frequency.
That's why we actually check the value of obj_s->hz

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok yes good catch, I'll post an alternate fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated PR

@mrcoulter45 mrcoulter45 force-pushed the issue-9890-fix branch 2 times, most recently from 6ce43f5 to 8f06cb6 Compare March 1, 2019 17:23
@LMESTM
Copy link
Contributor

LMESTM commented Mar 5, 2019

@mrcoulter45 looks good to me.
@jeromecoutant - could we start a test non regression session around CI test shield / I2C ?


void i2c_init_internal(i2c_t *obj, PinName sda, PinName scl)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think you may need to declare this function at the beginning of the file (might be a static one).
Seems to fail building with a few toolchains

@mrcoulter45 mrcoulter45 force-pushed the issue-9890-fix branch 2 times, most recently from 0988beb to 66e8e05 Compare March 5, 2019 17:32
@mrcoulter45
Copy link
Contributor Author

Updated PR

Copy link
Collaborator

@jeromecoutant jeromecoutant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ST CI OK:

target platform_name test suite result elapsed_time (sec) copy_method
NUCLEO_F091RC-ARM NUCLEO_F091RC tests-api-i2c OK 19.9 default
NUCLEO_F091RC-ARM NUCLEO_F091RC tests-assumptions-i2c OK 17.39 default
NUCLEO_F091RC-GCC_ARM NUCLEO_F091RC tests-api-i2c OK 22.37 default
NUCLEO_F091RC-GCC_ARM NUCLEO_F091RC tests-assumptions-i2c OK 17.8 default
NUCLEO_F091RC-IAR NUCLEO_F091RC tests-api-i2c OK 19.78 default
NUCLEO_F091RC-IAR NUCLEO_F091RC tests-assumptions-i2c OK 16.69 default
NUCLEO_F103RB-ARM NUCLEO_F103RB tests-api-i2c OK 20.51 default
NUCLEO_F103RB-ARM NUCLEO_F103RB tests-assumptions-i2c OK 17.35 default
NUCLEO_F103RB-GCC_ARM NUCLEO_F103RB tests-api-i2c OK 21.48 default
NUCLEO_F103RB-GCC_ARM NUCLEO_F103RB tests-assumptions-i2c OK 17.99 default
NUCLEO_F103RB-IAR NUCLEO_F103RB tests-api-i2c OK 20.28 default
NUCLEO_F103RB-IAR NUCLEO_F103RB tests-assumptions-i2c OK 16.82 default
NUCLEO_F207ZG-ARM NUCLEO_F207ZG tests-api-i2c OK 19.22 default
NUCLEO_F207ZG-ARM NUCLEO_F207ZG tests-assumptions-i2c OK 16.55 default
NUCLEO_F207ZG-GCC_ARM NUCLEO_F207ZG tests-api-i2c OK 20.8 default
NUCLEO_F207ZG-GCC_ARM NUCLEO_F207ZG tests-assumptions-i2c OK 17.67 default
NUCLEO_F207ZG-IAR NUCLEO_F207ZG tests-api-i2c OK 18.61 default
NUCLEO_F207ZG-IAR NUCLEO_F207ZG tests-assumptions-i2c OK 16.05 default
NUCLEO_F303ZE-ARM NUCLEO_F303ZE tests-api-i2c OK 19.95 default
NUCLEO_F303ZE-ARM NUCLEO_F303ZE tests-assumptions-i2c OK 16.82 default
NUCLEO_F303ZE-GCC_ARM NUCLEO_F303ZE tests-api-i2c OK 20.81 default
NUCLEO_F303ZE-GCC_ARM NUCLEO_F303ZE tests-assumptions-i2c OK 18.3 default
NUCLEO_F303ZE-IAR NUCLEO_F303ZE tests-api-i2c OK 19.49 default
NUCLEO_F303ZE-IAR NUCLEO_F303ZE tests-assumptions-i2c OK 16.27 default
NUCLEO_F446RE-ARM NUCLEO_F446RE tests-api-i2c OK 18.36 default
NUCLEO_F446RE-ARM NUCLEO_F446RE tests-assumptions-i2c OK 15.77 default
NUCLEO_F446RE-GCC_ARM NUCLEO_F446RE tests-api-i2c OK 19.31 default
NUCLEO_F446RE-GCC_ARM NUCLEO_F446RE tests-assumptions-i2c OK 16.41 default
NUCLEO_F446RE-IAR NUCLEO_F446RE tests-api-i2c OK 18.66 default
NUCLEO_F446RE-IAR NUCLEO_F446RE tests-assumptions-i2c OK 15.66 default
NUCLEO_F767ZI-ARM NUCLEO_F767ZI tests-api-i2c OK 18.5 default
NUCLEO_F767ZI-ARM NUCLEO_F767ZI tests-assumptions-i2c OK 15.69 default
NUCLEO_F767ZI-GCC_ARM NUCLEO_F767ZI tests-api-i2c OK 18.91 default
NUCLEO_F767ZI-GCC_ARM NUCLEO_F767ZI tests-assumptions-i2c OK 16.26 default
NUCLEO_F767ZI-IAR NUCLEO_F767ZI tests-api-i2c OK 18.06 default
NUCLEO_F767ZI-IAR NUCLEO_F767ZI tests-assumptions-i2c OK 15.52 default
NUCLEO_H743ZI-ARM NUCLEO_H743ZI tests-api-i2c OK 22.29 default
NUCLEO_H743ZI-ARM NUCLEO_H743ZI tests-assumptions-i2c OK 15.72 default
NUCLEO_H743ZI-GCC_ARM NUCLEO_H743ZI tests-api-i2c OK 18.5 default
NUCLEO_H743ZI-GCC_ARM NUCLEO_H743ZI tests-assumptions-i2c OK 16.05 default
NUCLEO_H743ZI-IAR NUCLEO_H743ZI tests-api-i2c OK 18.22 default
NUCLEO_H743ZI-IAR NUCLEO_H743ZI tests-assumptions-i2c OK 15.62 default
NUCLEO_L073RZ-ARM NUCLEO_L073RZ tests-api-i2c OK 21.87 default
NUCLEO_L073RZ-ARM NUCLEO_L073RZ tests-assumptions-i2c OK 19.09 default
NUCLEO_L073RZ-GCC_ARM NUCLEO_L073RZ tests-api-i2c OK 24.69 default
NUCLEO_L073RZ-GCC_ARM NUCLEO_L073RZ tests-assumptions-i2c OK 20.76 default
NUCLEO_L073RZ-IAR NUCLEO_L073RZ tests-api-i2c OK 23.9 default
NUCLEO_L073RZ-IAR NUCLEO_L073RZ tests-assumptions-i2c OK 23.9 default
NUCLEO_L152RE-ARM NUCLEO_L152RE tests-api-i2c OK 19.53 default
NUCLEO_L152RE-ARM NUCLEO_L152RE tests-assumptions-i2c OK 16.44 default
NUCLEO_L152RE-GCC_ARM NUCLEO_L152RE tests-api-i2c OK 20.44 default
NUCLEO_L152RE-GCC_ARM NUCLEO_L152RE tests-assumptions-i2c OK 17.46 default
NUCLEO_L152RE-IAR NUCLEO_L152RE tests-api-i2c OK 19.58 default
NUCLEO_L152RE-IAR NUCLEO_L152RE tests-assumptions-i2c OK 16.6 default
NUCLEO_L476RG-ARM NUCLEO_L476RG tests-api-i2c OK 19.47 default
NUCLEO_L476RG-ARM NUCLEO_L476RG tests-assumptions-i2c OK 16.22 default
NUCLEO_L476RG-GCC_ARM NUCLEO_L476RG tests-api-i2c OK 19.73 default
NUCLEO_L476RG-GCC_ARM NUCLEO_L476RG tests-assumptions-i2c OK 16.8 default
NUCLEO_L476RG-IAR NUCLEO_L476RG tests-api-i2c OK 19.0 default
NUCLEO_L476RG-IAR NUCLEO_L476RG tests-assumptions-i2c OK 16.13 default

60 OK

Copy link
Contributor

@LMESTM LMESTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @mrcoulter45

@0xc0170
Copy link
Contributor

0xc0170 commented Mar 8, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Mar 9, 2019

Test run: SUCCESS

Summary: 13 of 13 test jobs passed
Build number : 1
Build artifacts

@0xc0170 0xc0170 merged commit 897d15a into ARMmbed:master Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants