/**************************************************************
 *   DIO-144  :      DEMO_02 Program                          *
 *   Function :  Digital Input Output                         *
 *   Langurage                                                *
 **************************************************************/

 #include "stdio.h"
 #include "dio144.h"


 main()

 {
 int cn0_pa, cn0_pc_low, cn1_pb, cn1_pc_high;

 int i;

 clrscr();

 if(_DIO144_Init(0x2c0)) printf(" Can't Found DIO-144 !! ");

    /* _DIO144_Conf( CN number , Port A Conf , Port B Conf ,
			     Port C Low nibble Conf , Port C High nibble Conf) */


			    /* Config  1: For Input  */
			    /* Config  0: For Output */


 _DIO144_Conf(CN0,1,0,1,0); /* Config CN0 PA      1 : Input  */
			    /* Config CN0 PB       0 : Output */
			    /* Config CN0 PC_Low   1 : Input  */
			    /* Config CN0 PC_High  0 : Output */

 _DIO144_Conf(CN1,0,1,0,1);
			    /* Config CN1 PA       0 : Output  */
			    /* Config CN1 PB       1 : Input   */
			    /* Config CN1 PC_Low   0 : Output  */
			    /* Config CN1 PC_High  1 : Input   */

 printf(" DIO-144 DEMO Program\n ");
 gotoxy(2,12);

 printf(" Press any key to countiune \n ");
 printf(" Press <q> to Quit          \n ");





 for (i=0;i<=255;i++)
 {
   gotoxy(1,2);

   _DIO144_Output(CN0,Port_B,i);
   _DIO144_Output(CN0,Port_C_Higher,i);
   _DIO144_Output(CN1,Port_A,i);
   _DIO144_Output(CN1,Port_C_Lower,i);

   cn0_pa      = _DIO144_Input(CN0,Port_A);
   cn0_pc_low  = _DIO144_Input(CN0,Port_C_Lower);
   cn1_pb      = _DIO144_Input(CN1,Port_B);
   cn1_pc_high = _DIO144_Input(CN1,Port_C_Higher);

   printf(" CN0 Port B , Port C High  nibble Output Data = %X\n",i);
   printf(" CN1 Port A , Port C Lower nibble Output Data = %X\n\n",i);

   printf(" CN0 Port A              ( 8 bit) , Read Data = %X \n",cn0_pa);
   printf(" CN0 Port C Lower nibble ( 4 bit) , Read Data = %X \n",cn0_pc_low);
   printf(" CN1 Port B              ( 8 bit) , Read Data = %X \n",cn1_pb);
   printf(" CN1 Port C High  nibble ( 4 bit) , Read Data = %X \n",cn1_pc_high);

  if( getch()=='q') exit();
  }

}
