/************************************************************
**
**     Object name : rasp24-lld
**
**     Public      : 
**                   
**
**     Private     : 
**
**
**     Description
**     -- -- -- -- -- -- -- --
**     RASP24のDriverのヘッダファイル
**
**     History
**     -- -- -- -- -- -- -- --
**     [ver3履歴]
**     2012.11.24 K.Takagi 多重インクルード防止用マクロ定義
**     2012.11.13 K.Takagi PWM関係のコマンドを追加
**
**     [ver2履歴]
**     2011.04.20 K.Takagi LED設定コマンドを追加
**     2011.04.19 K.Takagi A/D動作中のモード関係を追加
**                         GPIO関係を追加
**
**
**
**
**     [ver1履歴]
**     2011.02.07 K.Takagi 電源OFF用のコマンド追加
**     2010.12.21 K.Takagi D/A FIFO関係を追加
**     2010.11.17 K.Takagi 構造体名、コマンド名を一部変更
**     2010.11.05 K.Takagi 新規作成
**
**     Copyright (c) 2010 - 2011
**     System In Frontier,Inc.
**
**
**
*/


/*=========================================================*/
/*               Special Macro Definition                  */
/*=========================================================*/
#ifndef _INCLUDE_RASP24_DRIVER_H_
#define _INCLUDE_RASP24_DRIVER_H_


/*=========================================================*/
/*                   Include Files                         */
/*=========================================================*/
#include <linux/ioctl.h>


/*=========================================================*/
/*                 Structure Declaration                   */
/*=========================================================*/

typedef struct _SYSTEM_INFO_t_
{
    unsigned short module_id;
    unsigned short version;
} SYSTEM_INFO_t;

typedef struct _CAPTURE_CHANNELS_t_
{
    int board_no;
    int channels;
} CAPTURE_CHANNELS_t;

typedef struct _CAPTURE_GAIN_t_
{
    int channel;
    int gain;
} CAPTURE_GAIN_t;

typedef struct _LOOP_BACK_CHANNEL_t_
{
    int da_channel;
    int ad_channel;
} LOOP_BACK_CHANNEL_t;

typedef struct _LOOP_BACK_MODE_t_
{
    int channel;
    int flag;
} LOOP_BACK_MODE_t;

typedef struct _DA_CHANNEL_MODE_t_
{
    int board_no;
    int mode;
} DA_CHANNEL_MODE_t;

typedef struct _DA_OUTPUT_ENABLE_t_
{
    int channel;
    int flag;
} DA_OUTPUT_ENABLE_t;


typedef struct _DA_MUTE_t_
{
    int channel;
    int flag;
} DA_MUTE_t;

typedef struct _DA_GAIN_t_
{
    int channel;
    int gain;
} DA_GAIN_t;


#define PWM_IN_CH_NUM   (8+1)
#define PWM_OUT_CH_NUM  12

typedef struct _PWM_IN_DATA_t_
{
    int ch;
    int count;
} PWM_IN_DATA_t;

typedef struct _PWM_IN_DATA_ALL_t_
{
    int count[PWM_IN_CH_NUM];
} PWM_IN_DATA_ALL_t;

typedef struct _PWM_OUT_DATA_t_
{
    int ch;
    int start;
    int width;
} PWM_OUT_DATA_t;

typedef struct _PWM_OUT_DATA_ALL_t_
{
    int start[PWM_OUT_CH_NUM];
    int width[PWM_OUT_CH_NUM];
} PWM_OUT_DATA_ALL_t;


/*=========================================================*/
/*                   Macro Definition                      */
/*=========================================================*/
#define RASP24_IOCTL_MAGIC                    0xEA


#define FIO_RASP24_AD_START                   _IO(RASP24_IOCTL_MAGIC,   1)
#define FIO_RASP24_AD_STOP                    _IO(RASP24_IOCTL_MAGIC,   2)
#define FIO_RASP24_DA_START                   _IO(RASP24_IOCTL_MAGIC,   3)
#define FIO_RASP24_DA_STOP                    _IO(RASP24_IOCTL_MAGIC,   4)
#define FIO_RASP24_DA_STOP_WAIT               _IO(RASP24_IOCTL_MAGIC,   5)
#define FIO_RASP24_DA_READY                   _IO(RASP24_IOCTL_MAGIC,   6)
#define FIO_RASP24_AD_DA_START                _IO(RASP24_IOCTL_MAGIC,   7)

#define FIO_RASP24_SET_FREQ                   _IOW(RASP24_IOCTL_MAGIC,  8, int)
#define FIO_RASP24_GET_FREQ                   _IOR(RASP24_IOCTL_MAGIC,  9, int)

#define FIO_RASP24_SET_CAPTURE_CHANNELS       _IOW(RASP24_IOCTL_MAGIC, 10, CAPTURE_CHANNELS_t)
#define FIO_RASP24_GET_CAPTURE_CHANNELS       _IOR(RASP24_IOCTL_MAGIC, 11, CAPTURE_CHANNELS_t)

#define FIO_RASP24_SET_WORD_CLOCK             _IOW(RASP24_IOCTL_MAGIC, 12, int)

#define FIO_RASP24_GET_SYSTEM_INFO            _IOR(RASP24_IOCTL_MAGIC, 13, SYSTEM_INFO_t)

#define FIO_RASP24_SET_AD_DATA_FORMAT         _IOW(RASP24_IOCTL_MAGIC, 14, int)
#define FIO_RASP24_GET_AD_DATA_FORMAT         _IOR(RASP24_IOCTL_MAGIC, 15, int)

#define FIO_RASP24_SET_AD_GAIN                _IOW(RASP24_IOCTL_MAGIC, 16, CAPTURE_GAIN_t)
#define FIO_RASP24_GET_AD_GAIN                _IOR(RASP24_IOCTL_MAGIC, 17, CAPTURE_GAIN_t)

#define FIO_RASP24_SET_DA_LOOP_BACK_CHANNEL   _IOW(RASP24_IOCTL_MAGIC, 18, LOOP_BACK_CHANNEL_t)
#define FIO_RASP24_GET_DA_LOOP_BACK_CHANNEL   _IOR(RASP24_IOCTL_MAGIC, 19, LOOP_BACK_CHANNEL_t)

#define FIO_RASP24_SET_DA_LOOP_BACK_MODE      _IOW(RASP24_IOCTL_MAGIC, 20, LOOP_BACK_MODE_t)
#define FIO_RASP24_GET_DA_LOOP_BACK_MODE      _IOR(RASP24_IOCTL_MAGIC, 21, LOOP_BACK_MODE_t)

#define FIO_RASP24_SET_DA_OUTPUT_ENABLE       _IOW(RASP24_IOCTL_MAGIC, 22, DA_OUTPUT_ENABLE_t)
#define FIO_RASP24_GET_DA_OUTPUT_ENABLE       _IOR(RASP24_IOCTL_MAGIC, 23, DA_OUTPUT_ENABLE_t)

#define FIO_RASP24_SET_DA_CHANNEL_MODE        _IOW(RASP24_IOCTL_MAGIC, 24, DA_CHANNEL_MODE_t)
#define FIO_RASP24_GET_DA_CHANNEL_MODE        _IOR(RASP24_IOCTL_MAGIC, 25, DA_CHANNEL_MODE_t)

#define FIO_RASP24_SET_DA_DATA_FORMAT         _IOW(RASP24_IOCTL_MAGIC, 26, int)
#define FIO_RASP24_GET_DA_DATA_FORMAT         _IOR(RASP24_IOCTL_MAGIC, 27, int)

#define FIO_RASP24_SET_DA_MUTE                _IOW(RASP24_IOCTL_MAGIC, 28, DA_MUTE_t)
#define FIO_RASP24_GET_DA_MUTE                _IOR(RASP24_IOCTL_MAGIC, 29, DA_MUTE_t)

#define FIO_RASP24_SET_DA_GAIN                _IOW(RASP24_IOCTL_MAGIC, 30, DA_GAIN_t)
#define FIO_RASP24_GET_DA_GAIN                _IOR(RASP24_IOCTL_MAGIC, 31, DA_GAIN_t)

#define FIO_RASP24_GET_BOARD_NUM              _IOR(RASP24_IOCTL_MAGIC, 32, int)

#define FIO_RASP24_SET_AD_HEADER_MODE         _IOW(RASP24_IOCTL_MAGIC, 33, int)
#define FIO_RASP24_GET_AD_HEADER_MODE         _IOR(RASP24_IOCTL_MAGIC, 34, int)

#define FIO_RASP24_SET_AD_SLEEP_MODE          _IOW(RASP24_IOCTL_MAGIC, 35, int)
#define FIO_RASP24_GET_AD_SLEEP_MODE          _IOR(RASP24_IOCTL_MAGIC, 36, int)

#define FIO_RASP24_DA_FIFO_RESET              _IO(RASP24_IOCTL_MAGIC,  37)
#define FIO_RASP24_GET_DA_FIFO_SIZE           _IOR(RASP24_IOCTL_MAGIC, 38, int)

#define FIO_RASP24_POWER_DOWN                 _IO(RASP24_IOCTL_MAGIC,  39)

#define FIO_RASP24_SET_AD_ACTIVE_MODE         _IOW(RASP24_IOCTL_MAGIC, 40, int)
#define FIO_RASP24_GET_AD_ACTIVE_MODE         _IOR(RASP24_IOCTL_MAGIC, 41, int)

#define FIO_RASP24_SET_GPIO_DATA              _IOW(RASP24_IOCTL_MAGIC, 42, int)
#define FIO_RASP24_GET_GPIO_DATA              _IOR(RASP24_IOCTL_MAGIC, 43, int)
#define FIO_RASP24_SET_GPIO_DIRECTION         _IOW(RASP24_IOCTL_MAGIC, 44, int)
#define FIO_RASP24_GET_GPIO_DIRECTION         _IOR(RASP24_IOCTL_MAGIC, 45, int)

#define FIO_RASP24_SET_BLUE_LED               _IOW(RASP24_IOCTL_MAGIC, 46, int)
#define FIO_RASP24_SET_RED_LED                _IOW(RASP24_IOCTL_MAGIC, 47, int)


#define FIO_RASP24_GET_AD_SMP_CNT             _IOR(RASP24_IOCTL_MAGIC, 50, int)

#define FIO_RASP24_SET_PWM_PERIOD             _IOW(RASP24_IOCTL_MAGIC, 51, int)
#define FIO_RASP24_GET_PWM_PERIOD             _IOR(RASP24_IOCTL_MAGIC, 52, int)

#define FIO_RASP24_SET_PWM_MAX_ON_CNT         _IOW(RASP24_IOCTL_MAGIC, 53, int)
#define FIO_RASP24_GET_PWM_MAX_ON_CNT         _IOR(RASP24_IOCTL_MAGIC, 54, int)

#define FIO_RASP24_SET_PWM_MONI_CTRL          _IOW(RASP24_IOCTL_MAGIC, 55, int)
#define FIO_RASP24_GET_PWM_MONI_CTRL          _IOR(RASP24_IOCTL_MAGIC, 56, int)

#define FIO_RASP24_GET_PWM_IN_CNT             _IOR(RASP24_IOCTL_MAGIC, 57, PWM_IN_DATA_t)
#define FIO_RASP24_GET_PWM_IN_CNT_ALL         _IOR(RASP24_IOCTL_MAGIC, 58, PWM_IN_DATA_ALL_t)

#define FIO_RASP24_SET_PWM_OUT_CNT            _IOW(RASP24_IOCTL_MAGIC, 59, PWM_OUT_DATA_t)
#define FIO_RASP24_GET_PWM_OUT_CNT            _IOR(RASP24_IOCTL_MAGIC, 60, PWM_OUT_DATA_t)

#define FIO_RASP24_SET_PWM_OUT_CNT_ALL        _IOW(RASP24_IOCTL_MAGIC, 61, PWM_IN_DATA_ALL_t)
#define FIO_RASP24_GET_PWM_OUT_CNT_ALL        _IOR(RASP24_IOCTL_MAGIC, 62, PWM_IN_DATA_ALL_t)

#endif /* End of _INCLUDE_RASP24_DRIVER_H_ */

/* EOF */
