/* Process function for the Q15 Linear Interpolation Function.  */
q15_t arm_linear_interp_q15(const q15_t *pYData, q31_t x, uint32_t nValues)
/* Process function for the Q15 Linear Interpolation Function.  */
q15_t arm_linear_interp_q15(const q15_t *pYData, q31_t x, uint32_t nValues)
{
    q63_t y;
    q15_t y0, y1;
    q31_t fract;
    int32_t index;
    index = ((x & (int32_t)0xFFF00000) >> 20);
    if (index >= (int32_t)(nValues - 1))
    {
      return (pYData[nValues - 1]);
    }
    else if (index < 0)
    {
      return (pYData[0]);
    }
    else
    {
      fract = (x & 0x000FFFFF);
      y0 = pYData[index];
      y1 = pYData[index + 1];
      y = ((q63_t) y0 * (0xFFFFF - fract));
      y += ((q63_t) y1 * (fract));
      return (q15_t) (y >> 20);
    }
  }