/* Write a value in a register of the device through BUS.  */
int32_t NFC_IO_WriteReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
/* Write a value in a register of the device through BUS.  */
int32_t NFC_IO_WriteReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
{
  int32_t ret = -8;
  uint32_t hal_error = HAL_OK;
  if (HAL_I2C_Mem_Write(&hI2cHandler, (uint8_t)DevAddr,
                       (uint16_t)Reg, I2C_MEMADD_SIZE_16BIT,
                       (uint8_t *)pData, Length, 0x1000) == HAL_OK)
  {
    ret = 0;
  }
  else
  {
    hal_error = HAL_I2C_GetError(&hI2cHandler);
    if ( hal_error == HAL_I2C_ERROR_AF)
    {
      return NFC_I2C_ERROR_NACK;
    }
    else
    {
      ret =  NFC_I2C_ERROR_PERIPHERAL;
    }
  }
  return ret;
}