Go to the documentation of this file.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
00158 void arm_lms_f32(
00159 const arm_lms_instance_f32 * S,
00160 float32_t * pSrc,
00161 float32_t * pRef,
00162 float32_t * pOut,
00163 float32_t * pErr,
00164 uint32_t blockSize)
00165 {
00166 float32_t *pState = S->pState;
00167 float32_t *pCoeffs = S->pCoeffs;
00168 float32_t *pStateCurnt;
00169 float32_t *px, *pb;
00170 float32_t mu = S->mu;
00171 uint32_t numTaps = S->numTaps;
00172 uint32_t tapCnt, blkCnt;
00173 float32_t sum, e, d;
00174 float32_t w = 0.0f;
00175 float32_t x0, x1;
00176 float32_t c0, c1;
00177 e = 0.0f;
00178 d = 0.0f;
00179
00180
00181
00182 pStateCurnt = &(S->pState[(numTaps - 1u)]);
00183
00184 blkCnt = blockSize;
00185
00186 while(blkCnt > 0u)
00187 {
00188
00189 *pStateCurnt++ = *pSrc++;
00190
00191
00192 px = pState;
00193
00194
00195 pb = (pCoeffs);
00196
00197
00198 sum = 0.0f;
00199
00200
00201 tapCnt = numTaps >> 2;
00202
00203 while(tapCnt > 0u)
00204 {
00205
00206
00207 x0 = *px;
00208 c0 = *pb++;
00209 x1 = *(px + 1u);
00210 c1 = *pb++;
00211
00212
00213 sum += x0 * c0;
00214 sum += x1 * c1;
00215
00216
00217 x0 = *(px + 2u);
00218 c0 = *pb++;
00219 x1 = *(px + 3u);
00220 c1 = *pb++;
00221
00222
00223 px += 4u;
00224
00225
00226 sum += x0 * c0;
00227 sum += x1 * c1;
00228
00229
00230 tapCnt--;
00231 }
00232
00233
00234 tapCnt = numTaps % 0x4u;
00235
00236 while(tapCnt > 0u)
00237 {
00238
00239 sum += (*px++) * (*pb++);
00240
00241
00242 tapCnt--;
00243 }
00244
00245
00246 *pOut++ = sum;
00247
00248
00249 d = (float32_t) (*pRef++);
00250 e = d - sum;
00251 *pErr++ = e;
00252
00253
00254 w = e * mu;
00255
00256
00257 px = pState;
00258
00259
00260 pb = (pCoeffs);
00261
00262
00263 tapCnt = numTaps >> 2;
00264
00265
00266 while(tapCnt > 0u)
00267 {
00268
00269
00270
00271 x0 = *px;
00272 x1 = *(px + 1u);
00273 c0 = *pb;
00274 c1 = *(pb + 1u);
00275
00276
00277 c0 = c0 + x0 * w;
00278 c1 = c1 + x1 * w;
00279
00280
00281 *pb = c0;
00282 *(pb + 1u) = c1;
00283
00284
00285 x0 = *(px + 2u);
00286 x1 = *(px + 3u);
00287 c0 = *(pb + 2u);
00288 c1 = *(pb + 3u);
00289
00290
00291 c0 = c0 + x0 * w;
00292 c1 = c1 + x1 * w;
00293
00294
00295 *(pb + 2u) = c0;
00296 *(pb + 3u) = c1;
00297
00298
00299 px += 4u;
00300 pb += 4u;
00301
00302
00303
00304 tapCnt--;
00305 }
00306
00307
00308 tapCnt = numTaps % 0x4u;
00309
00310 while(tapCnt > 0u)
00311 {
00312
00313 *pb = *pb + (w * (*px++));
00314 pb++;
00315
00316
00317 tapCnt--;
00318 }
00319
00320
00321 pState = pState + 1;
00322
00323
00324 blkCnt--;
00325 }
00326
00327
00328
00329
00330
00331
00332
00333 pStateCurnt = S->pState;
00334
00335
00336 tapCnt = (numTaps - 1u) >> 2u;
00337
00338
00339 while(tapCnt > 0u)
00340 {
00341 *pStateCurnt++ = *pState++;
00342 *pStateCurnt++ = *pState++;
00343 *pStateCurnt++ = *pState++;
00344 *pStateCurnt++ = *pState++;
00345
00346
00347 tapCnt--;
00348 }
00349
00350
00351 tapCnt = (numTaps - 1u) % 0x4u;
00352
00353
00354 while(tapCnt > 0u)
00355 {
00356 *pStateCurnt++ = *pState++;
00357
00358
00359 tapCnt--;
00360 }
00361 }
00362