// $Id: control.h,v 1.1 2004/07/07 22:07:11 alpha Exp $
//
// Copyright (c) 1999-2004 Darius Rad
//
// This file is part of the OpenOtto project.
//
// OpenOtto is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//

/// \file
/// \brief Control command definitions for otto drivers (device and otherwise)
/// \todo get/set timeouts?


#ifndef _OTTO_CONTROL_H
#define _OTTO_CONTROL_H


/// \brief Perform bus initialization
///
/// Only valid on a bus
/// \param type (default, fast, slow)
/// \param addr for slow init, address to use
#define OTTO_IOCBUSINIT 0x0001

/// \brief Set bus or device bit rate
/// \param[in] rate
#define OTTO_IOCSDATARATE 0x0002

/// \brief Get bus or device bit rate
///
/// \param[out] rate
#define OTTO_IOCGDATARATE 0x0003

/// \brief Set bus address
///
/// Only valid on a bus
/// \param[in] address
#define OTTO_IOCSBUSADR 0x0004

/// \brief Get bus address
///
/// Only valid on a bus
/// \param[out] address
#define OTTO_IOCGBUSADR 0x0005

/// \brief Get file descriptor for select()
///
/// Only valid on a bus
/// \param[out] fd file descriptor
#define OTTO_IOCGSELECTFD 0x0006

/// \brief Get number of interfaces on this device
///
/// Only valid on a device
#define OTTO_IOCGIFCOUNT 0x0007


/// \brief Control data parameters
union otto_control_data
{
  struct
  {
    enum
    {
      OTTO_INIT_AUTO = 0,
      OTTO_INIT_FAST = 1,
      OTTO_INIT_SLOW = 2,
    }
    type;  ///< Initialization type
    int addr;  ///< Address for slow init
  }
  init;  ///< Initialization parameters

  int rate;  ///< Bus bit rate
  int addr;  ///< Bus address
  int fd;  ///< File descriptor
};


#endif
