I'm working on a port of libmaple for the STM32L1 for a dev board I'm working on, and I'm running into some mystery hex values in the header files that I can't make heads or tails of. For example, the definitions for Configuration Register 2 in adc.h:
#define ADC_CR2_ADON BIT(ADC_CR2_ADON_BIT)
#define ADC_CR2_CONT BIT(ADC_CR2_CONT_BIT)
#define ADC_CR2_CAL BIT(ADC_CR2_CAL_BIT)
#define ADC_CR2_RSTCAL BIT(ADC_CR2_RSTCAL_BIT)
#define ADC_CR2_DMA BIT(ADC_CR2_DMA_BIT)
#define ADC_CR2_ALIGN BIT(ADC_CR2_ALIGN_BIT)
#define ADC_CR2_JEXTSEL (0x7000)
#define ADC_CR2_JEXTTRIG BIT(ADC_CR2_JEXTTRIG_BIT)
#define ADC_CR2_EXTSEL (0xE0000)
#define ADC_CR2_EXTTRIG BIT(ADC_CR2_EXTTRIG_BIT)
#define ADC_CR2_JSWSTART BIT(ADC_CR2_JSWSTART_BIT)
#define ADC_CR2_SWSTART BIT(ADC_CR2_SWSTART_BIT)
#define ADC_CR2_TSEREFE BIT(ADC_CR2_TSEREFE_BIT)
EXTSEL and JEXTSEL are multi-bit settings so I understand why it wouldn't be a single bitshift, but where are those values coming from? In this case, they're both 3-bit values. The sample time registers are all 3-bit values as well, but they're all defined like this (which does make sense):
#define ADC_SMPR1_SMP17 (0x7 << 21)
#define ADC_SMPR1_SMP16 (0x7 << 18)
#define ADC_SMPR1_SMP15 (0x7 << 15)
#define ADC_SMPR1_SMP14 (0x7 << 12)
#define ADC_SMPR1_SMP13 (0x7 << 9)
#define ADC_SMPR1_SMP12 (0x7 << 6)
#define ADC_SMPR1_SMP11 (0x7 << 3)
#define ADC_SMPR1_SMP10 0x7