Step 4: Setting register bits
The registers have some names that are specified in the datasheet depending on their meanings, like ADCSRA for the ADC Setting Register A. Also each meaningful bit of the registers has a name, like ADEN for the ADC Enable Bit in the ADCSRA register.
To set their bits we could use the usual C syntax for binary algebra, but I found on the internet a couple of macros that are very nice and clean:
// Defines for setting and clearing register bits
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
Using them is very simple, if we want to set to 1 the Enable Bit of the ADC we can just write:
While if we want to set it to 0 (id est clear it) we can just write: