00001 /*This file has been prepared for Doxygen automatic documentation generation.*/ 00017 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00018 * 00019 * Redistribution and use in source and binary forms, with or without 00020 * modification, are permitted provided that the following conditions are met: 00021 * 00022 * 1. Redistributions of source code must retain the above copyright notice, this 00023 * list of conditions and the following disclaimer. 00024 * 00025 * 2. Redistributions in binary form must reproduce the above copyright notice, 00026 * this list of conditions and the following disclaimer in the documentation 00027 * and/or other materials provided with the distribution. 00028 * 00029 * 3. The name of Atmel may not be used to endorse or promote products derived 00030 * from this software without specific prior written permission. 00031 * 00032 * 4. This software may only be redistributed and used in connection with an Atmel 00033 * AVR product. 00034 * 00035 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00036 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00037 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00038 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00039 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00040 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00041 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00042 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00043 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00044 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00045 * 00046 */ 00047 00048 #include "dsp.h" 00049 00050 #if defined(FORCE_ALL_GENERICS) || \ 00051 defined(FORCE_GENERIC_FILT16_IIRPART) || \ 00052 !defined(TARGET_SPECIFIC_FILT16_IIRPART) 00053 00054 void dsp16_filt_iirpart(dsp16_t *y, dsp16_t *x, int size, dsp16_t *num, int num_size, dsp16_t *den, int den_size, int num_prediv, int den_prediv) 00055 { 00056 int n, m; 00057 S32 sum1, sum2; 00058 dsp16_t *px, *py; 00059 00060 num_prediv = DSP16_QB - num_prediv; 00061 den_prediv = DSP16_QB - den_prediv; 00062 00063 // Compute the first den_size elements 00064 // to initialize the vect1 00065 for(n=0; n<den_size; n++) 00066 { 00067 sum1 = 0; 00068 sum2 = 0; 00069 px = &x[n+num_size-1]; 00070 for(m=0; m<num_size; m++) 00071 sum1 += (S32) num[m] * (S32) px[-m]; 00072 py = &y[n-1]; 00073 for(m=0; m<n; m++) 00074 sum2 += (S32) den[m] * (S32) py[-m]; 00075 00076 sum1 >>= num_prediv; 00077 sum2 >>= den_prediv; 00078 00079 y[n] = sum1 - sum2; 00080 } 00081 00082 for(; n<=(size-num_size); n++) 00083 { 00084 sum1 = 0; 00085 sum2 = 0; 00086 px = &x[n+num_size-1]; 00087 for(m=0; m<num_size; m++) 00088 sum1 += (S32) num[m] * (S32) x[-m]; 00089 py = &y[n-1]; 00090 for(m=0; m<den_size; m++) 00091 sum2 += (S32) den[m] * (S32) y[-m]; 00092 00093 sum1 >>= num_prediv; 00094 sum2 >>= den_prediv; 00095 00096 y[n] = sum1 - sum2; 00097 } 00098 } 00099 00100 #endif