summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/fixedpoint.h
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-04-10 13:24:32 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-04-10 13:28:35 -0400
commitf49e75053198cc24aff92e9045795e011fa25083 (patch)
treea6800dbd34679289a44f954ca92d6d36fff89978 /apps/plugins/lib/fixedpoint.h
parentf5b7134f59fa20685a51d56d3a323044a2c441cf (diff)
downloadrockbox-f49e75053198cc24aff92e9045795e011fa25083.tar.gz
rockbox-f49e75053198cc24aff92e9045795e011fa25083.zip
Move fixedpoint.h to be accessible in /firmware.
Will need it soon enough. Combine the contents of all the various fixedpoint.h files. Not moving fixedpoint.c for now since I'm not sure where it should be and it causes some dependency issues. Change-Id: Ideacbca2ca78f9158c2b114b113c274f68e908d5
Diffstat (limited to 'apps/plugins/lib/fixedpoint.h')
-rw-r--r--apps/plugins/lib/fixedpoint.h52
1 files changed, 2 insertions, 50 deletions
diff --git a/apps/plugins/lib/fixedpoint.h b/apps/plugins/lib/fixedpoint.h
index 1631f8d6d8..811a1d9b81 100644
--- a/apps/plugins/lib/fixedpoint.h
+++ b/apps/plugins/lib/fixedpoint.h
@@ -20,55 +20,7 @@
20 * KIND, either express or implied. 20 * KIND, either express or implied.
21 * 21 *
22 ****************************************************************************/ 22 ****************************************************************************/
23
24/** PLUGINS - FIXED POINT MATH ROUTINES - USAGE
25 *
26 * - x and y arguments are fixed point integers
27 * - fracbits is the number of fractional bits in the argument(s)
28 * - functions return long fixed point integers with the specified number
29 * of fractional bits unless otherwise specified
30 *
31 * Calculate sin and cos of an angle:
32 * fp_sincos(phase, *cos)
33 * where phase is a 32 bit unsigned integer with 0 representing 0
34 * and 0xFFFFFFFF representing 2*pi, and *cos is the address to
35 * a long signed integer. Value returned is a long signed integer
36 * from -0x80000000 to 0x7fffffff, representing -1 to 1 respectively.
37 * That is, value is a fixed point integer with 31 fractional bits.
38 *
39 * Take square root of a fixed point number:
40 * fp_sqrt(x, fracbits)
41 *
42 * Calculate sin or cos of an angle (very fast, from a table):
43 * fp14_sin(angle)
44 * fp14_cos(angle)
45 * where angle is a non-fixed point integer in degrees. Value
46 * returned is a fixed point integer with 14 fractional bits.
47 *
48 * Calculate the natural log of a positive fixed point integer
49 * fp16_log(x)
50 * where x and the value returned are fixed point integers
51 * with 16 fractional bits.
52 */
53
54#ifndef _FIXEDPOINT_H_PLUGINS 23#ifndef _FIXEDPOINT_H_PLUGINS
55#define _FIXEDPOINT_H_PLUGINS 24#define _FIXEDPOINT_H_PLUGINS
56 25#include "../../../firmware/include/fixedpoint.h"
57long fp_sincos(unsigned long phase, long *cos); 26#endif /* _FIXEDPOINT_H_PLUGINS */
58long fp_sqrt(long a, unsigned int fracbits);
59long fp14_cos(int val);
60long fp14_sin(int val);
61long fp16_log(int x);
62long fp16_exp(int x);
63
64unsigned long isqrt(unsigned long x);
65
66/* fast unsigned multiplication (16x16bit->32bit or 32x32bit->32bit,
67 * whichever is faster for the architecture) */
68#ifdef CPU_ARM
69#define FMULU(a, b) ((uint32_t) (((uint32_t) (a)) * ((uint32_t) (b))))
70#else /* SH1, coldfire */
71#define FMULU(a, b) ((uint32_t) (((uint16_t) (a)) * ((uint16_t) (b))))
72#endif
73
74#endif