Paparazzi UAS  v7.0_unstable
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 // init compressed table if needed
82 extern int pprz_trig_int_init(void);
83 
84 #if defined(PPRZ_TRIG_INT_COMPR_FLASH)
85 uint8_t get_nibble(uint16_t pos);
86 
87 #if defined(PPRZ_TRIG_INT_COMPR_HIGHEST)
88 void table_encode_4(int16_t val, int16_t val_prev, int16_t cnt, int16_t *tab);
89 int16_t pprz_trig_int_4(int16_t val);
90 #endif
91 
92 #if defined(PPRZ_TRIG_INT_COMPR_HIGH)
93 void table_encode_8(int16_t val, int16_t val_prev, int16_t cnt, int16_t *tab);
94 int16_t pprz_trig_int_8(int16_t val);
95 #endif
96 
97 #if defined(PPRZ_TRIG_INT_COMPR_LOW)
98 void table_encode_12(int16_t val, int16_t val_prev, int16_t cnt, int16_t *tab);
99 int16_t pprz_trig_int_12(int16_t val);
100 #endif
101 
102 #if defined(PPRZ_TRIG_INT_COMPR_NONE)
103 int16_t pprz_trig_int_16(int32_t val);
104 void table_encode_16(int16_t val, int16_t cnt);
105 #endif
106 
107 int16_t pprz_trig_int_f(int32_t angle);
108 #endif // PPRZ_TRIG_INT_COMPR_FLASH
109 
110 /* for backwards compatibility */
111 #define PPRZ_ITRIG_SIN(_s, _a) { _s = pprz_itrig_sin(_a); }
112 #define PPRZ_ITRIG_COS(_c, _a) { _c = pprz_itrig_cos(_a); }
113 #define INT32_ATAN2(_a, _y, _x) { _a = int32_atan2(_y, _x); }
114 #define INT32_ATAN2_2(_a, _y, _x) { _a = int32_atan2_2(_y, _x); }
115 
116 #ifdef __cplusplus
117 } /* extern "C" */
118 #endif
119 
120 #endif /* PPRZ_TRIG_INT_H */
int pprz_trig_int_init(void)
#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 int32_atan2(int32_t y, int32_t x)
int32_t pprz_itrig_cos(int32_t angle)
int32_t int32_atan2_2(int32_t y, int32_t x)
int32_t pprz_itrig_sin(int32_t angle)
PPRZ_TRIG_CONST int16_t pprz_trig_int[]
Definition: pprz_trig_int.c:31
uint16_t val[TCOUPLE_NB]
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98