//开方函数
uint16_t isqrt32(uint32_t x)
{
uint32_t m, y, b;
m = 0x40000000;
y = 0;
while (m != 0) {
b = y | m;
y = y >> 1;
if (x >= b) {
x = x - b;
y = y | m;
}
m >>= 2;
}
return y;
}
//求均方根(真有效值)
uint16_t rms(uint16_t * ptr)
{
uint64_t t = 0;
uint16_t i;
for (i = 0; i < BUF_SIZE; i++)
t += (uint32_t) * (ptr + i) * (uint32_t) * (ptr + i);
return (isqrt32(t / BUF_SIZE));
}
*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。