I want to do some bitwise manipulation on GPIO result, suppose I have three variables to define whether the state of some GPIO devices are on or off:
mask : 1 means bit is set, and need to be calculate
value : real gpio value 0 / 1
active_level; : 1 means high active, 0 means low active
suppose I have:
mask : 0010 0001
value : 0000 0001
active: 0000 0001
is there any good way (at this moment I'm thinking about looping) to get the result based on the active level? in above case, bit0 is active high and bit5 is active low, and since bit0 value is high and bit 5 is low, thus the result is:
result: 0010 0001
later on, what I want to do is to check whether result == mask, if yes means GPIO devices state is on (e.g two buttons are pressed together)
Thanks