#ifndef MANCH_H
#define MANCH_H

#ifdef __cplusplus
extern "C" {
#endif




struct MANCH_READ_BITS {         // bits  description
    Uint16  but_0:1;          // 1
	Uint16  but_1:1;          // 1
	Uint16  but_2:1;          // 1
	Uint16  but_3:1;          // 1
	Uint16  but_4:1;          // 1
	Uint16  but_5:1;          // 1
	Uint16  but_6:1;          // 1
	Uint16  but_7:1;          // 1
	Uint16  press_any_key:1;         // 0
};


union MANCH_READ_REG {
   Uint16                all;
   struct MANCH_READ_BITS   bit;
};


struct MANCH_WRITE_BITS {         // bits  description    
    int  number0:14;          // 1
	int  number1:14;          // 1
	Uint16  data_control:1;          // 1
	Uint16  case_line_recive2:1;          // 1
	Uint16  res0:1;          // 1
	Uint16  res1:1;          // 1
	Uint16  set_ratio_indicator:4;          // 1
	union {
       Uint16                all;
       struct
       {
    		Uint16  lamp_0:1;          // 1
    		Uint16  lamp_1:1;          // 1
    		Uint16  lamp_2:1;          // 1
    		Uint16  lamp_3:1;          // 1
    		Uint16  lamp_4:1;          // 1
    		Uint16  lamp_5:1;          // 1
    		Uint16  lamp_6:1;          // 1
    		Uint16  lamp_7:1;          // 1
    		Uint16  lamp_8:1;          // 1
    		Uint16  lamp_9:1;          // 1
    		Uint16  lamp_10:1;          // 1
    		Uint16  lamp_11:1;          // 1
    		Uint16  lamp_12:1;          // 1
    		Uint16  lamp_13:1;          // 1
    		Uint16  lamp_14:1;          // 1
    		Uint16  lamp_15:1;          // 1
       } bit;
    } lamps;
	union {
       Uint16                all;
       struct
       {
    		Uint16  lamp_0:1;          // 1
    		Uint16  lamp_1:1;          // 1
    		Uint16  lamp_2:1;          // 1
    		Uint16  lamp_3:1;          // 1
    		Uint16  lamp_4:1;          // 1
    		Uint16  lamp_5:1;          // 1
    		Uint16  lamp_6:1;          // 1
    		Uint16  lamp_7:1;          // 1
    		Uint16  lamp_8:1;          // 1
    		Uint16  lamp_9:1;          // 1
    		Uint16  lamp_10:1;          // 1
    		Uint16  lamp_11:1;          // 1
    		Uint16  lamp_12:1;          // 1
    		Uint16  lamp_13:1;          // 1
    		Uint16  lamp_14:1;          // 1
    		Uint16  lamp_15:1;          // 1
       } bit;
    } lamps_2;
	Uint16  res2:1;          // 1
	Uint16  res3:1;          // 1
	Uint16  set_ratio_lamp:4;          // 1
	Uint16  case_line_receive1:1;
};

/*

struct MANCH_WRITE1_BITS {         // bits  description    
    Uint16  number0:16;          // 1
};



struct MANCH_WRITE2_BITS {         // bits  description    
    Uint16  number1:8;          // 1
	Uint16  data_control:1;          // 1
	Uint16  case_line_recive2:1;          // 1
	Uint16  res10:1;          // 1
	Uint16  res11:1;          // 1

	Uint16  res1:6;          // 1
};

struct MANCH_WRITE3_BITS {         // bits  description    
    Uint16  lamp_0:1;          // 1
    Uint16  lamp_1:1;          // 1
    Uint16  lamp_2:1;          // 1
    Uint16  lamp_3:1;          // 1
    Uint16  lamp_4:1;          // 1
    Uint16  lamp_5:1;          // 1
    Uint16  lamp_6:1;          // 1
    Uint16  lamp_7:1;          // 1
    Uint16  lamp_8:1;          // 1
    Uint16  lamp_9:1;          // 1
    Uint16  lamp_10:1;          // 1
    Uint16  lamp_11:1;          // 1
    Uint16  lamp_12:1;          // 1
    Uint16  lamp_13:1;          // 1
    Uint16  lamp_14:1;          // 1
    Uint16  lamp_15:1;          // 1
};


union MANCH_WRITE1_REG {
   Uint16                all;
   struct MANCH_WRITE1_BITS   bit;
};

union MANCH_WRITE2_REG {
   Uint16                all;
   struct MANCH_WRITE2_BITS   bit;
};

union MANCH_WRITE3_REG {
   Uint16                all;
   struct MANCH_WRITE3_BITS   bit;
};

*/

typedef volatile struct {         // bits  description
   union MANCH_READ_REG   reg1;
} MANCH_READ_REGS;

/*
typedef volatile struct {         // bits  description
   union MANCH_WRITE1_REG   reg1;
   union MANCH_WRITE2_REG   reg2;
   union MANCH_WRITE3_REG   reg3;
} MANCH_WRITE_REGS;
*/

typedef volatile struct MANCH_WRITE_BITS MANCH_WRITE_REGS;





extern MANCH_READ_REGS ManchReadRegs_00;
extern MANCH_READ_REGS ManchReadRegs_01;
extern MANCH_READ_REGS ManchReadRegs_02;
extern MANCH_READ_REGS ManchReadRegs_03;

extern MANCH_WRITE_REGS ManchWriteRegs_00;
extern MANCH_WRITE_REGS ManchWriteRegs_01;



void read_manch();
int write_manch();
void tune_manch_lines_v1();


#ifdef __cplusplus
}
#endif /* extern "C" */


#endif  // end of MANCH_H definition