Commit 60831117 authored by 陈家乐's avatar 陈家乐

🐞 fix:QAC问题:45351 Suspicious: Division by zero

parent 6beb5c28
......@@ -122,6 +122,11 @@ uint16_t ADC_Converse_Scan(ADC_Channel_t ch, uint32_t times, uint16_t *buf)
volatile uint8_t flag;
uint32_t total = 0;
if(times == 0)
{
return 0;
}
else{
assert_param(IS_SCAN_START_CHAN(ch));
INTC_DisableIRQ(ADC_IRQn); // disable INTAD interrupt
......@@ -150,7 +155,8 @@ uint16_t ADC_Converse_Scan(ADC_Channel_t ch, uint32_t times, uint16_t *buf)
}
}
return (total / times); // return average value
return (uint16_t)(total / times); // return average value
}
}
/**
......@@ -192,7 +198,7 @@ uint16_t ADC_Converse(ADC_Channel_t ch, uint32_t times, uint16_t *buf)
*buf++ = ADC->ADCR;
total += ADC->ADCR;
}
return (total / times); // return average value
return (uint16_t)(total / times); // return average value
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment