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

Fixed pin ownership checks for I2C. #9810

Merged
merged 1 commit into from May 27, 2020

Conversation

mikeller
Copy link
Member

Fixes #9806.

This fixes the problem that currently, IOInit() does not check if a pin is already used (i.e. has an owner assigned) before setting the owner. This leads to cases where a pin is successfully assigned and a pin function started, but then the pin gets re-assigned to a different function, leaving artefacts:

Setup:

# resource

[...]

resource MOTOR 4 C09

[...]

resource I2C_SDA 3 C09

[...]

Before:

# resource show all

[...]

C09: I2C_SDA 3

[...]

Currently active Timers:
-----------------------
TIM1: FREE
TIM2: FREE
TIM3:
    CH1: MOTOR 1
TIM4: FREE
TIM5: FREE
TIM6: FREE
TIM7: FREE
TIM8:
    CH2: MOTOR 2
    CH3: MOTOR 3
    CH4: MOTOR 4

Currently active DMA:
--------------------
DMA1 Stream 0: FREE
DMA1 Stream 1: FREE
DMA1 Stream 2: TIMUP 3
DMA1 Stream 3: FREE
DMA1 Stream 4: FREE
DMA1 Stream 5: FREE
DMA1 Stream 6: FREE
DMA1 Stream 7: FREE
DMA2 Stream 0: ADC 1
DMA2 Stream 1: TIMUP 8
DMA2 Stream 2: FREE
DMA2 Stream 3: FREE
DMA2 Stream 4: FREE
DMA2 Stream 5: FREE
DMA2 Stream 6: FREE
DMA2 Stream 7: FREE

After:

# resource show all

[...]

C09: MOTOR 4

[...]

Currently active Timers:
-----------------------
TIM1: FREE
TIM2: FREE
TIM3:
    CH1: MOTOR 1
TIM4: FREE
TIM5: FREE
TIM6: FREE
TIM7: FREE
TIM8:
    CH2: MOTOR 2
    CH3: MOTOR 3
    CH4: MOTOR 4

Currently active DMA:
--------------------
DMA1 Stream 0: FREE
DMA1 Stream 1: FREE
DMA1 Stream 2: TIMUP 3
DMA1 Stream 3: FREE
DMA1 Stream 4: FREE
DMA1 Stream 5: FREE
DMA1 Stream 6: FREE
DMA1 Stream 7: FREE
DMA2 Stream 0: ADC 1
DMA2 Stream 1: TIMUP 8
DMA2 Stream 2: FREE
DMA2 Stream 3: FREE
DMA2 Stream 4: FREE
DMA2 Stream 5: FREE
DMA2 Stream 6: FREE
DMA2 Stream 7: FREE

This is just one fix to solve a problem that is currently breaking configurations for users. A comprehensive switch to replace IOInit() with functionality that checks resource ownership is needed, and is currently work in progress, to be added after 4.2 has been released.

Also removing a duplicate RCC_ClockCmd() line.

Test firmware:

betaflight_4.2.0_STM32F745_37209b4826.zip
betaflight_4.2.0_STM32F7X2_37209b4826.zip
betaflight_4.2.0_STM32F411_37209b4826.zip
betaflight_4.2.0_STM32F405_37209b4826.zip

(installation instructions: youtu.be/I1uN9CN30gw)

@mikeller mikeller merged commit 23a9ea4 into betaflight:master May 27, 2020
@mikeller mikeller deleted the fix_i2c_pin_ownership_check branch May 27, 2020 13:18
@mikeller mikeller modified the milestones: 4.2, 4.1.7 May 28, 2020
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.

Matek F405-STD - I2C 3 Unified Target Change - Motor 4 Not Spinning
2 participants