No description
Find a file
Florian Vaussard 632a07d987 gpio: stm32: Use atomic set/reset in stm32_gpio_set()
The current implementation of stm32_gpio_set() uses the GPIO output data
register to change the state of individual GPIOs. The generated
assembler needs at least 3 instructions: load / modify / store.

This opens a small race window, for example if a thread and an
interrupt both try to change the state of the same GPIO bank.

Use the GPIO bit set/reset register to perform the atomic change without
locking.

This also has the benefit of a more optimised implementation, which can
be useful for GPIO-intensive work. Compare the new version:

08000c98 <stm32_gpio_set>:
 8000c98:       f001 010f       and.w   r1, r1, #15
 8000c9c:       2301            movs    r3, #1
 8000c9e:       b902            cbnz    r2, 8000ca2 <stm32_gpio_set+0xa>
 8000ca0:       3110            adds    r1, #16
 8000ca2:       408b            lsls    r3, r1
 8000ca4:       6183            str     r3, [r0, #24]
 8000ca6:       2000            movs    r0, #0
 8000ca8:       4770            bx      lr

and the old one:

08000c98 <stm32_gpio_set>:
 8000c98:       2301            movs    r3, #1
 8000c9a:       f001 010f       and.w   r1, r1, #15
 8000c9e:       fa03 f101       lsl.w   r1, r3, r1
 8000ca2:       6943            ldr     r3, [r0, #20]
 8000ca4:       b10a            cbz     r2, 8000caa <stm32_gpio_set+0x12>
 8000ca6:       4319            orrs    r1, r3
 8000ca8:       e001            b.n     8000cae <stm32_gpio_set+0x16>
 8000caa:       ea23 0101       bic.w   r1, r3, r1
 8000cae:       6141            str     r1, [r0, #20]
 8000cb0:       2000            movs    r0, #0
 8000cb2:       4770            bx      lr

Change-Id: Ie5800d1c345016028d1b9a099f5d74cac35f592a
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-03-27 09:05:57 -05:00
.known-issues net/mgmt: Add a function to wait on a event synchronously 2017-03-17 10:34:42 +02:00
arch gpio: stm32: Use atomic set/reset in stm32_gpio_set() 2017-03-27 09:05:57 -05:00
boards boards: add 96b_nitrogen board documentation 2017-03-27 09:05:57 -05:00
doc doc: fix installation on windows instructions 2017-03-25 12:36:14 +00:00
drivers arm: UART driver modifications for MKL25Z soc support 2017-03-27 09:05:57 -05:00
dts dts: arm: Add base DTS support for Olimexino STM32 board 2017-03-27 09:05:57 -05:00
ext spi: mcux: Rename spi driver to DSPI to match naming convention 2017-03-27 09:05:57 -05:00
include Merge "Merge bluetooth branch into master" 2017-03-25 11:25:43 +00:00
kernel kernel: arm: Increase idle stack size to fix corruption by FP_SHARING 2017-03-27 09:05:57 -05:00
lib lib: json: Fix parsing of boolean values 2017-03-25 13:11:55 +00:00
misc misc: Let the compiler choose whether to omit frame pointer 2017-02-08 13:14:16 +00:00
samples samples: grove: remove duplicate config 2017-03-26 02:10:24 +00:00
scripts scripts/dfuutil: add support for DfuSe devices 2017-03-22 20:59:07 -03:00
subsys Merge "Merge bluetooth branch into master" 2017-03-25 11:25:43 +00:00
tests test/crypto: Update ECC DSA test case 2017-03-25 15:42:13 +00:00
.checkpatch.conf checkpatch: Remove reference to legacy IP stack 2017-02-08 13:05:27 +00:00
.gitattributes First commit 2015-04-10 16:44:37 -07:00
.gitignore doc: tweak .gitignore to allow doc theme dev 2017-02-23 13:20:04 +00:00
.gitreview Add a .gitreview file 2016-02-20 14:25:01 +00:00
.mailmap mailmap: added axy (for Anas Nashif) 2016-12-21 13:49:59 +00:00
defaults.tc testcases: catch more fatal kernel error messages 2016-11-11 13:21:16 +00:00
Kbuild frdm: fixed path and dependencies for extract_dts_includes.py 2017-02-22 13:57:52 +00:00
Kconfig license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
Kconfig.zephyr license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
LICENSE add top level Apache 2.0 license file 2016-02-05 20:24:37 -05:00
MAINTAINERS MAINTAINERS: update mantainers 2017-03-02 21:47:40 +00:00
Makefile build: Add support for MSYS2 2017-03-17 17:34:56 +01:00
Makefile.inc Revert "build: Fix qemugdb target" 2017-03-09 09:22:51 +00:00
Makefile.test tests: introduce Makefile.test 2017-01-03 17:48:44 +00:00
zephyr-env.sh build: Add support for MSYS2 2017-03-17 17:34:56 +01:00