I am using the ST32 I-cube example code and trying to initiate the ADC with the following code:
ADC_HandleTypeDef hadc;
void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) {
if(hadc->Instance==ADC){
GPIO_InitTypeDef GPIO_InitStruct={0};
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* Enable GPIO clock ****************************************/
__HAL_RCC_GPIOA_CLK_ENABLE();
/* ADC1 Periph clock enable */
/*##- 2- Configure peripheral GPIO #########################################*/
/* ADC3 Channel8 GPIO pin configuration */
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
.........
}
The compiler is giving me a warning of "comparison of distinct pointer types lacks a cast" on the line :
if(hadc->Instance==ADC){
What i am doing wrong?
Appreciate the help!
I'm almost certain that ADC
is not a valid instance, you should be using ADC1
(or 2 or whatever) instead.
Looking in one of the STM32 header files shows:
// stm32f030x6.h
...
#define ADC1 ((ADC_TypeDef *) ADC1_BASE)
#define ADC ((ADC_Common_TypeDef *) ADC_BASE) /* Kept for legacy purpose */
...
This suggest to me you might have been looking at an old example, which remains so it's not an undefined symbol, but ADC1
has the type it's looking for while ADC
does not.