Skip to content

Instantly share code, notes, and snippets.

@phardy
Created November 18, 2014 10:08
Show Gist options
  • Select an option

  • Save phardy/57d53f38873ab948f6eb to your computer and use it in GitHub Desktop.

Select an option

Save phardy/57d53f38873ab948f6eb to your computer and use it in GitHub Desktop.
rising-edge latching of bit field
void controlGroupLatch() {
uint16_t mask;
uint16_t state = controlGroupToggle[0];
// Only care about the first mux bank at the moment
mask = ~lastMuxState[0] & muxState[0]; // Mask of all changed inputs
mask = mask & muxState[0]; // Mask of changed inputs that are now high
state = state ^ mask; // Apply mask to toggle state
controlGroupToggle[0] = state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment