/*
 * __________________________________________________________________
 *
 * Copyright (C) [2023] by InvenSense, Inc.
 * 
 * Permission to use, copy, modify, and/or distribute this software
 * for any purpose with or without fee is hereby granted.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
 * WARRANTIES  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
 * WARRANTIES OF MERCHANTABILITY  AND FITNESS. IN NO EVENT SHALL
 * THE AUTHOR BE LIABLE  FOR ANY SPECIAL, DIRECT, INDIRECT, OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 * __________________________________________________________________
 */

#ifndef _EXAMPLE_WOM_H_
#define _EXAMPLE_WOM_H_

#include <stdint.h>
#include "Invn/Drivers/Ixm42xxx/Ixm42xxxTransport.h"
#include "Invn/Drivers/Ixm42xxx/Ixm42xxxDefs.h"
#include "Invn/Drivers/Ixm42xxx/Ixm42xxxDriver_HL.h"
#include "Invn/Drivers/Ixm42xxx/Ixm42xxxDriver_HL_apex.h"

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

/**
 * \brief This function configures the device in order to output WoM event.
 *
 * Then function sets full scale range and frequency for acceland it 
 * starts it in the requested power mode.
 *
 * \param[in] is_low_noise_mode : if true sensor is started in low-noise mode else in 
 *                                low-power mode.
 * \param[in] acc_fsr_g :   full scale range for accelerometer. See IXM42XXX_ACCEL_CONFIG0_FS_SEL_t Ixm42xxxDefs.h
 *                         for possible values.
 * \param[in] acc_freq :    accelerometer frequency. See IXM42XXX_ACCEL_CONFIG0_ODR_t in Ixm42xxxDefs.h
 *                         for possible values.
 * \return 0 on success, negative value on error.
 */
int ConfigureInvDevice(uint8_t is_low_noise_mode, 
                       IXM42XXX_ACCEL_CONFIG0_FS_SEL_t acc_fsr_g,
					   IXM42XXX_ACCEL_CONFIG0_ODR_t acc_freq);

/**
 * \brief This function reads WOM status.
 *
 * \return 0 on success, negative value on error.
 */
int GetDataFromInvDevice(void);


#endif /* !_EXAMPLE_WOM_H_ */
