Skip to main content
MQi.1
Senior II
March 15, 2023
Question

How to compare 2 AdcHandle objects equal or not?

  • March 15, 2023
  • 4 replies
  • 1165 views

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 "==".

This topic has been closed for replies.

4 replies

ONadr.1
Senior III
March 15, 2023

Use memcmp for this two structures.

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

MQi.1
MQi.1Author
Senior II
March 15, 2023

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.

Graduate II
March 15, 2023
if (ADC_Handler == &ADC_Handler_1)
 {
 
...
 
}

What about this ?

MQi.1
MQi.1Author
Senior II
March 18, 2023

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.