Skip to content. | Skip to navigation

Personal tools




//  82C55.h
//  Last updated: 4/15/2006

/* The CTRL55 port determines the directions of Port A, B, and C in
   mode 0.  The simple digital I/O makes mode 0 the most commonly used mode.
   The following table shows effect of various control byte outputs to CTRL55.

   Port A   Port B   Port C   Port C     Control Byte
                     7-4      3-0        (CTRL55)

   Out      Out      Out      Out        0x80
   Out      Out      Out      In         0x81
   Out      Out      In       Out        0x88
   Out      Out      In       In         0x89
   Out      In       Out      Out        0x82
   Out      In       Out      In         0x83
   Out      In       In       Out        0x8A
   Out      In       In       In         0x8B
   In       Out      Out      Out        0x90
   In       Out      Out      In         0x91
   In       Out      In       Out        0x98
   In       Out      In       In         0x99
   In       In       Out      Out        0x92
   In       In       Out      In         0x93
   In       In       In       Out        0x9A
   In       In       In       In         0x9B

// This function initializes all I/O pins for input or output
void Init_IO(unsigned control_byte,unsigned PAInit,unsigned PCInit);
// control_byte: configures the three ports as inputs or output according
// to the table above.
// control_byte will usually be 0x82 =>
// Port A & Port C outputs, PortB inputs
// PAInit and PCInit are the initial values (set/clear)
// you want to output to the 8 lines in Port A and Port C

// This function returns the state of the current I/O pin specified by
// the argument bit_number.
int read_bit(int bit_number);
//  bit_number: The integer argument specifies the bit number to read.
//              Valid arguments are from 0 to 23.
//  Returns the current state of the specified bit, 1 or 0.

// This function sets the specified I/O pin to either high or low as dictated
// by the val argument. A non zero value for val sets the bit.
// This routine considers port's C 8 bits to be just outputs or inputs
void write_bit(int bit_number, int val);
// bit_number: The I/O pin to access is specified by bit_number 0 to 23.
// val: The setting for the specified bit, either 1 or 0.

Generated by GNU Enscript
Document Actions