IBASE MB899X User Manual

Page 66

Advertising
background image

APPENDIX

62

MB899X User’s Manual

File of the Main.cpp
//=====================================================================
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//=====================================================================
#include <dos.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include "W627HF.H"
//---------------------------------------------------------------------------
void ClrKbBuf(void);
int main (void);
unsigned char GetDI(unsigned char);
void SetDo(unsigned char, unsigned char);
//---------------------------------------------------------------------------
int main (void)
{
unsigned

char

ucDO

=

0;

//data

for

digital

output

unsigned

char

ucDI;

//data

for

digital

input

unsigned char ucBuf;

char

SIO;


SIO = Init_W627HF();

if (SIO == 0)

{

printf("Can not detect Winbond 83627HF/83627THF/83627EHF, program abort.\n");

return(1);
}
switch

(SIO)

{

//-------------------------------------------------------------------

case

1:

printf("Winbond 83627HF is detected .\n");

break;
//-------------------------------------------------------------------
case

2:

printf("Winbond 83627THF is detected.\n");

break;
//-------------------------------------------------------------------
case

4:

printf("Winbond 83627EHF is detected.\n");

break;
//-------------------------------------------------------------------
}

//bit 0..3 = input signal

//bit 4..7 = output signal


ucDI

=

GetDI(0x0F);

//get

current

DI

status

SetDo(ucDO,

0xF0);

//set

current

DO

status

return

0;

}
//---------------------------------------------------------------------------
unsigned char GetDI(unsigned char Mask)
{

unsigned char result;


Set_W627HF_LD(0x07); //switch

to

logic

device

7

Set_W627HF_Reg(0xF0,

Mask);

//set

the

DIO

direction

result = Get_W627HF_Reg(0xF1) & Mask;

Advertising
This manual is related to the following products: