Serial ports on the SA1100 (cont’d)
// some register pointers
struct sp_regs * sp1 = (struct sp_regs *)SP1_BASE;
struct ppc_regs * ppc = (struct ppc_regs *)PPC_BASE;
unsigned * gpdr = (unsigned *)GP_PIN_DIR;
unsigned * gafr = (unsigned *)GP_PIN_AFR;
unsigned bdr = serialGetBaudRateDivisor( 9600 );
Install_Handler( (unsigned)Serial_Handler, (unsigned *)IRQ_VECTOR );
printf( "Serial Test Program\n" );
// enable serial port 1 in PPC (see 11-184 in Developer Manual)
ppc->ppfr &= 0xFFFFCFFF; // disable PPC control of serial port 1 (11-192)
// the board uses the UART redirected to GPIO 14-15, so we also need to
ppc->ppar |= 0x00001000; // enable serial port 1 redirection (11-189)
*gafr |= 0x0000C000; // set pins 14-15
*gpdr |= 0x00004000; // set bit 14
*gpdr &= 0xFFFF7FFF; // clear bit 15