00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "arm_math.h"
00025
00063 void arm_float_to_q15(
00064 float32_t * pSrc,
00065 q15_t * pDst,
00066 uint32_t blockSize)
00067 {
00068 float32_t *pIn = pSrc;
00069 uint32_t blkCnt;
00070
00071 #ifdef ARM_MATH_ROUNDING
00072
00073 float32_t in;
00074
00075 #endif
00076
00077
00078 blkCnt = blockSize >> 3u;
00079
00080
00081
00082 while(blkCnt > 0u)
00083 {
00084
00085 #ifdef ARM_MATH_ROUNDING
00086
00087
00088 in = *pIn++;
00089 in = (in * 32768.0f);
00090 in += in > 0 ? 0.5 : -0.5;
00091 #ifdef CCS
00092 *pDst++ = (q15_t) (__SSATA((q31_t) (in), 0, 16));
00093 #else
00094 *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
00095 #endif // #ifdef CCS
00096
00097 in = *pIn++;
00098 in = (in * 32768.0f);
00099 in += in > 0 ? 0.5 : -0.5;
00100 #ifdef CCS
00101 *pDst++ = (q15_t) (__SSATA((q31_t) (in), 0, 16));
00102 #else
00103 *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
00104 #endif // #ifdef CCS
00105
00106 in = *pIn++;
00107 in = (in * 32768.0f);
00108 in += in > 0 ? 0.5 : -0.5;
00109 #ifdef CCS
00110 *pDst++ = (q15_t) (__SSATA((q31_t) (in), 0, 16));
00111 #else
00112 *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
00113 #endif // #ifdef CCS
00114
00115 in = *pIn++;
00116 in = (in * 32768.0f);
00117 in += in > 0 ? 0.5 : -0.5;
00118 #ifdef CCS
00119 *pDst++ = (q15_t) (__SSATA((q31_t) (in), 0, 16));
00120 #else
00121 *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
00122 #endif // #ifdef CCS
00123
00124 in = *pIn++;
00125 in = (in * 32768.0f);
00126 in += in > 0 ? 0.5 : -0.5;
00127 #ifdef CCS
00128 *pDst++ = (q15_t) (__SSATA((q31_t) (in), 0, 16));
00129 #else
00130 *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
00131 #endif // #ifdef CCS
00132
00133 in = *pIn++;
00134 in = (in * 32768.0f);
00135 in += in > 0 ? 0.5 : -0.5;
00136 #ifdef CCS
00137 *pDst++ = (q15_t) (__SSATA((q31_t) (in), 0, 16));
00138 #else
00139 *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
00140 #endif // #ifdef CCS
00141
00142 in = *pIn++;
00143 in = (in * 32768.0f);
00144 in += in > 0 ? 0.5 : -0.5;
00145 #ifdef CCS
00146 *pDst++ = (q15_t) (__SSATA((q31_t) (in), 0, 16));
00147 #else
00148 *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
00149 #endif // #ifdef CCS
00150
00151 in = *pIn++;
00152 in = (in * 32768.0f);
00153 in += in > 0 ? 0.5 : -0.5;
00154 #ifdef CCS
00155 *pDst++ = (q15_t) (__SSATA((q31_t) (in), 0, 16));
00156 #else
00157 *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
00158 #endif // #ifdef CCS
00159
00160 #else
00161
00162
00163
00164 #ifdef CCS
00165 *pDst++ = (q15_t) __SSATA((q31_t) (*pIn++ * 32768.0f), 0, 16);
00166 *pDst++ = (q15_t) __SSATA((q31_t) (*pIn++ * 32768.0f), 0, 16);
00167 *pDst++ = (q15_t) __SSATA((q31_t) (*pIn++ * 32768.0f), 0, 16);
00168 *pDst++ = (q15_t) __SSATA((q31_t) (*pIn++ * 32768.0f), 0, 16);
00169 *pDst++ = (q15_t) __SSATA((q31_t) (*pIn++ * 32768.0f), 0, 16);
00170 *pDst++ = (q15_t) __SSATA((q31_t) (*pIn++ * 32768.0f), 0, 16);
00171 *pDst++ = (q15_t) __SSATA((q31_t) (*pIn++ * 32768.0f), 0, 16);
00172 *pDst++ = (q15_t) __SSATA((q31_t) (*pIn++ * 32768.0f), 0, 16);
00173 #else
00174 *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
00175 *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
00176 *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
00177 *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
00178 *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
00179 *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
00180 *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
00181 *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
00182 #endif // #ifdef CCS
00183
00184 #endif // #ifdef ARM_MATH_ROUNDING
00185
00186
00187 blkCnt--;
00188 }
00189
00190
00191
00192 blkCnt = blockSize % 0x8u;
00193
00194 while(blkCnt > 0u)
00195 {
00196
00197 #ifdef ARM_MATH_ROUNDING
00198
00199
00200 in = *pIn++;
00201 in = (in * 32768.0f);
00202 in += in > 0 ? 0.5 : -0.5;
00203 #ifdef CCS
00204 *pDst++ = (q15_t) (__SSATA((q31_t) (in), 0, 16));
00205 #else
00206 *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
00207 #endif // #ifdef CCS
00208
00209 #else
00210
00211
00212
00213 #ifdef CCS
00214 *pDst++ = (q15_t) __SSATA((q31_t) (*pIn++ * 32768.0f), 0, 16);
00215 #else
00216 *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
00217 #endif // #ifdef CCS
00218
00219 #endif //#ifdef ARM_MATH_ROUNDING
00220
00221
00222 blkCnt--;
00223 }
00224 }
00225