/*
 * Copyright (c) 2021 Pimax. All rights reserved.
 * Author    Date          ChangeLog
 * Master    2021-03-18    First version
 * Master    2021-04-06    add error code
 */
#ifndef __TWIM_H__
#define __TWIM_H__

#include "nrf_drv_twi.h"

#define TWI_SUCCESS             (0)
#define TWI_ARGS_ERROR          (-1)
#define TWI_XFER_TIMEOUT        (-2)
#define TWI_NACK                (-3)
#define TWI_ERROR               (-4)

extern const nrf_drv_twi_t cs_twi_instance;
extern const nrf_drv_twi_t haptic_twi_instance;

void twi_init(void);

void twi_disable(void);

int twi_read_reg(const nrf_drv_twi_t *instance, 
                 uint8_t slave_addr, 
                 uint8_t reg_addr, 
                 uint8_t *read_data, 
                 uint8_t len);

int twi_write_reg(nrf_drv_twi_t *const instance,
                  uint8_t slave_addr, 
                  const uint8_t *write_data, 
                  uint8_t len);


#endif  // @page end

