components/esp-cryptoauthlib/cryptoauthlib/lib/hal/hal_linux_i2c_userspace.c
ATCA_STATUS hal_i2c_idle(ATCAIface iface)
{
    ATCAIfaceCfg *cfg = atgetifacecfg(iface);
    ATCAI2CMaster_t * hal_data = (ATCAI2CMaster_t*)atgetifacehaldat(iface);
    uint8_t data = 0x02; // idle word address value
    int f_i2c;           // I2C file descriptor

    // Initiate I2C communication
    if ( (f_i2c = open(hal_data->i2c_file, O_RDWR) ) < 0)
    {
        return ATCA_COMM_FAIL;
    }

    // Set Slave Address
    if (ioctl(f_i2c, I2C_SLAVE, cfg->atcai2c.slave_address >> 1) < 0)
    {
        close(f_i2c);
        return ATCA_COMM_FAIL;
    }

    // Send data
    if (write(f_i2c, &data, 1) != 1)
    {
        close(f_i2c);
        return ATCA_COMM_FAIL;
    }

    close(f_i2c);
    return ATCA_SUCCESS;
}
/** \brief idle CryptoAuth device using I2C bus
 * \param[in] iface  interface to logical device to idle
 * \return ATCA_SUCCESS on success, otherwise an error code.
 */
\brief idle CryptoAuth device using I2C bus
\param[in] iface  interface to logical device to idle
\return ATCA_SUCCESS on success, otherwise an error code.
\ brief idle CryptoAuth device using I2C bus \ param [ in ] iface interface to logical device to idle \ return ATCA_SUCCESS on success otherwise an error code .
ATCA_STATUS hal_i2c_idle(ATCAIface iface)
{
    ATCAIfaceCfg *cfg = atgetifacecfg(iface);
    ATCAI2CMaster_t * hal_data = (ATCAI2CMaster_t*)atgetifacehaldat(iface);
    uint8_t data = 0x02; 
    int f_i2c;           
    if ( (f_i2c = open(hal_data->i2c_file, O_RDWR) ) < 0)
    {
        return ATCA_COMM_FAIL;
    }
    if (ioctl(f_i2c, I2C_SLAVE, cfg->atcai2c.slave_address >> 1) < 0)
    {
        close(f_i2c);
        return ATCA_COMM_FAIL;
    }
    if (write(f_i2c, &data, 1) != 1)
    {
        close(f_i2c);
        return ATCA_COMM_FAIL;
    }
    close(f_i2c);
    return ATCA_SUCCESS;
}
ATCA_STATUS hal_i2c_idle ( ATCAIface iface ) { ATCAIfaceCfg * cfg = atgetifacecfg ( iface ) ; ATCAI2CMaster_t * hal_data = ( ATCAI2CMaster_t * ) atgetifacehaldat ( iface ) ; uint8_t data = 0x02 ; int f_i2c ; if ( ( f_i2c = open ( hal_data -> i2c_file , O_RDWR ) ) < 0 ) { return ATCA_COMM_FAIL ; } if ( ioctl ( f_i2c , I2C_SLAVE , cfg -> atcai2c . slave_address >> 1 ) < 0 ) { close ( f_i2c ) ; return ATCA_COMM_FAIL ; } if ( write ( f_i2c , & data , 1 ) != 1 ) { close ( f_i2c ) ; return ATCA_COMM_FAIL ; } close ( f_i2c ) ; return ATCA_SUCCESS ; }
\brief idle CryptoAuth device using I2C bus
 \param[in] iface  interface to logical device to idle
 \return ATCA_SUCCESS on success, otherwise an error code.
\ brief idle CryptoAuth device using I2C bus \ param [ in ] iface interface to logical device to idle \ return ATCA_SUCCESS on success otherwise an error code .
// idle word address value // I2C file descriptor // Initiate I2C communication // Set Slave Address // Send data