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

[stm32] safe gpio toggle #337

Closed
wants to merge 3 commits into from
Closed

Conversation

nuft
Copy link
Contributor

@nuft nuft commented Jul 16, 2014

With this change, gpio_toggle() wont't affect in any case the state of the non-toggled GPIOs.
This makes toggling GPIOs more safe, if pins of the same port are used in interrupts.

@BuFran
Copy link
Member

BuFran commented Jul 17, 2014

Bug: if the pin will be toggled in the interrupt routine, in between reading ODR and setting BSRR, the toggle will be missed.

But I agree that this code will not change other bits. In current situation, when ISR occurs inside read-modify-write operation of the XOR, and other bit of the same port is changed in the isr, the value will be overwritten by result of xor with old value of register, undoing the change that was made in the isr.

The probability of miss of toggle of specified pin is higher than probability of reset another bit, due to more operations in between read-write operations. But for me, miss of toggle is better than miss of change to the port made in another part of code, because of locality of the bug so 👍 for me.

This commit should go soon after it will be tested on blinky example.

Conflicts:
	lib/stm32/f3/gpio.c
@BuFran
Copy link
Member

BuFran commented Oct 7, 2014

👍 for squished first two commits, 👎 for the merge with LM4F modifications

@nuft
Copy link
Contributor Author

nuft commented Oct 7, 2014

👎 for the merge with LM4F modifications

So should I open a new PR and close this one?

@karlp
Copy link
Member

karlp commented Oct 7, 2014

No, bufran, it's just the merge process looking funky. It's only a single clean commit after rebasing. Merged via rebase in: 50dd1c5

@karlp karlp closed this Oct 7, 2014
flixr added a commit to paparazzi/paparazzi that referenced this pull request Nov 6, 2014
to get updates from libopencm3 and remove our own workarounds for:
- STM32F4 25Mhz clock: libopencm3/libopencm3#311
- STM32 defines for TIM9-TIM17: libopencm3/libopencm3#350
- STM32 set I2C address: libopencm3/libopencm3#344

additionally get fixes:
- STM32 safe gpio toggle: libopencm3/libopencm3#337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants