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

Fix STM32 radio driver when bandwidth is 0 #15217

Merged
merged 1 commit into from
Feb 7, 2022

Conversation

LukaB
Copy link
Contributor

@LukaB LukaB commented Jan 31, 2022

Summary of changes

A bug was detected when the uint8_t SUBGRF_GetFskBandwidthRegValue( uint32_t bandwidth )
is called and the bandwidth argument has a value of 0.

Comparing the code to the STMCubeWL 1.1 we can see that an if statement is missing to
address the condition where bandwidth is equal to 0.

Added the if statement to the radio driver to account for this edge case to prevent entering while (1) loop.

Impact of changes

Migration actions required

Documentation

None required.
But to replicate, I was using AS923-1, and then set my Gateway to have a maximum allowed data rate of DR_7.
The mBed device connected and quickly maxed out to DR_7 at which point the above function as called with bandwidth == 0.

Code from radio_driver.c (Line 1143):

uint8_t SUBGRF_GetFskBandwidthRegValue( uint32_t bandwidth )
{
    uint8_t i;

    if( bandwidth == 0 )
    {
        return( 0x1F );
    }

    /* ST_WORKAROUND_BEGIN: Simplified loop */
    for( i = 0; i < ( sizeof( FskBandwidths ) / sizeof( FskBandwidth_t ) ); i++ )
    {
        if ( bandwidth < FskBandwidths[i].bandwidth )
        {
            return FskBandwidths[i].RegValue;
        }
    }
    /* ST_WORKAROUND_END */
    // ERROR: Value not found
    while( 1 );
}

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

Reviewers

@jeromecoutant @hallard


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.

@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label Jan 31, 2022
@ciarmcom ciarmcom requested review from jeromecoutant and a team January 31, 2022 08:30
@ciarmcom
Copy link
Member

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

@mergify mergify bot dismissed 0xc0170’s stale review February 1, 2022 06:42

Pull request has been modified.

@LukaB LukaB requested a review from 0xc0170 February 1, 2022 06:42
A bug was detected when the uint8_t SUBGRF_GetFskBandwidthRegValue( uint32_t bandwidth )
is called and the bandwith argument has a value of 0.

Comparing the code to the STMCubeWL 1.1 we can see that an if statement is missing to
address the condition where bandwith is equal to 0.

Added the if statement to the radio driver to account for this edge case.
@mergify mergify bot added needs: CI and removed needs: work labels Feb 7, 2022
@mbed-ci
Copy link

mbed-ci commented Feb 7, 2022

Jenkins CI Test : ✔️ SUCCESS

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_unittests ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@0xc0170 0xc0170 merged commit 835b274 into ARMmbed:master Feb 7, 2022
@mergify mergify bot removed the ready for merge label Feb 7, 2022
@LukaB LukaB deleted the fix-STM32WL-radio-driver branch February 7, 2022 19:05
@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

6 participants