简体   繁体   中英

STM32 convert an unsigned short array to a float array

I have been doing research in google, however I cannot find a solution.

How to convert an unsigned short array to a float array in STM32? I need to perform multiplication between an unsigned short array with a float array. To use FPU and DSP library for STM32F4, the unsigned array is to be converted to floating point first.

There are only libraries converting signed short arrays to float arrays. How to convert an unsigned short array to a float array?

By just storing them as float, I'd say:

void uint16_to_float(float *out, const unsigned short *in, size_t num)
{
  for(; num > 0; --num)
    *out++ = *in++;
}

It's up to the compiler to figure out what instruction(s) are best suited for this, but it's a pretty standard operation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM