summaryrefslogtreecommitdiffstats
path: root/invensense/mlsdk/mllite/mlFIFO.h
blob: 2114eb3ad5fb817ac65a80da43f7acc5b538157c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 $License:
   Copyright 2011 InvenSense, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
  $
 */

#ifndef INVENSENSE_INV_FIFO_H__
#define INVENSENSE_INV_FIFO_H__

#include "mltypes.h"
#include "mlinclude.h"
#include "ml.h"
#ifdef INV_INCLUDE_LEGACY_HEADERS
#include "mlFIFO_legacy.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

    /**************************************************************************/
    /*  Elements                                                              */
    /**************************************************************************/

#define INV_ELEMENT_1                    (0x0001)
#define INV_ELEMENT_2                    (0x0002)
#define INV_ELEMENT_3                    (0x0004)
#define INV_ELEMENT_4                    (0x0008)
#define INV_ELEMENT_5                    (0x0010)
#define INV_ELEMENT_6                    (0x0020)
#define INV_ELEMENT_7                    (0x0040)
#define INV_ELEMENT_8                    (0x0080)

#define INV_ALL                          (0xFFFF)
#define INV_ELEMENT_MASK                 (0x00FF)

    /**************************************************************************/
    /*  Accuracy                                                              */
    /**************************************************************************/

#define INV_16_BIT                       (0x0100)
#define INV_32_BIT                       (0x0200)
#define INV_ACCURACY_MASK                (0x0300)

    /**************************************************************************/
    /*  Accuracy                                                              */
    /**************************************************************************/

#define INV_GYRO_FROM_RAW                (0x00)
#define INV_GYRO_FROM_QUATERNION         (0x01)

    /**************************************************************************/
    /*  High Rate Proceses                                                    */
    /**************************************************************************/

#define MAX_HIGH_RATE_PROCESSES 16

    /**************************************************************************/
    /*  Prototypes                                                            */
    /**************************************************************************/

    inv_error_t inv_set_fifo_rate(unsigned short fifoRate);
    unsigned short inv_get_fifo_rate(void);
    int_fast16_t inv_get_sample_step_size_ms(void);
    int_fast16_t inv_get_sample_frequency(void);
    long inv_decode_temperature(short tempReg);

    // Register callbacks after a packet of FIFO data is processed
    inv_error_t inv_register_fifo_rate_process(inv_obj_func func, int priority);
    inv_error_t inv_unregister_fifo_rate_process(inv_obj_func func);
    inv_error_t inv_run_fifo_rate_processes(void);

    // Setup FIFO for various output
    inv_error_t inv_send_quaternion(uint_fast16_t accuracy);
    inv_error_t inv_send_gyro(uint_fast16_t elements, uint_fast16_t accuracy);
    inv_error_t inv_send_accel(uint_fast16_t elements, uint_fast16_t accuracy);
    inv_error_t inv_send_linear_accel(uint_fast16_t elements,
                                      uint_fast16_t accuracy);
    inv_error_t inv_send_linear_accel_in_world(uint_fast16_t elements,
                                               uint_fast16_t accuracy);
    inv_error_t inv_send_cntrl_data(uint_fast16_t elements,
                                    uint_fast16_t accuracy);
    inv_error_t inv_send_sensor_data(uint_fast16_t elements,
                                     uint_fast16_t accuracy);
    inv_error_t inv_send_external_sensor_data(uint_fast16_t elements,
                                              uint_fast16_t accuracy);
    inv_error_t inv_send_gravity(uint_fast16_t elements,
                                 uint_fast16_t accuracy);
    inv_error_t inv_send_packet_number(uint_fast16_t accuracy);
    inv_error_t inv_send_quantized_accel(uint_fast16_t elements,
                                         uint_fast16_t accuracy);
    inv_error_t inv_send_eis(uint_fast16_t elements, uint_fast16_t accuracy);

    // Get Fixed Point data from FIFO
    inv_error_t inv_get_accel(long *data);
    inv_error_t inv_get_quaternion(long *data);
    inv_error_t inv_get_6axis_quaternion(long *data);
    inv_error_t inv_get_relative_quaternion(long *data);
    inv_error_t inv_get_gyro(long *data);
    inv_error_t inv_set_linear_accel_filter_coef(float coef);
    inv_error_t inv_get_linear_accel(long *data);
    inv_error_t inv_get_linear_accel_in_world(long *data);
    inv_error_t inv_get_gyro_and_accel_sensor(long *data);
    inv_error_t inv_get_gyro_sensor(long *data);
    inv_error_t inv_get_cntrl_data(long *data);
    inv_error_t inv_get_temperature(long *data);
    inv_error_t inv_get_gravity(long *data);
    inv_error_t inv_get_unquantized_accel(long *data);
    inv_error_t inv_get_quantized_accel(long *data);
    inv_error_t inv_get_external_sensor_data(long *data, int size);
    inv_error_t inv_get_eis(long *data);

    // Get Floating Point data from FIFO
    inv_error_t inv_get_accel_float(float *data);
    inv_error_t inv_get_quaternion_float(float *data);

    inv_error_t inv_process_fifo_packet(const unsigned char *dmpData);
    inv_error_t inv_read_and_process_fifo(int_fast8_t numPackets,
                                          int_fast8_t * processed);

    inv_error_t inv_set_fifo_processed_callback(void (*func) (void));

    inv_error_t inv_init_fifo_param(void);
    inv_error_t inv_close_fifo(void);
    inv_error_t inv_set_gyro_data_source(uint_fast8_t source);
    inv_error_t inv_decode_quantized_accel(void);
    unsigned long inv_get_gyro_sum_of_sqr(void);
    unsigned long inv_accel_sum_of_sqr(void);
    void inv_override_quaternion(float *q);
#ifdef UMPL
    bool isUmplDataInFIFO(void);
    void setUmplDataInFIFOFlag(bool flag);
#endif
    uint_fast16_t inv_get_fifo_packet_size(void);
#ifdef __cplusplus
}
#endif
#endif                          // INVENSENSE_INV_FIFO_H__