Chapter 15 digital i/o sample configuration, Filename:main.cpp – IBASE FWA8308 User Manual

Page 36

Advertising
background image

35


#define F81866_UNLOCK

0x87

#define F81866_LOCK

0xAA

//---------------------------------------------------------------------------
unsigned int Init_F81866(void);
void Set_F81866_LD( unsigned char);
void Set_F81866_Reg( unsigned char, unsigned char);
unsigned char Get_F81866_Reg( unsigned char);
//---------------------------------------------------------------------------
#endif

//__F81866_H


Chapter 15 Digital I/O Sample Configuration


Filename: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 "F81865.H"

#define BIT0 0x01
#define BIT1 0x02
#define BIT2 0x04
#define BIT3 0x08
#define BIT4 0x10
#define BIT5 0x20
#define BIT6 0x40
#define BIT7 0x80

//---------------------------------------------------------------------------
int main (void);

void Dio5Initial(void);
void Dio5SetOutput(unsigned char);
unsigned char Dio5GetInput(void);
void Dio5SetDirection(unsigned char);
unsigned char Dio5GetDirection(void);
//---------------------------------------------------------------------------
int main (void)
{

char SIO;

unsigned char DIO;


printf("Fintek 81865/81866 digital I/O test program\n");


SIO = Init_F81865();

if (SIO == 0)

{

printf("Can not detect Fintek 81865/81866, program abort.\n");

return(1);

}//if (SIO == 0)


Dio5Initial();

/*

//for GPIO50..57

Dio5SetDirection(0xF0);

//GP50..53 = input, GP54..57=output

printf("Current DIO direction = 0x%X\n", Dio5GetDirection());


printf("Current DIO status = 0x%X\n", Dio5GetInput());


printf("Set DIO output to high\n");

Dio5SetOutput(0x0F);


printf("Set DIO output to low\n");

Dio5SetOutput(0x00);

*/

//for GPIO50..57

Dio5SetDirection(0xF0);

//GP50..53 = input, GP54..57=output


Dio5SetOutput(0x00);

//clear

//

DIO = Dio5GetInput() & 0x0F;

Advertising