Skip to content

Instantly share code, notes, and snippets.

@benjcal
Last active November 1, 2017 15:41
Show Gist options
  • Save benjcal/91eaf40c617d3288281aaf8022d551e9 to your computer and use it in GitHub Desktop.
Save benjcal/91eaf40c617d3288281aaf8022d551e9 to your computer and use it in GitHub Desktop.
// Credits: https://github.com/hexagon5un/AVR-Programming/blob/master/AVR-Programming-Library/macros.h
#define BV(bit) (1 << bit)
#define set_bit(sfr, bit) (_SFR_BYTE(sfr) |= BV(bit)) // old sbi()
#define clear_bit(sfr, bit) (_SFR_BYTE(sfr) &= ~BV(bit)) // old cbi()
#define toggle_bit(sfr, bit) (_SFR_BYTE(sfr) ^= BV(bit))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment