/*******************************************************************************
 * @file	app_raw.h
 * @author	CandyPops Co.
 * @version V1.0.0
 * @date	2022-09-05
 * @brief	
 ******************************************************************************/

#ifndef _APP_RAW_H_
#define _APP_RAW_H_
#include "sdk_config.h"

#include <stdint.h>
#include "inv_imu_transport.h"
#include "inv_imu_defs.h"
#include "inv_imu_driver.h"


/*** Example configuration ***/

/* 
 * Select communication link between SmartMotion and IMU 
 */
#define SERIF_TYPE           UI_I2C

/*
 * Set power mode flag
 * Set this flag to run example in low-noise mode.
 * Reset this flag to run example in low-power mode.
 * Note: low-noise mode is not available with sensor data frequencies less than 12.5Hz.
 */
#define USE_LOW_NOISE_MODE   1

/*
 * Select Fifo resolution Mode (default is low resolution mode)
 * Low resolution mode: 16 bits data format
 * High resolution mode: 20 bits data format
 * Warning: Enabling High Res mode will force FSR to 16g and 2000dps
 */
#define USE_HIGH_RES_MODE    0

/*
 * Select to use FIFO or to read data from registers
 */
#define USE_FIFO             0


/**
 * \brief This function is in charge of reseting and initializing IMU device. It should
 * be successfully executed before any access to IMU device.
 *
 * \return 0 on success, negative value on error.
 */
int setup_imu_device(struct inv_imu_serif *icm_serif);

/**
 * \brief This function configures the device in order to output gyro and accelerometer.
 * \return 0 on success, negative value on error.
 */
int configure_imu_device(void);

/**
 * \brief This function extracts data from the IMU FIFO.
 * \return 0 on success, negative value on error.
 */
int get_imu_data(void);

/**
 * \brief This function is the custom handling packet function.
 * \param[in] event structure containing sensor data from one packet
 */
void imu_callback(inv_imu_sensor_event_t *event);

/**
 * \brief Direct IMU register read — bypasses DRDY, sends rsp: via BLE.
 * \return 0 on success, negative value on error.
 */
int imu_read_direct(void);


#endif /* !_APP_RAW_H_ */
