Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
FixedMath.h
00001 #include "DataTypes.h" 00002 00003 #ifndef FIXEDMATH_H_ 00004 #define FIXEDMATH_H_ 00005 00006 00007 typedef SIGNED_WORD FIXED_7_8; 00008 typedef SIGNED_WORD FIXED_9_6; 00009 00010 typedef SIGNED_WORD FIXED_0_15; 00011 typedef SIGNED_WORD FIXED_1_14; 00012 00013 00014 extern const FIXED_1_14 Fixed_1_14_SineTable [256]; 00015 extern const FIXED_7_8 Fixed_7_8_SineTable [256]; 00016 00017 #define FMul_15_0(A,B) (FIXED_0_15)(((FIXED_0_15)(A) * (FIXED_0_15 )(B))>>15) 00018 #define FMul_7_8to0_15(A,B) (FIXED_7_8)(((FIXED_7_8)(A) * (FIXED_0_15)(B))>>15) 00019 #define FMul_15_0to7_8(A,B) (SIGNED_WORD)(((SIGNED_WORD)(A) * (FIXED_7_8)(B))>>8) 00020 00021 00022 00023 #define INT_7_8(A) (SIGNED_WORD)(A>>8) 00024 #define INT_TO_7_8(A) ((FIXED_7_8)(A)<<8) 00025 #define FRAC_7_8(A) (FIXED_7_8)(A&0xFF) 00026 00027 #define INT_9_6(A) (SIGNED_WORD)(A>>6) 00028 #define INT_TO_9_6(A) ((FIXED_9_6)(A)<<6) 00029 #define FRAC_6_9(A) (FIXED_9_6)(A&0x3F) 00030 00031 00032 00033 //#define FMul_15_0to0_15 (SIGNED_WORD)(((SIGNED_WORD)(A) * (FIXED_0_15)(B))>>16) 00034 inline SIGNED_WORD FMul_15_0to0_15(SIGNED_WORD A,SIGNED_WORD B) 00035 { 00036 return (((long)(A) * (long)(B))>>15); 00037 } 00038 00039 inline SIGNED_WORD FMul_15_0to1_14(SIGNED_WORD A,SIGNED_WORD B) 00040 { 00041 long temp; 00042 temp = (((long)(A) * (long)(B))>>13); 00043 if(temp&0x01) 00044 { 00045 temp = temp>>1; 00046 temp = temp +1; 00047 } 00048 else 00049 { 00050 temp = temp>>1; 00051 } 00052 return temp; 00053 } 00054 00055 //inline SIGNED_WORD ABS(A) 00056 //{ 00057 //if(A<0) 00058 //return -A; 00059 //else 00060 //return A; 00061 //} 00062 00063 #endif /*FIXEDMATH_H_*/
Generated on Thu Jul 14 2022 09:05:34 by
1.7.2