/***********************************************************/
/*     DIO-144   : DEMO _01 Program                        */
/*     Function  : Basic Digital input / Output            */
/*     Langurage : Turbo C
/***********************************************************/

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


main()
{
unsigned char cn1_pa , cn1_pb , cn1_pc;

int i, io_adr;

clrscr();

printf(" DIO-144 Digital Input / Output Demo Program \n");

      /* init DIO144 & get I/O address */

if(_DIO144_Init(0x2c0))
      {
         printf(" Can't Found DIO-144 \n");
         exit();
       }
else
      {
      printf(" DIO-144 I/O Address = %X \n",0x2C0 );

      }
                               /* Configuration I/O port  */

  _DIO144_Conf(CN0,0,0,0,0);     /* Set CN0 each port Output Mode */

  _DIO144_Conf(CN1,1,1,1,1);     /* Set CN1 each port Input Mode  */

  _DIO144_Conf(CN2,0,0,0,0);     /* Set CN2 each port Output Mode */

  _DIO144_Conf(CN3,1,1,1,1);     /* Set CN3 each port Input Mode  */

  _DIO144_Conf(CN4,0,0,0,0);     /* Set CN4 each port Output Mode */

  _DIO144_Conf(CN5,1,1,1,1);     /* Set CN5 each port Input Mode */





for (i=0;i<=255; i++)
{                                      /*  Output CN0 Port A,B,C DATA */

  _DIO144_Output(CN0,Port_A,i);
  _DIO144_Output(CN0,Port_B,i);
  _DIO144_Output(CN0,Port_C,i);




					/* Read CN1 Port A,B,C DATA */
  cn1_pa = _DIO144_Input(CN1,Port_A);
  cn1_pb = _DIO144_Input(CN1,Port_B);
  cn1_pc = _DIO144_Input(CN1,Port_C);

  gotoxy(1,5);

  printf("CN0 Port A,B,C Output Data %X \n",i);

  printf("CN1 Port A Input Data = %X \n",cn1_pa);
  printf("CN1 Port B Input Data = %X \n",cn1_pb);
  printf("CN1 Port C Input Data = %X \n",cn1_pc);
  if(getch()=='q') exit();
}

}

