I would like to know where the actual registers is setup.
This is a small snippet of code in "wiring_analog.c"
Code: Select all
#if defined(HAL_ADC_MODULE_ENABLED) && !defined(HAL_ADC_MODULE_ONLY)
PinName p = analogInputToPinName(ulPin);
if (p != NC) {
value = adc_read_value(p, _internalReadResolution);
value = mapResolution(value, _internalReadResolution, _readResolution);
}
#else
UNUSED(ulPin);
#endif
return value;
}
Like in the sample below.
Code: Select all
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN | // Enable clock to GPIO port C
RCC_AHB1ENR_DMA1EN; // Enable DMA1
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; // Enable clock to TIM2 timer
GPIOC->MODER |= GPIO_MODER_MODER0_1; // Set D8 (PC0) as alterntive function
GPIOC->AFR[0] |= GPIO_AFRL_AFSEL0_0;