cancel
Showing results for 
Search instead for 
Did you mean: 

How to compare 2 AdcHandle objects equal or not?

MQi.1
Senior II

I have 2 ADC_HandlerTypeDef objects came from 2 different channel of ADC1, and I have an ADC function, like this:

ADC_read(ADC_HandlerTypeDef ADC_Handler)

How can I use this function for 2 channels?

I tried this:

if (ADC_Handler == ADC_Handler_1)

{

...

}

if (ADC_Handler == ADC_Handler_2)

{

...

}

there was compile error for "==".

4 REPLIES 4
ONadr.1
Senior III

Use memcmp for this two structures.

https://cplusplus.com/reference/cstring/memcmp/

MQi.1
Senior II

This method was too heavy, since the 2 objects were different in "ADC_Channel", I want to know how to get the channel number for the ADC_Handler argument.

JTP1
Lead
if (ADC_Handler == &ADC_Handler_1)
 {
 
...
 
}

What about this ?

MQi.1
Senior II

I found a solution: define 1 handler, define an array with 2 elements, update the 2 elements once ADC, then shift in 2 ADC channels for 2 elements - each one for a channel.