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

#ifndef _SYSTEM_INTERFACE_H_
#define _SYSTEM_INTERFACE_H_

#include "inv_imu_transport.h"
#include <stdbool.h>
/* TODO: Move that somewhere else */
#ifndef TO_MASK
#define TO_MASK(a) (1U << (unsigned)(a))
#endif


#define ICM42670_I2C_INSTANCE 		0 /**< I2C instance index. */
#define ICM42670_I2C_SDA_PIN    	NRF_GPIO_PIN_MAP(1,15)
#define ICM42670_I2C_SCL_PIN    	NRF_GPIO_PIN_MAP(1,14)
#define ICM42670_INT1_PIN     		NRF_GPIO_PIN_MAP(1,13)
#define ICM42670_INT2_PIN     		NRF_GPIO_PIN_MAP(0,26)
uint32_t icm42670_twi_tx(  uint8_t       device_id,
                          uint8_t const *       p_data,
                          uint8_t               length,
                          bool                  no_stop);
uint32_t icm42670_twi_rx(  uint8_t       device_id,
                          uint8_t *             p_data,
                          uint8_t               length);
uint8_t cat_read (uint8_t device_id, uint8_t address, uint8_t *data);
void cat_write (uint8_t device_id, uint8_t address, uint8_t *data);	
void inv_i2c_master_uninitialize(void);
void inv_i2c_master_initialize(void);
int inv_io_hal_init(struct inv_imu_serif *serif);
int inv_io_hal_read_reg(struct inv_imu_serif *serif, uint8_t reg, uint8_t * rbuffer, uint32_t rlen);
int inv_io_hal_write_reg(struct inv_imu_serif *serif, uint8_t reg, const uint8_t * wbuffer, uint32_t wlen);

#endif /* !_SYSTEM_INTERFACE_H_ */

