Home | History | Annotate | Download | only in mpl
      1 /*
      2  $License:
      3     Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved.
      4     See included License.txt for License information.
      5  $
      6  */
      7 #ifndef INV_SHAKE_H__
      8 #define INV_SHAKE_H__
      9 
     10 #include "mltypes.h"
     11 
     12 
     13 #ifdef __cplusplus
     14 extern "C" {
     15 #endif
     16 
     17 	/* ------------ */
     18     /* - Defines. - */
     19     /* ------------ */
     20 
     21     #define STATE_ZERO                             0
     22     #define STATE_INIT_1                           1
     23     #define STATE_INIT_2                           2
     24     #define STATE_DETECT                           3
     25 
     26 	struct t_shake_config_params {
     27 		long shake_time_min_ms;
     28 		long shake_time_max_ms;
     29 		long shake_time_min;
     30         long shake_time_max;
     31 		unsigned char shake_time_set;
     32 		long shake_time_saved;
     33         float shake_deriv_thr;
     34         int zero_cross_thr;
     35         float accel_delta_min;
     36         float accel_delta_max;
     37 		unsigned char interp_enable;
     38 	};
     39 
     40 	struct t_shake_state_params {
     41 		unsigned char state;
     42         float accel_peak_high;
     43         float accel_peak_low;
     44         float accel_range;
     45         int num_zero_cross;
     46         short curr_shake_time;
     47 		int deriv_major_change;
     48 		int deriv_major_sign;
     49         float accel_buffer[200];
     50         float delta_buffer[200];
     51 	};
     52 
     53 	struct t_shake_data_params {
     54 		float accel_prev;
     55 		float accel_curr;
     56 		float delta_prev;
     57 		float delta_curr;
     58 		float delta_prev_buffer;
     59 	};
     60 
     61 	struct t_shake_results {
     62 		//unsigned char shake_int;
     63 		int shake_number;
     64 	};
     65 
     66 	struct t_shake_cb {
     67        void (*shake_callback)(struct t_shake_results *shake_results);
     68     };
     69 
     70 
     71     /* --------------------- */
     72     /* - Function p-types. - */
     73     /* --------------------- */
     74 	inv_error_t inv_enable_shake(void);
     75     inv_error_t inv_disable_shake(void);
     76     inv_error_t inv_init_shake(void);
     77     inv_error_t inv_start_shake(void);
     78 	int inv_set_shake_cb(void (*callback)(struct t_shake_results *shake_results));
     79 	void inv_config_shake_time_params(long sample_time_ms);
     80 	void inv_set_shake_accel_delta_min(float accel_g);
     81 	void inv_set_shake_accel_delta_max(float accel_g);
     82 	void inv_set_shake_zero_cross_thresh(int num_zero_cross);
     83 	void inv_set_shake_deriv_thresh(float shake_deriv_thresh);
     84 	void inv_set_shake_time_min_ms(long time_ms);
     85 	void inv_set_shake_time_max_ms(long time_ms);
     86 	void inv_enable_shake_data_interpolation(unsigned char en);
     87 
     88 
     89 
     90 #ifdef __cplusplus
     91 }
     92 #endif
     93 
     94 #endif // INV_SHAKE__