1 /* 2 $License: 3 Copyright 2011 InvenSense, Inc. 4 5 Licensed under the Apache License, Version 2.0 (the "License"); 6 you may not use this file except in compliance with the License. 7 You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, software 12 distributed under the License is distributed on an "AS IS" BASIS, 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 See the License for the specific language governing permissions and 15 limitations under the License. 16 $ 17 */ 18 19 #ifndef INVENSENSE_INV_FIFO_H__ 20 #define INVENSENSE_INV_FIFO_H__ 21 22 #include "mltypes.h" 23 #include "mlinclude.h" 24 #include "ml.h" 25 #ifdef INV_INCLUDE_LEGACY_HEADERS 26 #include "mlFIFO_legacy.h" 27 #endif 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /**************************************************************************/ 34 /* Elements */ 35 /**************************************************************************/ 36 37 #define INV_ELEMENT_1 (0x0001) 38 #define INV_ELEMENT_2 (0x0002) 39 #define INV_ELEMENT_3 (0x0004) 40 #define INV_ELEMENT_4 (0x0008) 41 #define INV_ELEMENT_5 (0x0010) 42 #define INV_ELEMENT_6 (0x0020) 43 #define INV_ELEMENT_7 (0x0040) 44 #define INV_ELEMENT_8 (0x0080) 45 46 #define INV_ALL (0xFFFF) 47 #define INV_ELEMENT_MASK (0x00FF) 48 49 /**************************************************************************/ 50 /* Accuracy */ 51 /**************************************************************************/ 52 53 #define INV_16_BIT (0x0100) 54 #define INV_32_BIT (0x0200) 55 #define INV_ACCURACY_MASK (0x0300) 56 57 /**************************************************************************/ 58 /* Accuracy */ 59 /**************************************************************************/ 60 61 #define INV_GYRO_FROM_RAW (0x00) 62 #define INV_GYRO_FROM_QUATERNION (0x01) 63 64 /**************************************************************************/ 65 /* High Rate Proceses */ 66 /**************************************************************************/ 67 68 #define MAX_HIGH_RATE_PROCESSES 16 69 70 /**************************************************************************/ 71 /* Prototypes */ 72 /**************************************************************************/ 73 74 inv_error_t inv_set_fifo_rate(unsigned short fifoRate); 75 unsigned short inv_get_fifo_rate(void); 76 int_fast16_t inv_get_sample_step_size_ms(void); 77 int_fast16_t inv_get_sample_frequency(void); 78 long inv_decode_temperature(short tempReg); 79 80 // Register callbacks after a packet of FIFO data is processed 81 inv_error_t inv_register_fifo_rate_process(inv_obj_func func, int priority); 82 inv_error_t inv_unregister_fifo_rate_process(inv_obj_func func); 83 inv_error_t inv_run_fifo_rate_processes(void); 84 85 // Setup FIFO for various output 86 inv_error_t inv_send_quaternion(uint_fast16_t accuracy); 87 inv_error_t inv_send_gyro(uint_fast16_t elements, uint_fast16_t accuracy); 88 inv_error_t inv_send_accel(uint_fast16_t elements, uint_fast16_t accuracy); 89 inv_error_t inv_send_linear_accel(uint_fast16_t elements, 90 uint_fast16_t accuracy); 91 inv_error_t inv_send_linear_accel_in_world(uint_fast16_t elements, 92 uint_fast16_t accuracy); 93 inv_error_t inv_send_cntrl_data(uint_fast16_t elements, 94 uint_fast16_t accuracy); 95 inv_error_t inv_send_sensor_data(uint_fast16_t elements, 96 uint_fast16_t accuracy); 97 inv_error_t inv_send_external_sensor_data(uint_fast16_t elements, 98 uint_fast16_t accuracy); 99 inv_error_t inv_send_gravity(uint_fast16_t elements, 100 uint_fast16_t accuracy); 101 inv_error_t inv_send_packet_number(uint_fast16_t accuracy); 102 inv_error_t inv_send_quantized_accel(uint_fast16_t elements, 103 uint_fast16_t accuracy); 104 inv_error_t inv_send_eis(uint_fast16_t elements, uint_fast16_t accuracy); 105 106 // Get Fixed Point data from FIFO 107 inv_error_t inv_get_accel(long *data); 108 inv_error_t inv_get_quaternion(long *data); 109 inv_error_t inv_get_6axis_quaternion(long *data); 110 inv_error_t inv_get_relative_quaternion(long *data); 111 inv_error_t inv_get_gyro(long *data); 112 inv_error_t inv_set_linear_accel_filter_coef(float coef); 113 inv_error_t inv_get_linear_accel(long *data); 114 inv_error_t inv_get_linear_accel_in_world(long *data); 115 inv_error_t inv_get_gyro_and_accel_sensor(long *data); 116 inv_error_t inv_get_gyro_sensor(long *data); 117 inv_error_t inv_get_cntrl_data(long *data); 118 inv_error_t inv_get_temperature(long *data); 119 inv_error_t inv_get_gravity(long *data); 120 inv_error_t inv_get_unquantized_accel(long *data); 121 inv_error_t inv_get_quantized_accel(long *data); 122 inv_error_t inv_get_external_sensor_data(long *data, int size); 123 inv_error_t inv_get_eis(long *data); 124 125 // Get Floating Point data from FIFO 126 inv_error_t inv_get_accel_float(float *data); 127 inv_error_t inv_get_quaternion_float(float *data); 128 129 inv_error_t inv_process_fifo_packet(const unsigned char *dmpData); 130 inv_error_t inv_read_and_process_fifo(int_fast8_t numPackets, 131 int_fast8_t * processed); 132 133 inv_error_t inv_set_fifo_processed_callback(void (*func) (void)); 134 135 inv_error_t inv_init_fifo_param(void); 136 inv_error_t inv_close_fifo(void); 137 inv_error_t inv_set_gyro_data_source(uint_fast8_t source); 138 inv_error_t inv_decode_quantized_accel(void); 139 unsigned long inv_get_gyro_sum_of_sqr(void); 140 unsigned long inv_accel_sum_of_sqr(void); 141 void inv_override_quaternion(float *q); 142 #ifdef UMPL 143 bool isUmplDataInFIFO(void); 144 void setUmplDataInFIFOFlag(bool flag); 145 #endif 146 uint_fast16_t inv_get_fifo_packet_size(void); 147 #ifdef __cplusplus 148 } 149 #endif 150 #endif // INVENSENSE_INV_FIFO_H__ 151