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

nRF52: GPIO: Assert that init succeeds #15189

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

boraozgen
Copy link
Contributor

Summary of changes

The issue with number of input interrupts was not fixed properly in #11622. If more InterruptIns are defined than configured with NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS, the initialization failed silently and the additional inputs did not work. This change asserts that the initialization succeeds, so that the issue is at least visible to the developer.

Impact of changes

Migration actions required

Documentation

None


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

[X] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label Dec 9, 2021
@ciarmcom ciarmcom requested a review from a team December 9, 2021 16:00
@ciarmcom
Copy link
Member

ciarmcom commented Dec 9, 2021

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

0xc0170
0xc0170 previously approved these changes Dec 13, 2021
@0xc0170
Copy link
Contributor

0xc0170 commented Dec 13, 2021

CI started

@mergify mergify bot added needs: CI and removed needs: review labels Dec 13, 2021
@mbed-ci
Copy link

mbed-ci commented Dec 13, 2021

Jenkins CI Test : ❌ FAILED

Build Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test

@mergify mergify bot added needs: work and removed needs: CI labels Dec 13, 2021
@0xc0170
Copy link
Contributor

0xc0170 commented Dec 13, 2021

The failures look related, hal-tests-tests-mbed_hal_fpga_ci_test_shield-gpio_irq fails for NRF52 with fpga shield.

Are we hitting the assert (too many irq inputs under tests for this platform) ?

@boraozgen
Copy link
Contributor Author

Probably they hit the assert, but I'm not sure if the number of inputs is the reason, as the tests were working before, the inputs must have worked properly. Maybe the function returns another code in some cases, it is hard to tell.

I'll try to look into it, but we could drop this PR if it continues to fail and make sure that the configuration is documented properly.

@mergify mergify bot dismissed 0xc0170’s stale review December 14, 2021 09:02

Pull request has been modified.

@boraozgen
Copy link
Contributor Author

It seems that the init functions are returning NRFX_ERROR_INVALID_STATE in case the pin is already used. This might be the issue. I changed the assert so that it checks for the actual error which is received when the number of inputs exceed the configuration.

/**
* @brief Function for initializing a GPIOTE input pin.
* @details The input pin can act in two ways:
* - lower accuracy but low power (high frequency clock not needed)
* - higher accuracy (high frequency clock required)
*
* The initial configuration specifies which mode is used.
* If high-accuracy mode is used, the driver attempts to allocate one
* of the available GPIOTE channels. If no channel is
* available, an error is returned.
* In low accuracy mode SENSE feature is used. In this case only one active pin
* can be detected at a time. It can be worked around by setting all of the used
* low accuracy pins to toggle mode.
* For more information about SENSE functionality, refer to Product Specification.
*
* @param[in] pin Pin.
* @param[in] p_config Initial configuration.
* @param[in] evt_handler User function to be called when the configured transition occurs.
*
* @retval NRFX_SUCCESS If initialization was successful.
* @retval NRFX_ERROR_INVALID_STATE If the driver is not initialized or the pin is already used.
* @retval NRFX_ERROR_NO_MEM If no GPIOTE channel is available.
*/
nrfx_err_t nrfx_gpiote_in_init(nrfx_gpiote_pin_t pin,
nrfx_gpiote_in_config_t const * p_config,
nrfx_gpiote_evt_handler_t evt_handler);

@mbed-ci
Copy link

mbed-ci commented Dec 14, 2021

Jenkins CI Test : ✔️ SUCCESS

Build Number: 2 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@0xc0170 0xc0170 merged commit 7a6262c into ARMmbed:master Dec 15, 2021
@mergify mergify bot removed the ready for merge label Dec 15, 2021
@mbedmain mbedmain added release-version: 6.16.0 Release-pending and removed release-type: patch Indentifies a PR as containing just a patch Release-pending labels Jun 14, 2022
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.

None yet

5 participants