00001 /*This file is 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 /* - \ref Multiplication 00048 * - \ref Division 00049 * - \ref Sine 00050 * - \ref Cosine 00051 * - \ref Arc_sine 00052 * - \ref Arc_cosine 00053 * - \ref Absolute 00054 * - \ref Square_root 00055 * - \ref Natural_logarithm 00056 * - \ref Binary_logarithm 00057 * - \ref Common_logarithm 00058 * - \ref Exponential 00059 * - \ref Power 00060 * - \ref Random 00061 * 00062 * \htmlonly 00063 * <hr /> 00064 * \endhtmlonly 00065 */ 00066 00067 #ifndef __DSP_OPERATORS_H__ 00068 #define __DSP_OPERATORS_H__ 00069 00070 #ifdef __AVR32_ABI_COMPILER__ 00071 00091 inline static dsp16_t dsp16_op_mul(dsp16_t num1, dsp16_t num2) { return (dsp16_t) ((((S32) num1)*((S32) num2)) >> DSP16_QB); } 00098 inline static dsp32_t dsp32_op_mul(dsp32_t num1, dsp32_t num2) { return (dsp32_t) ((((S64) num1)*((S64) num2)) >> DSP32_QB); } 00099 00118 inline static dsp16_t dsp16_op_div(dsp16_t num, dsp16_t den) { return (dsp16_t) ((((S32) num) << DSP16_QB)/((S32) den)); } 00125 inline static dsp32_t dsp32_op_div(dsp32_t num, dsp32_t den) { return (dsp32_t) ((((S64) num) << DSP32_QB)/((S64) den)); } 00126 00148 dsp16_t dsp16_op_sin(dsp16_t angle); 00156 dsp32_t dsp32_op_sin(dsp32_t angle); 00157 00178 inline static dsp16_t dsp16_op_cos(dsp16_t angle) { return dsp16_op_sin(angle + DSP16_Q(0.5)); } 00186 inline static dsp32_t dsp32_op_cos(dsp32_t angle) { return dsp32_op_sin(angle + DSP32_Q(0.5)); } 00187 00209 dsp16_t dsp16_op_asin(dsp16_t number); 00217 dsp32_t dsp32_op_asin(dsp32_t number); 00218 00240 inline static dsp16_t dsp16_op_acos(dsp16_t number) { return (DSP16_Q(0.5)-1) - dsp16_op_asin(number); } 00248 inline static dsp32_t dsp32_op_acos(dsp32_t number) { return (DSP32_Q(0.5)-1) - dsp32_op_asin(number); } 00249 00267 inline static dsp16_t dsp16_op_abs(dsp16_t number) { return (number < 0)?-number:number; } 00273 inline static dsp32_t dsp32_op_abs(dsp32_t number) { return (number < 0)?-number:number; } 00274 00294 dsp16_t dsp16_op_sqrt(dsp16_t number); 00302 dsp32_t dsp32_op_sqrt(dsp32_t number); 00303 00325 dsp16_t dsp16_op_ln(dsp16_t number); 00333 dsp32_t dsp32_op_ln(dsp32_t number); 00334 00356 dsp16_t dsp16_op_log2(dsp16_t number); 00364 dsp32_t dsp32_op_log2(dsp32_t number); 00365 00387 dsp16_t dsp16_op_log10(dsp16_t number); 00395 dsp32_t dsp32_op_log10(dsp32_t number); 00396 00416 dsp16_t dsp16_op_exp(dsp16_t number); 00422 dsp32_t dsp32_op_exp(dsp32_t number); 00423 00424 00446 dsp16_t dsp16_op_pow(dsp16_t x, dsp16_t y); 00454 dsp32_t dsp32_op_pow(dsp32_t x, dsp32_t y); 00455 00473 void dsp_op_srand(int new_seed); 00479 dsp16_t dsp16_op_rand(); 00485 dsp32_t dsp32_op_rand(); 00486 00487 #endif // __AVR32_ABI_COMPILER__ 00488 00489 #endif //__DSP_OPERATORS_H__ 00490