// digi3a.c // The following are known only to the functions that follow them. // They can't be modified or even accessed by anything above this point. unsigned base; unsigned switch_port; unsigned ppi_porta; unsigned ppi_portb; unsigned ppi_portc; // set up the ppi -- change back to a void return for normal operation int set_up_ppi(int mode) { unsigned control = base + 0x23; int command; command = (mode & 0x0c) << 1; // shift bits 2 and 3 into positions 3 and 4 command += (mode & 3); // add in bits 0 and 1 command |= 0x80; // OR in bit 7 for PPI set up // remove the following for normal operation return command; outp(control, command); // set according to mode command } // end set_up_ppi(..) // get the port -- in the future, this will grow into an auto-detect function void get_port(void) { base = 0x300; switch_port = base + 0x18; ppi_porta = base + 0x20; ppi_portb = base + 0x21; ppi_portc = base + 0x22; } // end get_port() // end digi3a.c