bit_manipulation_101
Table des matières
Bit Manipulation 101
OR
pour mettre un bit a 1
X | 0 = X X | 1 = 1
AND
pour mettre un bit a 0
X & 0 = 0 X & 1 = X
SNIPPETS
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
FLAG
uint8_t FLAGS = 0; #define F_f1 0 #define F_f2 1 #define F_f3 2 #define F_f4 3 sbi(FLAGS,f1) //Set FLAG if (FLAGS & _BV(F_f1)) //si flag ON if (!(FLAGS & _BV(F_f2))) //si flag OFF cbi(FLAGS,F_f1) //Clear Flag
bit_manipulation_101.txt · Dernière modification : 2021/05/10 07:24 de ptitfrap