Atomicity in GPIO pin changes


Jon Medhurst (Tixy) <tixy@...>
 

Hi

I have a hardware register I want to change individual bits in as they
are used for different purposes on my SoC. I thought the GPIO APIs might
be the correct abstraction to represent that, and even if that wasn't
suitable I thought I could at least look at those to work out how
atomicity of updates is achieved (Zephyr doesn't seem to have spinlocks,
and mutexes and the like seem a bit heavyweight for the task, ...).

However, looking at the GPIO API's and various implementations I can't
spot anything that serialises register updates, it just seems to boil
down to an unsafe "port |= (1 << bit_to_set)" or similar. Have I missed
things or is it expected that all users of a given port agree on a
mutual exclusion method? That doesn't seem very practical if they are
each different drivers or apps with no real need to know of each others
existence.

--
Tixy

Join devel@lists.zephyrproject.org to automatically receive all group messages.