4 programming considerations, 1 i/o ports code example – Intel 386 User Manual

Page 490

Advertising
background image

16-11

INPUT/OUTPUT PORTS

16.4 PROGRAMMING CONSIDERATIONS

16.4.1 I/O Ports Code Example

The following code example contains a software routine that initializes the I/O port pins. See Ap-
pendix C
for the included header files.

#include <conio.h>

#include “80386ex.h”

#include “ev386ex.h”

/*******************************************************************************

Init_IOPorts:

Description:

This function initializes the direction and mode of the I/O port pins.

Although the pins are default configured to the peripheral state after

RESET, they must still be initialized to turn off the weak resistors.

Parameters:

Port1

Port1 Mode Configuration

Port2

Port2 Mode Configuration

Port3

Port3 Mode Configuration

PortDir1

Port1 Direction

PortDir2

Port2 Direction

PortDir3

Port3 Direction

PortLtc1

Port1 Data Latch Value

PortLtc2

Port2 Data Latch Value

PortLtc3

Port3 Data Latch Value

Returns:

None

Assumptions:

None

Syntax:

// Port 1 configuration defines

#define DCD0

0x1

#define RTS0

0x2

#define DTR0

0x4

#define DSR0

0x8

#define RI0

0X10

#define LOCK

0x20

#define HOLD

0X40

#define HOLDACK

0X80

// Port 2 configuration defines

#define CS0

0x1

#define CS1

0x2

Advertising