59 #ifndef __INCLUDE_FIXEDMATH_H 60 #define __INCLUDE_FIXEDMATH_H 74 #define b8HUNDRED 0x6400 78 #define b8ONETENTH 0x001a 79 #define b8ONEHUNDRTH 0x0003 80 #define b8HALFPI 0x0192 82 #define b8TWOPI 0x0648 89 #define b16THOUSAND 0x03e80000 90 #define b16HUNDRED 0x00640000 91 #define b16TEN 0x000a0000 92 #define b16ONE 0x00010000 93 #define b16HALF 0x00008000 94 #define b16ONETENTH 0x0000199a 95 #define b16ONEHUNDRTH 0x0000028f 96 #define b16ONETHOUSTH 0x00000042 97 #define b16HALFPI 0x0001921f 98 #define b16PI 0x0003243f 99 #define b16TWOPI 0x0006487b 101 #define b16MAX 0x7fffffff 102 #define ub16MAX 0xffffffff 103 #define b16MIN 0x80000000 104 #define ub16MIN 0x00000000 106 #define b32MILLION 0x000f424000000000 107 #define b32THOUSAND 0x000003e800000000 108 #define b32HUNDRED 0x0000006400000000 109 #define b32TEN 0x0000000a00000000 110 #define b32ONE 0x0000000100000000 111 #define b32HALF 0x0000000080000000 112 #define b32ONETENTH 0x000000001999999a 113 #define b32ONEHUNDRTH 0x00000000028f5c29 114 #define b32ONETHOUSTH 0x0000000000418937 115 #define b32ONETENTHOU 0x0000000000068db9 116 #define b32HALFPI 0x00000001921eb9ff 117 #define b32PI 0x00000003243f6b4f 118 #define b32TWOPI 0x00000006487ae7fd 120 #define b32MAX 0x7fffffffffffffff 121 #define ub32MAX 0xffffffffffffffff 122 #define b32MIN 0x8000000000000000 123 #define ub32MIN 0x0000000000000000 127 #define b8tob16(b) (((b16_t)(b)) << 8) 128 #define ub8toub16(b) (((ub16_t)(b)) << 8) 129 #define b16tob8(b) (b8_t)(((b)+0x0080)>>8) 130 #define ub16toub8(b) (ub8_t)(((b)+0x0080)>>8) 132 #ifdef CONFIG_HAVE_LONG_LONG 133 #define b8tob32(b) (((b32_t)(b)) << 24) 134 #define ub8toub32(b) (((ub32_t)(b)) << 24) 135 #define b16tob32(b) (((b32_t)(b)) << 16) 136 #define ub16toub32(b) (((ub32_t)(b)) << 16) 137 #define b32tob16(b) (b16_t)(((b) + 0x0000000000008000)>>16) 138 #define ub32toub16(b) (ub16_t)(((b) + 0x0000000000008000)>>16) 139 #define b32tob8(b) (b8_t)(((b) + 0x0000000000000080)>>8) 146 #define b8toi(a) ((a) >> 8) 147 #define itob8(i) (((b8_t)(i)) << 8) 148 #define uitoub8(i) (((ub8_t)(i)) << 8) 149 #define b8tof(b) (((float)b)/256.0) 150 #define ftob8(f) (b8_t)(((f)*256.0)) 151 #define b8trunc(a) ((a) & 0xff00) 152 #define b8round(a) (((a)+0x0080) & 0xff00) 153 #define b8frac(a) ((a) & 0x00ff) 157 #define ub8inv(b) (0x8000/((b)>>1)) 158 #define b8inv(b) (0x4000/((b)>>2)) 159 #define b8addb8(a, b) ((a)+(b)) 160 #define b8addi(a, i) ((a)+itob8(i)) 161 #define b8subb8(a, b) ((a)-(b)) 162 #define b8subi(a, i) ((a)-itob8(i)) 163 #define b8mulb8(a, b) b16tob8((b16_t)(a)*(b16_t)(b) 164 #define ub8mulub8(a, b) ub16toub8((ub16_t)(a)*(ub16_t)(b) 165 #define b8muli(a, i) ((a)*(i)) 166 #define b8sqr(a) b8mulb8(a, a) 167 #define ub8sqr(a) ub8mulub8(a, a) 168 #define b8divb8(a, b) b8tob16(a)/(b16_t)(b) 169 #define ub8divub8(a, b) ub8toub16(a)/(ub16_t)(b) 170 #define b8divi(a, i) ((a)/(i)) 171 #define b8idiv(i, j) (((i)<<8)/j) 177 #define b16toi(a) ((a) >> 16) 178 #define itob16(i) (((b16_t)(i)) << 16) 179 #define uitoub16(i) (((ub16_t)(i)) << 16) 180 #define b16tof(b) (((float)b)/65536.0) 181 #define ftob16(f) (b16_t)(((f)*65536.0)) 182 #define b16trunc(a) ((a) & 0xffff0000) 183 #define b16round(a) (((a)+0x00008000) & 0xffff0000) 184 #define b16frac(a) ((a) & 0x0000ffff) 188 #define ub16inv(b) (0x80000000/((b)>>1)) 189 #define b16inv(b) (0x40000000/((b)>>2)) 190 #define b16addb16(a, b) ((a)+(b)) 191 #define b16addi(a, i) ((a)+itob16(i)) 192 #define b16subb16(a, b) ((a)-(b)) 193 #define b16subi(a, i) ((a)-itob16(i)) 194 #define b16muli(a, i) ((a)*(i)) 195 #define b16divi(a, i) ((a)/(i)) 196 #define b16idiv(i, j) (((i)<<16)/j) 198 #ifdef CONFIG_HAVE_LONG_LONG 201 #define b16mulb16(a, b) b32tob16((b32_t)(a)*(b32_t)(b)) 202 #define ub16mulub16(a, b) ub32toub16((ub32_t)(a)*(ub32_t)(b)) 206 #define b16sqr(a) b16mulb16(a, a) 207 #define ub16sqr(a) ub16mulub16(a, a) 211 #define b16divb16(a, b) (b16_t)(b16tob32(a)/(b32_t)(b)) 212 #define ub16divub16(a, b) (ub16_t)(ub16toub32(a)/(ub32_t)(b)) 223 #ifdef CONFIG_HAVE_LONG_LONG 233 #if defined(__cplusplus) 234 #define EXTERN extern "C" 237 #define EXTERN extern 240 #ifndef CONFIG_HAVE_LONG_LONG 329 #if defined(__cplusplus) b16_t b16atan2(b16_t y, b16_t x)
Trigonometric tangent operation.
b16_t b16sin(b16_t rad)
Trigonometric sine operation.
#define ub16mulub16(a, b)
#define ub16divub16(a, b)
b16_t b16cos(b16_t rad)
Trigonometric cosine operation.