Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
pprz_trig_int.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
27 #ifndef PPRZ_TRIG_INT_H
28 #define PPRZ_TRIG_INT_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include "std.h"
35 
39 #ifndef PPRZ_TRIG_CONST
40 #define PPRZ_TRIG_CONST
41 #endif
42 
43 #if defined(PPRZ_TRIG_INT_TEST)
44 #define PPRZ_TRIG_INT_COMPR_FLASH
45 #define PPRZ_TRIG_INT_COMPR_HIGHEST
46 #define PPRZ_TRIG_INT_COMPR_HIGH
47 #define PPRZ_TRIG_INT_COMPR_LOW
48 #define PPRZ_TRIG_INT_COMPR_NONE
49 #endif
50 
51 #if defined(PPRZ_TRIG_INT_COMPR_FLASH) && !defined(PPRZ_TRIG_INT_COMPR_HIGHEST) && !defined(PPRZ_TRIG_INT_COMPR_HIGH) && !defined(PPRZ_TRIG_INT_COMPR_LOW)
52 #define PPRZ_TRIG_INT_COMPR_NONE
53 #endif
54 
55 #define TRIG_INT_SIZE 6434
56 #define TRIG_INT_VAL_MAX 14
57 #define TREE_SIZE_4 (TRIG_INT_VAL_MAX - 4)
58 #define TREE_SIZE_8 (TRIG_INT_VAL_MAX - 8)
59 #define TREE_SIZE_12 (TRIG_INT_VAL_MAX - 12)
60 
61 /* resulting compressed size */
62 #define TRIG_INT_RLE_LEN 3379
63 #define TRIG_INT_COMPR_LEN ((TRIG_INT_RLE_LEN + 1) / 2)
64 
65 /* minimum size to use multi */
66 #define ONE_MIN ((3 * 3) + 1)
67 
68 #define TREE_BUF_12_1 1035
69 #define TREE_BUF_12_2 2145
70 #define TREE_BUF_12_3 3474
71 
72 #if !defined(PPRZ_TRIG_INT_COMPR_FLASH) || defined(PPRZ_TRIG_INT_TEST)
74 #endif
75 
76 extern int32_t pprz_itrig_sin(int32_t angle);
77 extern int32_t pprz_itrig_cos(int32_t angle);
78 extern int32_t int32_atan2(int32_t y, int32_t x);
80 
81 #if defined(PPRZ_TRIG_INT_COMPR_FLASH)
82 uint8_t get_nibble(uint16_t pos);
83 int pprz_trig_int_init(void);
84 
85 #if defined(PPRZ_TRIG_INT_COMPR_HIGHEST)
86 void table_encode_4(int16_t val, int16_t val_prev, int16_t cnt, int16_t *tab);
87 int16_t pprz_trig_int_4(int16_t val);
88 #endif
89 
90 #if defined(PPRZ_TRIG_INT_COMPR_HIGH)
91 void table_encode_8(int16_t val, int16_t val_prev, int16_t cnt, int16_t *tab);
92 int16_t pprz_trig_int_8(int16_t val);
93 #endif
94 
95 #if defined(PPRZ_TRIG_INT_COMPR_LOW)
96 void table_encode_12(int16_t val, int16_t val_prev, int16_t cnt, int16_t *tab);
97 int16_t pprz_trig_int_12(int16_t val);
98 #endif
99 
100 #if defined(PPRZ_TRIG_INT_COMPR_NONE)
101 int16_t pprz_trig_int_16(int32_t val);
102 void table_encode_16(int16_t val, int16_t cnt);
103 #endif
104 
105 int16_t pprz_trig_int_f(int32_t angle);
106 #endif // PPRZ_TRIG_INT_COMPR_FLASH
107 
108 /* for backwards compatibility */
109 #define PPRZ_ITRIG_SIN(_s, _a) { _s = pprz_itrig_sin(_a); }
110 #define PPRZ_ITRIG_COS(_c, _a) { _c = pprz_itrig_cos(_a); }
111 #define INT32_ATAN2(_a, _y, _x) { _a = int32_atan2(_y, _x); }
112 #define INT32_ATAN2_2(_a, _y, _x) { _a = int32_atan2_2(_y, _x); }
113 
114 #ifdef __cplusplus
115 } /* extern "C" */
116 #endif
117 
118 #endif /* PPRZ_TRIG_INT_H */
uint16_t
unsigned short uint16_t
Definition: types.h:16
val
uint16_t val[TCOUPLE_NB]
Definition: temp_tcouple_adc.c:49
pprz_itrig_sin
int32_t pprz_itrig_sin(int32_t angle)
Definition: pprz_trig_int.c:859
pprz_itrig_cos
int32_t pprz_itrig_cos(int32_t angle)
Definition: pprz_trig_int.c:888
std.h
int16_t
signed short int16_t
Definition: types.h:17
uint8_t
unsigned char uint8_t
Definition: types.h:14
int32_atan2
int32_t int32_atan2(int32_t y, int32_t x)
Definition: pprz_trig_int.c:899
PPRZ_TRIG_CONST
#define PPRZ_TRIG_CONST
Allow makefile to define PPRZ_TRIG_CONST in case we want to make the trig tables const and store them...
Definition: pprz_trig_int.h:40
int32_t
signed long int32_t
Definition: types.h:19
int32_atan2_2
int32_t int32_atan2_2(int32_t y, int32_t x)
Definition: pprz_trig_int.c:921
pprz_trig_int
PPRZ_TRIG_CONST int16_t pprz_trig_int[]
Definition: pprz_trig_int.c:31